Scalable E-Commerce Platform built with a Distributed Microservices Architecture.
MicroMart is a production-realistic e-commerce backend designed to demonstrate high availability, service decoupling, and resilient distributed state management.
MicroMart follows a Choreography-based SAGA pattern for distributed transactions and uses an API Gateway for centralized request handling.
graph TD
Client[Client App] --> Gateway[API Gateway]
subgraph "Core Services"
Gateway --> AuthSvc[Auth Service]
Gateway --> ProdSvc[Product Service]
Gateway --> OrderSvc[Order Service]
Gateway --> CartSvc[Cart Service]
end
subgraph "Infrastructure"
AuthSvc --> AuthDB[(PostgreSQL)]
ProdSvc --> ProdDB[(MongoDB)]
OrderSvc --> OrderDB[(PostgreSQL)]
CartSvc --> CartDB[(Redis)]
end
subgraph "Message Bus"
OrderSvc <-->|Events| Bus[RabbitMQ / Redis PubSub]
CartSvc <-->|Events| Bus
ProdSvc <-->|Events| Bus
end
Managing a shopping cart across multiple sessions while ensuring eventual consistency with the Product service's inventory. Implemented using Redis for low-latency state and a background worker to sync state to the Order service during checkout.
Implemented a custom API Gateway to handle:
- JWT Authentication: Centralized verification to offload work from downstream services.
- Dynamic Routing: Routing requests based on path and method to the appropriate microservice.
- Rate Limiting: Protecting services from burst traffic.
Each service owns its data store (Polyglot Persistence), ensuring that a failure in the Product DB does not take down the entire checkout flow (provided the Cart is already populated).
- Backend: Node.js, TypeScript, Express
- Database: PostgreSQL (Relational Data), MongoDB (Product Catalog), Redis (Session/Cart)
- Communication: REST APIs, Asynchronous Eventing
- DevOps: Docker, Docker Compose
git clone https://github.com/belikedeep/MicroMart.git
cd MicroMart
npm installdocker-compose up --build- Gateway:
http://localhost:3000 - Auth Service:
http://localhost:3001 - Product Service:
http://localhost:3002
- Observability: Structured logging per service for easier debugging in distributed traces.
- Resilience: Circuit breakers implemented at the Gateway level to prevent cascading failures.
- Scalability: Stateless services allow for horizontal scaling via Kubernetes or ECS.
MIT - See LICENSE for details.