A production-ready, scalable E-Commerce backend built with NestJS, GraphQL (Mercurius), and Fastify. This API is designed to handle complex business logic including role-based access control, inventory management, audit logging, and payment processing.
🔗 Live Demo (GraphQL Playground): https://enterprise-ecommerce-api.onrender.com/graphiql
- 🛡️ Authentication & Security:
- JWT-based Authentication (Access & Refresh Tokens).
- Role-Based Access Control (RBAC) with
USERandADMINroles. - Argon2 password hashing.
- Throttling & Rate Limiting to prevent abuse.
- 📦 Catalog Management:
- Create, update, and delete products and categories.
- Inventory tracking with atomic stock decrements.
- Rich media support (Image uploads via Cloudinary).
- 🛒 Shopping Experience:
- Persistent Shopping Cart (Redis/Database backed).
- Coupon & Promotion system (Percentage discounts, Expiry logic).
- Order lifecycle management (Pending -> Paid -> Shipped).
- 💳 Payments:
- Stripe Integration for secure checkout.
- Webhook handling for payment confirmation.
- 🔍 Observability:
- Audit Logging: Tracks high-risk actions (e.g., Price changes, Coupon creation) with "Who, What, When".
- Structured Logging with Pino.
| Component | Technology | Description |
|---|---|---|
| Framework | NestJS | Modular, scalable Node.js framework. |
| Language | TypeScript | Strictly typed for reliability. |
| API Layer | GraphQL (Mercurius) | Efficient data fetching with generated types. |
| Server | Fastify | High-performance underlying HTTP server. |
| Database | MySQL (TiDB Cloud) | Serverless, distributed SQL database. |
| ORM | TypeORM | Data mapping and migration management. |
| Caching/Queues | Redis | Session storage and background jobs. |
| File Storage | Cloudinary | CDN for product images. |
| Deployment | Docker & Render | Containerized CI/CD pipeline. |
The API is self-documenting via the GraphQL Playground.
Endpoint: POST /graphql
query GetProducts {
products {
id
name
price
stock
category {
name
}
images {
url
isPrimary
}
}
}mutation Login {
login(loginInput: {
email: "admin@example.com",
password: "password123"
}) {
accessToken
user {
id
role
}
}
}This project is configured for seamless deployment on Render.com.