Một hệ thống quản lý cửa hàng (E-commerce) được xây dựng bằng Node.js, Express và MongoDB.
2026-04-20.10-10-21.mp4
Access Service
- SignUp
- JWT
- Login and Authentication
- Handle RefreshToken
Product Service
- Query Products [public]
- Query Products Using It's Id [Public]
- Create New Product [Shop]
- Update Product [Shop]
- Unpulish/Publish Product [Shop]
- Search Product [Public]
- Darf product [Shop]
Discount Service
- Generator Discount Code [Shop|Admin]
- Get All Discount Code [User|Shop]
- Get All Product By Discount Code [User]
- Get Discount Amount [User]
- Delete Discount Code [Admin|Shop]
- Cancel Discount Code [User]
Cart Service
- Add Product To Cart [User]
- Reduce Product Quantity [User]
- Increase Product Quantity [User]
- Get List To Cart [User]
- Delete Cart [User]
- Delete Cart Item [User]
Order Service
- Create New Order [User]
- Query Order [User]
- Query Order Using It's ID [User]
- Update Order Status[Admin]
Inventory Service
- Add Inventory When Create Product [Shop]
Comment Service(Nesting Comments)
- Create Comment[Shop|User]
- Delete Comment[Shop|User]
- Get Comment[Shop|User]
User Service
- User Registration With Verify Email[User]
Other
- Handle Error / Handle Response
- Handle Routeing
- Connect MongoDB and tracking connection
git clone https://github.com/huyhoang0205/Ecommerce_Express
cd Ecommerce_Express
Khởi tạo các tool bằng docker như sau:
docker compose -f docker/docker-compose up -d
Hoặc chạy các tool trực tiếp trên máy(server) và tạo file .env tại thư mục gốc và copy nội dung từ .env.example:
NODE_ENV=dev
DEV_DB_NAME=your_name_app
DEV_DB_HOST=your_mongodb_connection_host
DEV_DB_PORT=your_mongodb_connection_port
DEV_APP_PORT=your_app_port
EMAIL_USER=your_email_using_nodemail
EMAIL_PASS=google_app_password
REDIS_HOST=your_redis_connection_host
REDIS_PORT=your_redis_connection_port
# Cài đặt dependencies
npm install
# Chạy ở chế độ phát triển
npm run start
or node --watch server.js
Dự án đã được cấu hình Docker Compose để bạn có thể khởi chạy toàn bộ môi trường (Node.js, MongoDB, Redis) một cách nhanh chóng.
- Đã cài đặt Docker Desktop
- chỉnh sửa các biến môi trường trong file docker-compose
environment:
- NODE_ENV=dev
- DEV_DB_NAME=shopDEV
- DEV_DB_HOST=mongodb
- DEV_DB_PORT=27017
- DEV_APP_PORT=3000
- EMAIL_USER=${your_edit}
- EMAIL_PASS=${your_edit}
- REDIS_HOST=redis-server
- REDIS_PORT=6379
-
Chạy lệnh sau tại thư mục gốc:
docker-compose up -d
src/
├── auths/ # Auth
├── config/ # Cấu hình DB, Redis, NodeMail
├── constant/ # Cấu hình DB, Redis, NodeMail
├── controllers/ # Xử lý Request và gửi Response
├── cores/ # Responese code và Error code
├── dbs/ # Kết nối DB, Redis, NodeMail
├── helpers/ # Helper functions
├── middlewares/ # Xử lý Role based control access
├── models/ # Mongoose Schemas (User, Product, Order)
├── public/ # HTML Email Xác thực, Email cung cấp mật khẩu
├── routes/ # Định nghĩa các API endpoints
├── services/ # Logic nghiệp vụ (Gửi mail, thanh toán)
└── utils/ # Helper functions
Sau khi khởi chạy ứng dụng, bạn có thể truy cập tài liệu API đầy đủ (Swagger) tại:
URL: http://${host}$:${port}/api-docs
Contact: Nguyễn Đình Huy Hoàng - [ndhhoang.02052002@gmail.com]