Complete e-commerce platform for mechanical keyboards built with NestJS backend and Next.js frontend.
moda-key/
├── backend/ # NestJS REST API
│ ├── docs/ # Backend documentation (API, database, payment guides)
│ ├── prisma/ # Database schema and migrations
│ └── src/ # Source code
├── frontend/ # Next.js web application
│ ├── docs/ # Frontend documentation
│ ├── app/ # Next.js app directory
│ └── lib/ # Utilities and API client
├── project-prompt.md # Original project specification
└── todo.md # Development todo list
- Node.js 20.x or higher
- Docker & Docker Compose
- npm or yarn
cd backend
docker-compose up -dThis will start:
- PostgreSQL on port 5432
- Redis on port 6379
cd backend
# Install dependencies
npm install
# Generate Prisma client and run migrations
npx prisma generate
npx prisma migrate dev
# Start backend development server
npm run start:devBackend will be available at:
- API: http://localhost:3000/api/v1
- Swagger Docs: http://localhost:3000/api/docs
- Health Check: http://localhost:3000/api/v1/health
In a new terminal:
cd frontend
# Install dependencies
npm install
# Start frontend development server
npm run devFrontend will be available at: http://localhost:3001
# Stop backend and frontend servers (Ctrl+C in their terminals)
# Stop Docker services
cd backend
docker-compose down- NestJS 10.x - Progressive Node.js framework
- PostgreSQL 16 - Primary database
- Prisma 7 - Modern ORM
- Redis 7 - Caching layer
- JWT - Authentication
- Bull - Background job processing
- Swagger - API documentation
- Next.js 16 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Styling
- React Hooks - State management
- ✅ User authentication (register, login, JWT with refresh tokens)
- ✅ Product catalog with variants and Redis caching
- ✅ Shopping cart functionality
- ✅ Order processing with transactions
- ✅ Payment integration (Stripe) with webhook handling
- ✅ Product reviews and ratings system
- ✅ Inventory management with concurrency control
- ✅ Role-based access control (CUSTOMER, ADMIN, VENDOR)
- ✅ Admin panel with analytics and management
- ✅ API documentation (Swagger)
- ✅ Responsive UI with Tailwind CSS
- Order email notifications
- Advanced product search and filtering
- Coupon/discount system
- Product image upload
The project includes comprehensive documentation organized in dedicated docs/ folders:
- API Quick Reference - Complete API endpoint reference
- Payment Testing Guide - How to test Stripe integration
- Payment Implementation Summary - Payment module details
- Quick Database Reference - Database commands and queries
- Admin Implementation Summary - Admin features overview
- Admin Quick Reference - Admin API endpoints
- Admin API Documentation - Detailed admin API docs
- Backend Architecture - Architecture and design patterns
- Database Documentation - Database schema and relationships
- Reviews Implementation - Reviews system details
- Testing Guide - Frontend testing workflows
For API documentation, visit http://localhost:3000/api/docs when the backend is running.
The application uses a comprehensive schema with 20+ models including:
- Users & Authentication (User, RefreshToken, UserAddress)
- Product Catalog (Product, ProductVariant, Brand, Category)
- Shopping (Cart, CartItem, Order, OrderItem)
- Inventory Management (Inventory, InventoryLog)
- Payments (Payment)
- Reviews (Review, ReviewImage, ReviewVote)
- Promotions (Coupon, UserCoupon)
View complete schema: backend/prisma/schema.prisma
# Development
npm run start:dev # Start with hot reload
npm run build # Build for production
npm run start:prod # Start production server
# Database
npx prisma studio # Open database GUI
npx prisma migrate dev # Create migration
npx prisma generate # Generate Prisma client
# Testing
npm run test # Unit tests
npm run test:e2e # E2E testsnpm run dev # Development server
npm run build # Production build
npm run start # Start production server
npm run lint # Run ESLintDATABASE_URL="postgresql://moda_user:moda_password@localhost:5432/moda_key_db"
REDIS_HOST="localhost"
JWT_SECRET="your-secret-key"
PORT=3000
CORS_ORIGIN="http://localhost:3001"NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1The backend uses Docker Compose for services:
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downServices:
- PostgreSQL (port 5432)
- Redis (port 6379)
curl -X POST http://localhost:3000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!",
"firstName": "John",
"lastName": "Doe"
}'curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "SecurePass123!"
}'curl http://localhost:3000/api/v1/products?limit=10- Modular architecture with feature-based modules
- Prisma 7 with PostgreSQL adapter pattern
- Redis caching with 10-minute TTL for products
- JWT authentication with refresh tokens
- Role-based access control (RBAC)
- Global validation pipes
- Swagger documentation with decorators
- Next.js App Router for modern routing
- TypeScript API client with type safety
- Client-side state management
- Responsive design with Tailwind CSS
- Loading and error states
- Password hashing with bcrypt (10 rounds)
- JWT access tokens (15min) + refresh tokens (7 days)
- Role-based authorization
- Request validation with class-validator
- Rate limiting (100 requests per 60 seconds)
- CORS configuration
- SQL injection prevention via Prisma
- Redis caching for product catalog
- Database connection pooling
- Efficient pagination (cursor and offset-based)
- Background job processing with Bull
- Database indexes on frequently queried fields
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT
For issues or questions, please open an issue in the repository.