Skip to content

belikedeep/MicroMart

Repository files navigation

🛒 MicroMart

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.


🏗 Architecture Overview

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
Loading

🚀 Key Engineering Challenges Solved

1. Distributed State Synchronization

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.

2. API Gateway Pattern

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.

3. Service Decoupling

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).


💻 Tech Stack

  • Backend: Node.js, TypeScript, Express
  • Database: PostgreSQL (Relational Data), MongoDB (Product Catalog), Redis (Session/Cart)
  • Communication: REST APIs, Asynchronous Eventing
  • DevOps: Docker, Docker Compose

🛠️ Setup & Development

1. Clone & Install

git clone https://github.com/belikedeep/MicroMart.git
cd MicroMart
npm install

2. Run with Docker

docker-compose up --build

3. Access

  • Gateway: http://localhost:3000
  • Auth Service: http://localhost:3001
  • Product Service: http://localhost:3002

🎯 Production Considerations

  • 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.

⚖️ License

MIT - See LICENSE for details.

About

Scalable e-commerce platform built with a distributed microservices architecture using Node.js and TypeScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages