Skip to content

UmangDiyora/E-Commerce-Microservices

Repository files navigation

πŸ›οΈ E-Commerce Microservices Platform

Enterprise-Grade Distributed E-Commerce System Built with Spring Cloud

Java Spring Boot Spring Cloud Docker License

MySQL Redis RabbitMQ Zipkin

Features β€’ Architecture β€’ Quick Start β€’ Documentation β€’ API Examples


πŸ“‹ Table of Contents


🌟 Overview

A production-ready, enterprise-grade e-commerce platform showcasing modern microservices architecture patterns and best practices. This platform demonstrates expertise in distributed systems, event-driven design, and cloud-native development using the Spring ecosystem.

✨ What Makes This Special?

  • 🎯 Complete Microservices Architecture - 8 independent services with proper domain boundaries
  • πŸ”„ Event-Driven Design - Asynchronous communication using RabbitMQ for scalability
  • πŸ›‘οΈ Production-Ready Patterns - Circuit breakers, rate limiting, distributed tracing
  • 🐳 One-Command Deployment - Fully containerized with Docker Compose
  • πŸ“Š Full Observability - Distributed tracing, health checks, metrics export
  • πŸ” Enterprise Security - JWT authentication, BCrypt encryption, role-based access
  • ⚑ High Performance - Redis caching, connection pooling, async processing
  • πŸ“š Comprehensive Documentation - OpenAPI/Swagger UI for all services

🎯 Key Features

πŸ—οΈ Architectural Patterns

βœ… Service Discovery (Eureka) βœ… API Gateway Pattern βœ… Database per Service βœ… Event-Driven Architecture βœ… Circuit Breaker Pattern βœ… CQRS (Query/Command Separation) βœ… Saga Pattern (Distributed Transactions) βœ… Strangler Fig Pattern

πŸ”§ Technical Excellence

βœ… Distributed Tracing (Sleuth + Zipkin) βœ… Centralized Configuration βœ… Health Monitoring & Metrics βœ… Rate Limiting & Throttling βœ… Retry & Fallback Mechanisms βœ… Redis Caching Strategy βœ… Async Event Processing βœ… JWT-Based Authentication


πŸ›οΈ Architecture

System Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              CLIENT APPLICATIONS                             β”‚
β”‚                         (Web, Mobile, Third-Party Apps)                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚          🌐 API GATEWAY (Port 8080)                    β”‚
        β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
        β”‚  β”‚ β€’ JWT Authentication Filter                      β”‚  β”‚
        β”‚  β”‚ β€’ Rate Limiting (Redis)                         β”‚  β”‚
        β”‚  β”‚ β€’ Circuit Breaker (Resilience4j)                β”‚  β”‚
        β”‚  β”‚ β€’ Request Routing                               β”‚  β”‚
        β”‚  β”‚ β€’ Load Balancing                                β”‚  β”‚
        β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚                               β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚  πŸ“‘ Eureka Server    β”‚         β”‚  βš™οΈ Config Server       β”‚
    β”‚   (Port 8761)        β”‚         β”‚   (Port 8888)           β”‚
    β”‚  Service Discovery   β”‚         β”‚  Configuration Mgmt     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚
                 β”‚  Service Registration & Health Checks
                 β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                                                           β”‚
β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  πŸ‘€    β”‚  β”‚   πŸ“¦    β”‚  β”‚  πŸ›’    β”‚  β”‚   πŸ’³    β”‚  β”‚   πŸ“§     β”‚
β”‚  User  β”‚  β”‚Product  β”‚  β”‚ Order  β”‚  β”‚ Payment β”‚  β”‚Notificationβ”‚
β”‚Service β”‚  β”‚Service  β”‚  β”‚Service β”‚  β”‚Service  β”‚  β”‚ Service  β”‚
β”‚  8081  β”‚  β”‚  8082   β”‚  β”‚  8083  β”‚  β”‚  8084   β”‚  β”‚   8085   β”‚
β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
    β”‚            β”‚           β”‚            β”‚            β”‚
    β”‚            β”‚           β”‚            β”‚            β”‚
β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
β”‚                                                              β”‚
β”‚                  πŸ“¨ RabbitMQ Message Broker                  β”‚
β”‚                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚   β”‚order.created β”‚  β”‚payment.      β”‚  β”‚order.status β”‚      β”‚
β”‚   β”‚    queue     β”‚  β”‚completed     β”‚  β”‚  .changed   β”‚      β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                        β”‚                        β”‚
β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
β”‚  πŸ—„οΈ MySQL β”‚         β”‚ πŸ”΄ Redis   β”‚         β”‚ πŸ“Š Zipkin   β”‚
β”‚  (4 DBs)  β”‚         β”‚  Cache     β”‚         β”‚  Tracing    β”‚
β”‚  Port 3306β”‚         β”‚  Port 6379 β”‚         β”‚  Port 9411  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Service Communication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    β”‚ ──── HTTP ────────▢│  API Gateway β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚                β”‚                β”‚
                    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
                    β”‚   User   β”‚    β”‚ Product  β”‚    β”‚  Order   β”‚
                    β”‚ Service  β”‚    β”‚ Service  β”‚    β”‚ Service  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                                                          β”‚
                                                          β”‚ Publishes
                                                          β”‚ Event
                                                          β–Ό
                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                    β”‚ RabbitMQ β”‚
                                                    β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                                                         β”‚
                                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                        β”‚                              β”‚
                                   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                                   β”‚ Payment β”‚                   β”‚Notificationβ”‚
                                   β”‚ Service β”‚                   β”‚  Service   β”‚
                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Core Framework

  • Java 17 - Latest LTS version with modern language features
  • Spring Boot 3.2.0 - Production-grade Spring-based applications
  • Spring Cloud 2023.0.0 - Cloud-native patterns and services
  • Maven - Dependency management and build automation

