Amazon Clone β Distributed E-Commerce Platform
A production-grade distributed e-commerce platform built with Java 21 and Spring Boot, implementing microservices architecture with event-driven communication.
ββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway β
β (Spring Cloud Gateway :8080) β
β JWT Auth β Circuit Breaker β Rate Limitβ
ββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βββββββββββββββββββ¬βββββββββββ΄βββββββββββ¬βββββββββββββββββ
β β β β
βββββββββΌβββββββ βββββββββΌβββββββ ββββββββββββΌββββ ββββββββββΌβββββββ
β User Service β βProduct Serviceβ β Order Serviceβ βPayment Serviceβ
β :8081 β β :8082 β β :8083 β β :8084 β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬βββββββ ββββββββββ¬βββββββ
β β β β
βββββββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββ
β
ββββββββββββββββββ¬βββββββββββββ΄βββββββββββββ¬βββββββββββββββββ
β β β β
βββββββββΌβββββββ ββββββββΌβββββββββ ββββββββββββββΌβββ βββββββββββΌβββββββ
β Inventory β βNotification β β Search β βService Registryβ
β Service β β Service β β Service β β (Eureka) β
β :8085 β β :8086 β β :8087 β β :8761 β
ββββββββββββββββ βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β
βββββββββββββββββββ¬βββββββββββ΄βββββββββββ¬βββββββββββββββββ
β β β β
ββββββββΌβββββββ ββββββββΌβββββββ βββββββββββΌβββ ββββββββββΌβββββββ
β PostgreSQL β β Redis β β Kafka β βElasticsearch β
β (6 DBs) β β Cache β β (Events) β β (Search) β
βββββββββββββββ βββββββββββββββ ββββββββββββββ βββββββββββββββββ
Service
Port
Description
Service Registry
8761
Eureka service discovery
Config Server
8888
Centralized configuration
API Gateway
8080
Entry point β auth, routing, LB
User Service
8081
Auth, JWT, user profiles, addresses
Product Service
8082
Catalog, categories, reviews, images
Order Service
8083
Orders, cart (Redis), checkout
Payment Service
8084
Payments, refunds, webhooks
Inventory Service
8085
Stock management, reservations
Notification Service
8086
Email via Kafka consumers
Search Service
8087
Elasticsearch full-text search
Technology
Usage
Java 21
Virtual threads, records, sealed classes
Spring Boot 3.2
Core framework
Spring Security
JWT authentication, method-level auth
Spring Data JPA
Hibernate ORM + PostgreSQL
Spring Cloud Gateway
API Gateway with circuit breakers
Eureka
Service discovery and registration
Redis
Cart storage, caching
Apache Kafka
Event-driven async communication
RabbitMQ
Message queuing
Elasticsearch
Full-text product search
Docker
Containerization
Kubernetes
Orchestration + HPA autoscaling
AWS EKS
Cloud deployment
Jenkins
CI/CD pipeline
GitHub Actions
CI/CD pipeline (alternative)
Prometheus
Metrics collection
Grafana
Metrics dashboards
Flyway
Database migrations
JUnit 5 + Mockito
Testing
Docker Desktop
Java 21
Maven 3.9+
git clone https://github.com/your-org/amazon-clone.git
cd amazon-clone
# Start all infrastructure
docker-compose up -d postgres redis kafka zookeeper rabbitmq elasticsearch prometheus grafana
# Wait for infrastructure to be ready (~30 seconds), then start services
docker-compose up -d
# View running services
docker-compose ps
Run Locally (Development)
# 1. Start infrastructure only
docker-compose up -d postgres redis kafka zookeeper rabbitmq elasticsearch
# 2. Build all services
mvn clean install -DskipTests
# 3. Start services in order
java -jar service-registry/target/* .jar &
sleep 10
java -jar config-server/target/* .jar &
sleep 5
java -jar api-gateway/target/* .jar &
java -jar user-service/target/* .jar &
java -jar product-service/target/* .jar &
java -jar order-service/target/* .jar &
java -jar payment-service/target/* .jar &
java -jar inventory-service/target/* .jar &
java -jar notification-service/target/* .jar &
java -jar search-service/target/* .jar &
POST /api/v1/auth/register
POST /api/v1/auth/login
POST /api/v1/auth/refresh
POST /api/v1/auth/logout
GET /api/v1/users/me
GET /api/v1/users/{id}
PUT /api/v1/users/{id}
PATCH /api/v1/users/{id}/password
POST /api/v1/users/{id}/addresses
GET /api/v1/users/{id}/addresses
DELETE /api/v1/users/{id}/addresses/{addressId}
GET /api/v1/products
GET /api/v1/products/{id}
POST /api/v1/products (SELLER/ADMIN)
PUT /api/v1/products/{id} (SELLER/ADMIN)
DELETE /api/v1/products/{id} (SELLER/ADMIN)
GET /api/v1/products/search?keyword=
GET /api/v1/products/filter?categoryId=&minPrice=&maxPrice=&brand=
GET /api/v1/products/featured
GET /api/v1/products/{id}/reviews
POST /api/v1/products/{id}/reviews
GET /api/v1/categories
POST /api/v1/categories (ADMIN)
POST /api/v1/cart/items
GET /api/v1/cart
PUT /api/v1/cart/items/{productId}
DELETE /api/v1/cart/items/{productId}
DELETE /api/v1/cart
POST /api/v1/orders
GET /api/v1/orders/my
GET /api/v1/orders/{id}
POST /api/v1/orders/{id}/cancel
PATCH /api/v1/orders/{id}/status (ADMIN)
POST /api/v1/payments
GET /api/v1/payments/my
GET /api/v1/payments/{id}
GET /api/v1/payments/order/{orderNumber}
POST /api/v1/payments/{id}/refund
POST /api/v1/payments/webhook
POST /api/v1/inventory
GET /api/v1/inventory/product/{productId}
PUT /api/v1/inventory/product/{productId}/stock
GET /api/v1/inventory/low-stock
POST /api/v1/inventory/check
POST /api/v1/inventory/reserve
POST /api/v1/inventory/release
GET /api/v1/search?q=laptop&categoryId=1&minPrice=100&maxPrice=2000&sortBy=price
GET /api/v1/search/suggest?q=lap
GET /api/v1/search/category/{categoryId}
Topic
Producer
Consumer(s)
user-registered
User Service
Notification Service
user-updated
User Service
β
product-events
Product Service
Search Service, Notification Service
order-events
Order Service
Notification Service
payment-events
Payment Service
Notification Service
payment-order-events
Payment Service
Order Service
inventory-alerts
Inventory Service
Notification Service
# All tests
mvn test
# Single service
mvn test -pl user-service
# With coverage
mvn test jacoco:report -pl user-service
open user-service/target/site/jacoco/index.html
# Create namespace and secrets
kubectl apply -f k8s/namespace.yml
kubectl apply -f k8s/secrets.yml
# Deploy infrastructure
kubectl apply -f k8s/infrastructure.yml
# Deploy services
kubectl apply -f k8s/services.yml
# Check status
kubectl get pods -n amazon-clone
kubectl get services -n amazon-clone
# Scale a service
kubectl scale deployment product-service --replicas=3 -n amazon-clone
amazon-clone/
βββ pom.xml # Parent POM
βββ docker-compose.yml # Local development
βββ Jenkinsfile # Jenkins CI/CD
βββ .github/workflows/ci-cd.yml # GitHub Actions CI/CD
βββ service-registry/ # Eureka Server
βββ config-server/ # Spring Cloud Config
βββ api-gateway/ # Spring Cloud Gateway
βββ user-service/ # Users + Auth + JWT
βββ product-service/ # Products + Categories + Reviews
βββ order-service/ # Orders + Cart
βββ payment-service/ # Payments + Refunds
βββ inventory-service/ # Stock + Reservations
βββ notification-service/ # Email via Kafka
βββ search-service/ # Elasticsearch
βββ k8s/ # Kubernetes manifests
βββ monitoring/ # Prometheus + Grafana
βββ docker/ # Shared Dockerfiles