An open API service indexing awesome lists of open source software.

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.

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).