https://github.com/azizbekdevuz/trainium
TRAINIUM - This a NextJS turborepo app including web app and socket server offering the client pages and admin pages offering the modern and user friendly design.
https://github.com/azizbekdevuz/trainium
nextjs nodejs postgresql prisma socket socket-io socketio-client socketio-server tailwindcss typescript
Last synced: 6 days ago
JSON representation
TRAINIUM - This a NextJS turborepo app including web app and socket server offering the client pages and admin pages offering the modern and user friendly design.
- Host: GitHub
- URL: https://github.com/azizbekdevuz/trainium
- Owner: azizbekdevuz
- Created: 2025-10-29T07:02:59.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-11-05T15:06:13.000Z (5 months ago)
- Last Synced: 2025-11-05T16:24:42.008Z (5 months ago)
- Topics: nextjs, nodejs, postgresql, prisma, socket, socket-io, socketio-client, socketio-server, tailwindcss, typescript
- Language: TypeScript
- Homepage: https://trainium.shop
- Size: 21.6 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Trainium E-Commerce Platform
A modern, full-stack e-commerce platform built for selling high-tech fitness equipment. Trainium features a comprehensive product catalog, shopping cart, checkout system, real-time notifications, and an admin panel for managing all aspects of the business.
## ๐๏ธ Architecture
For a comprehensive overview of the system architecture, design patterns, and implementation details, see the [Architecture Documentation](./architecture.md).
## โจ Features
- **E-Commerce Core**
- Product catalog with variants, categories, and inventory management
- Shopping cart with guest and authenticated user support
- Multi-provider payment processing (Stripe, Toss Payments)
- Order management and tracking
- Product recommendations engine
- **User Management**
- Multi-provider authentication (Google, Kakao, Email/Password)
- Role-based access control (Admin, Staff, Customer)
- User profiles and account management
- **Real-Time Features**
- Socket.IO-based notification system
- Real-time order updates
- Product alerts and system notifications
- **Admin Panel**
- Dashboard with analytics and statistics
- Product, order, and customer management
- Category and FAQ management
- Low stock alerts and inventory tracking
- **Social Features**
- Product reviews and ratings
- Favorites and likes
- Review replies and interactions
- **Internationalization**
- Multi-language support (English, Korean, Uzbek)
- URL-based locale routing
- Translated email notifications
- **Presentation & UX**
- Design-token CSS (globals plus `styles/glass.css`, `components.css`, `admin.css`) with light/dark theming
- Glass-morphism surfaces, consistent overlays via portals, scroll-reveal and heading motion helpers
- **Desktop**: interactive background with a cursor-driven blob (Framer Motion). **Touch / coarse pointer**: CSS-only ambient layer (no scroll-bound motion) and lighter blur on nav and cards for smoother scrolling
## ๐ ๏ธ Tech Stack
- **Frontend**: Next.js 15.5, React 19, TypeScript, Tailwind CSS, Framer Motion (UI/background motion)
- **Backend**: Next.js API Routes, Express.js
- **Database**: PostgreSQL with Prisma ORM
- **Authentication**: NextAuth.js 5.0
- **Real-Time**: Socket.IO
- **Payments**: Stripe, Toss Payments
- **Email**: Resend
- **Build System**: Turbo (Monorepo)
- **Package Manager**: pnpm
## ๐ Project Structure
```
trainium/
โโโ apps/
โ โโโ web/ # Next.js web application (see architecture.md for src layout: styles/, motion/, ui/, โฆ)
โ โโโ socket/ # Socket.IO server
โโโ prisma/ # Database schema
โโโ scripts/ # Build and utility scripts
โโโ architecture.md # Architecture documentation
```
## ๐ Getting Started
### Prerequisites
- Node.js 18+
- pnpm 9.0.6+
- PostgreSQL database
- Docker (optional, for containerized deployment)
### Installation
1. Clone the repository:
```bash
git clone
cd trainium
```
2. Install dependencies:
```bash
pnpm install
```
3. Set up environment variables:
```bash
cp .env.example .env
# Edit .env with your configuration
```
Required environment variables:
- `DATABASE_URL`: PostgreSQL connection string
- `AUTH_SECRET`: NextAuth secret key
- `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET`: Google OAuth credentials
- `KAKAO_CLIENT_ID` / `KAKAO_CLIENT_SECRET`: Kakao OAuth credentials
- `STRIPE_SECRET_KEY` / `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`: Stripe credentials
- `TOSS_CLIENT_KEY` / `TOSS_SECRET_KEY`: Toss Payments credentials
- `RESEND_API_KEY`: Resend email service key
- `NEXTAUTH_URL`: Application URL
- `SOCKET_SERVER_URL`: Socket server URL for server-side HTTP calls (required in production)
- `NEXT_PUBLIC_SOCKET_URL`: Socket server URL for client WebSocket connections
- `SOCKET_ADMIN_SECRET`: Socket server admin secret (X-Admin-Secret header)
### Docker Deployment
**Important Security Note**: Environment variables are handled securely:
- `.env` files are NOT copied into Docker images
- Build-time variables (`NEXT_PUBLIC_*`) are passed via build args
- Runtime variables are loaded via `env_file` in docker-compose
**Building with Docker Compose:**
1. Ensure your `.env` file exists in the project root with all required variables
2. Build and start services:
```bash
docker-compose up -d --build
```
4. Set up the database:
```bash
# Generate Prisma client
pnpm --filter @apps/web prisma:generate
# Push schema (or run migrations)
pnpm --filter @apps/web prisma:push
# Optional: seed database
pnpm --filter @apps/web seed
```
5. Start development servers:
```bash
# Start both web and socket servers
pnpm dev
# Or start individually
pnpm dev:web # Web app on http://localhost:3000
pnpm dev:socket # Socket server on http://localhost:4000
```
## ๐ Available Scripts
### Root Level
- `pnpm dev` - Start all services in development mode
- `pnpm build` - Build all applications
- `pnpm start` - Start all services in production mode
- `pnpm lint` - Lint all code
- `pnpm typecheck` - Type check all TypeScript code
### Web Application
- `pnpm dev:web` - Start Next.js dev server (port 3000)
- `pnpm start:web` - Start Next.js production server
- `pnpm --filter @apps/web prisma:studio` - Open Prisma Studio
- `pnpm --filter @apps/web test` - Run Vitest tests
### Socket Server
- `pnpm dev:socket` - Start Socket.IO server (port 4000)
- `pnpm start:socket` - Start Socket.IO server in production
## ๐ณ Docker Deployment
The project includes Docker configuration for containerized deployment:
```bash
# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
```
## ๐ Documentation
- **[Architecture Documentation](./architecture.md)** - System architecture, design patterns, implementation details
- **[Prisma Schema](./prisma/schema.prisma)** - Database schema and models
- **[Contributing](./CONTRIBUTING.md)** - How to contribute, development workflow, coding standards
- **[Code of Conduct](./CODE_OF_CONDUCT.md)** - Community standards and expectations
- **[Security Policy](./SECURITY.md)** - How to report security vulnerabilities
## ๐ Authentication
The platform supports multiple authentication methods:
- **Google OAuth**: Social login via Google
- **Kakao OAuth**: Korean social login
- **Email/Password**: Traditional credentials authentication
All authentication is handled via NextAuth.js with JWT session strategy. Admin routes and API endpoints are protected via `requireAdminSession()`; the first admin account is created via `/admin/auth/signup` when no admin exists (bootstrap).
## ๐ณ Payment Processing
The platform integrates with two payment providers:
- **Stripe**: International payment processing
- **Toss Payments**: Korean payment gateway
Both providers support multiple currencies and handle zero-decimal currencies (KRW, JPY, VND) correctly.
## ๐ Internationalization
The platform supports three languages:
- English (en) - Default
- Korean (ko)
- Uzbek (uz)
Locale routing is URL-based (`/en/...`, `/ko/...`, `/uz/...`) with cookie-based preference storage.
## ๐ง Email Notifications
Email notifications are sent via Resend for:
- Order confirmations
- Order status updates
- Shipping notifications
## ๐ Real-Time Notifications
The platform includes a real-time notification system powered by Socket.IO:
- User-specific notifications
- Order update notifications
- Product alerts
- System-wide announcements
- Deduplication and read sync between DB and socket events
## ๐งช Development
### Code Structure
- **Components**: Reusable React components in `apps/web/src/components/` (feature folders, `ui/`, `motion/`, `background/`, etc.)
- **Styles**: Shared CSS in `apps/web/src/styles/`; global tokens and imports in `apps/web/src/app/globals.css`
- **API Routes**: Next.js API routes in `apps/web/src/app/api/`
- **Business Logic**: Core logic in `apps/web/src/lib/`
- **Types**: TypeScript definitions in `apps/web/src/types/`
### Database Management
```bash
# Open Prisma Studio
pnpm --filter @apps/web prisma:studio
# Generate ERD diagram (requires Mermaid CLI; use WSL on Windows)
node scripts/generate-erd.js
```
### CI (GitHub Actions)
On push/PR to `main`, the workflow runs: lint (web + socket), typecheck (web), and tests (web). No build step (sitemap generation requires a live DB).
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
## ๐ค Contributing
Contributions are welcome! Please read our [Contributing Guidelines](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) before submitting a pull request. Use our [issue templates](.github/ISSUE_TEMPLATE/) and [pull request template](.github/PULL_REQUEST_TEMPLATE.md) when opening issues and PRs.
## ๐ Support
For questions and discussions, use [GitHub Discussions](https://github.com/azizbekdevuz/trainium/discussions). For security issues, see [SECURITY.md](./SECURITY.md).