FlashCart is a backend system designed for limited edition product drops. It handles high traffic, real time inventory and safe checkout using Redis.
The project demonstrates real world backend concepts such as:
- Redis caching
- MongoDB persistence
- JWT authentication
- Role based access (Admin/User)
- Dockerized microservices
- Node.js
- Express.js
- TypeScript
- MongoDB
- Redis
- JWT Authentication
- Docker & Docker Compose
flash-cart/
├── src/
│ ├── controllers/
│ ├── routes/
│ ├── models/
│ ├── middlewares/
│ ├── config/
│ ├── types/
│ ├── app.ts
│ └── server.ts
├── docker-compose.yml
├── Dockerfile
├── tsconfig.json
├── package.json
└── README.md
git clone https://github.com/km-saifullah/flash-cart.git
cd flash-cartnpm installCreate a .env file:
PORT=5000
MONGO_URI=mongodb://localhost:27017/flashcart
REDIS_URL=redis://localhost:6379
JWT_SECRET=flashcart_secret# MongoDB
mongod
# Redis
redis-servernpm run devAPI runs at:
http://localhost:5000
docker-compose up --buildServices:
- API → Node.js
- MongoDB → Database
- Redis → Cache & inventory
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/signup | Register new user |
| POST | /api/v1/auth/login | Login User |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/products | Get all products |
| GET | /api/v1/products/:id | Get product by ID (Redis first) |
| POST | /api/v1/products | Admin only: create product |
| GET | /api/v1/products/trending | Top 3 most viewed products |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/sales/start/:id | Push stock from Mongo to Redis |
| GET | /api/v1/sales/stock/:id | Get real time stock |
| POST | /api/v1/sales/reserve/:id | Reserve stock using Redis |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/orders | Create order after reservation |
| GET | /api/v1/orders | View user orders |
| DELETE | /api/v1/orders/:id | Cancel order & restore stock |
-
Admin creates product → stored in MongoDB
-
Admin starts sale → stock pushed to Redis
-
Users reserve stock
-
Successful reservation → order saved in MongoDB
-
Cancel order → Redis stock increment + Mongo update
-
Product views tracked → Redis Sorted Set
- JWT authentication
- Role‑based authorization
- Redis atomic inventory handling
- Admin only protected routes
This project is licensed under the MIT License
FlashCart demonstrates how to design a scalable, production ready backend capable of handling flash sales with high concurrency, real time inventory and safe checkout.
Happy Coding!