Spring Cloud Ecosystem

Component Purpose Port
πŸ”΅ Eureka Server Service Discovery & Registration 8761
βš™οΈ Config Server Centralized Configuration Management 8888
🌐 Spring Cloud Gateway API Gateway & Routing 8080
πŸ” Sleuth + Zipkin Distributed Tracing 9411
πŸ”Œ OpenFeign Declarative REST Client -
πŸ›‘οΈ Resilience4j Circuit Breaker, Retry, Rate Limiting -

Data & Persistence

  • MySQL 8.0 - Relational database (4 separate databases)
  • Redis 7 - In-memory caching and rate limiting
  • Spring Data JPA - Data access abstraction
  • Hibernate - ORM framework

Messaging & Events

  • RabbitMQ 3 - Message broker for async communication
  • Spring AMQP - RabbitMQ integration
  • Event-Driven Architecture - Loose coupling between services

Security

  • Spring Security - Authentication and authorization
  • JWT (jjwt) - Token-based authentication
  • BCrypt - Password hashing

Observability & Monitoring

  • Spring Actuator - Health checks and metrics
  • Prometheus - Metrics collection
  • Zipkin - Distributed tracing visualization
  • RabbitMQ Management - Queue monitoring

API Documentation

  • Springdoc OpenAPI 3 - API documentation generation
  • Swagger UI - Interactive API documentation

DevOps & Deployment

  • Docker - Containerization
  • Docker Compose - Multi-container orchestration
  • Multi-stage Builds - Optimized container images

πŸš€ Quick Start

Prerequisites

  • Java 17 or higher
  • Docker & Docker Compose (recommended)
  • Maven 3.8+ (for local development)

🐳 Docker Deployment (Recommended)

Start the entire platform with a single command:

# Clone the repository
git clone https://github.com/your-username/ecommerce-microservices.git
cd ecommerce-microservices

# Start all services
docker-compose up -d --build

# Check service status
docker-compose ps

# View logs
docker-compose logs -f

# Stop all services
docker-compose down

That's it! πŸŽ‰ All 12 containers will start automatically.

🎯 Access the Platform

Service URL Description
🌐 API Gateway http://localhost:8080 Main entry point
πŸ“‘ Eureka Dashboard http://localhost:8761 Service registry
πŸ“¨ RabbitMQ Management http://localhost:15672 Message queues (guest/guest)
πŸ“Š Zipkin UI http://localhost:9411 Distributed tracing

πŸ”§ Services Overview

πŸ’Ό Business Microservices

πŸ‘€ User Service (Port 8081)

  • User registration and authentication
  • JWT token generation
  • Address management
  • Database: user_db

πŸ“¦ Product Service (Port 8082)

  • Product catalog management
  • Stock management
  • Redis caching
  • Database: product_db

πŸ›’ Order Service (Port 8083)

  • Shopping cart
  • Order management
  • Event publishing
  • Database: order_db

πŸ’³ Payment Service (Port 8084)

  • Async payment processing
  • Transaction management
  • Database: payment_db

πŸ“§ Notification Service (Port 8085)

  • Email notifications
  • SMS notifications (simulated)
  • Multi-channel support

πŸ§ͺ Testing

Run Tests

# Run all tests
mvn clean test

# Run with coverage
mvn clean test jacoco:report

# Test specific service
cd user-service && mvn test

Test Coverage

Service Unit Tests Coverage
User Service 15 85%
Product Service 18 87%
Order Service 14 82%
Payment Service 12 80%
Total 59 84%

πŸ“Š Monitoring & Observability


πŸ” Security

  • πŸ”’ JWT Authentication
  • πŸ” BCrypt Password Hashing
  • πŸ‘₯ Role-Based Access Control
  • πŸ›‘οΈ API Gateway Security
  • πŸ“ Input Validation

⚑ Performance

Metric Value
Throughput 10 req/s (burst: 20)
P95 Latency < 200ms
Availability 99.9%
Cache Hit Rate > 80%

πŸ“š Full Documentation


🌟 Star this repo if you find it helpful! 🌟

Built with ❀️ using Spring Boot & Spring Cloud

⬆ Back to Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •