Skip to content

ngduyd/economic-be

Repository files navigation

E-commerce Backend API

A robust e-commerce backend built with NestJS, featuring distributed databases, authentication, and modern architecture principles.

Features

  • 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

Tech Stack

  • 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

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB
  • SQL Server instances for:
    • Central DB (DB)
    • Northern Region (MB)
    • Central Region (MT)
    • Southern Region (MN)

Environment Variables

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_db

InstallInstall

Install dependencies

npm install

Run the application

npm run start

Run in development mode

npm run start:dev

Build for production

npm run build

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published