A robust e-commerce backend built with NestJS, featuring distributed databases, authentication, and modern architecture principles.
-
Distributed Database Architecture
- MongoDB for metadata and flexible data
- SQL Server with regional sharding (North, Central, South)
- Centralized database for shared data
-
Authentication & Authorization
- JWT-based authentication
- Role-based access control
- Secure password hashing with bcrypt
-
Core Functionalities
- User management
- Product catalog with variants
- Shopping cart system
- Order processing with regional distribution
- Category and brand management
- Framework: NestJS 10.x
- Databases:
- MongoDB (via Mongoose)
- SQL Server (via TypeORM)
- Authentication: Passport.js with JWT
- Validation: Class Validator & Class Transformer
- API Query Parser: api-query-params
- Node.js (v16 or higher)
- MongoDB
- SQL Server instances for:
- Central DB (DB)
- Northern Region (MB)
- Central Region (MT)
- Southern Region (MN)
Create a .env file in the root directory:
# App
PORT=3000
CORS_ORIGIN=http://localhost:3000
# JWT
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION_TIME=24h
# MongoDB
MONGODB_URI=mongodb://localhost:27017/your_db
# SQL Server - Central
DB_TYPE=mssql
DB_HOST=localhost
DB_PORT=1433
DB_USER=sa
DB_PASSWORD=your_password
DB_NAME=your_dbnpm installnpm run startnpm run start:devnpm run build