A robust e-commerce platform built with Spring Boot microservices architecture, implementing advanced features like API Gateway, Service Discovery, Circuit Breaker pattern, and containerized deployment on AWS.
-
API Gateway Service
- Routes requests to appropriate microservices
- Implements Spring Cloud Gateway
- Port: 9090
-
Config Server
- Centralized configuration management
- Git-based configuration storage
- Port: 9296
-
Service Registry (Eureka)
- Service discovery and registration
- Dynamic service lookup
- Port: 8761
-
Order Service
- Order processing and management
- Order status tracking
- Port: 8082
-
Payment Service
- Payment processing
- Transaction management
- Port: 8083
-
Product Service
- Product catalog management
- Inventory tracking
- Port: 8080
-
Resilience4j Integration
@CircuitBreaker(name = "productService", fallbackMethod = "fallbackMethod") @RateLimiter(name = "productService") @Retry(name = "productService")
-
Spring Cloud LoadBalancer
spring: cloud: loadbalancer: ribbon: enabled: false configurations: default: eager-load: enabled: true
-
Prometheus Monitoring
management: endpoints: web: exposure: include: prometheus metrics: export: prometheus: enabled: true
- Java 17
- Spring Boot 3.x
- Spring Cloud
- MySQL
- MongoDB
- Docker
- Kubernetes
- AWS
- Jenkins
- Prometheus & Grafana
ecommerce-microservices/
├── API-Gateway/
├── Config-Server/
├── Order-Service/
├── Payment-Service/
├── Product-Service/
├── Service-Registry/
├── kubernetes/
│ ├── deployments/
│ ├── services/
│ └── configmaps/
└── jenkins/
└── Jenkinsfile
- JDK 17
- Maven 3.8+
- Docker Desktop
- AWS CLI
- kubectl
- Git
-
Clone the Repository
git clone https://github.com/hemanthsaich/Ecommerce-Microservices.git cd Ecommerce-Microservices
-
Build Services
mvn clean package -DskipTests
-
Start Services in Order
# Start Service Registry first cd Service-Registry mvn spring-boot:run # Start Config Server cd ../Config-Server mvn spring-boot:run # Start other services cd ../Product-Service mvn spring-boot:run
-
Build Docker Images
docker build -t ecommerce/service-registry ./Service-Registry docker build -t ecommerce/config-server ./Config-Server docker build -t ecommerce/api-gateway ./API-Gateway docker build -t ecommerce/product-service ./Product-Service docker build -t ecommerce/order-service ./Order-Service docker build -t ecommerce/payment-service ./Payment-Service
-
Run Containers
docker-compose up -d
-
Create EKS Cluster
eksctl create cluster \ --name ecommerce-cluster \ --region us-east-1 \ --nodegroup-name standard-workers \ --node-type t3.medium \ --nodes 3
-
Apply Kubernetes Configurations
kubectl apply -f kubernetes/configmaps/ kubectl apply -f kubernetes/deployments/ kubectl apply -f kubernetes/services/
-
Add Dependencies
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency>
-
Configure Prometheus
scrape_configs: - job_name: 'ecommerce-microservices' metrics_path: '/actuator/prometheus' static_configs: - targets: ['localhost:8080', 'localhost:8082', 'localhost:8083']
pipeline {
agent any
environment {
DOCKER_REGISTRY = 'your-registry'
KUBE_CONFIG = credentials('eks-config')
}
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Docker Build & Push') {
steps {
script {
docker.build("${DOCKER_REGISTRY}/ecommerce-services")
docker.push()
}
}
}
stage('Deploy to EKS') {
steps {
sh 'kubectl apply -f kubernetes/'
}
}
}
}
- GET
/product/all
- Get all products - POST
/product/create
- Create new product - GET
/product/{id}
- Get product by ID
- POST
/order/create
- Create new order - GET
/order/{id}
- Get order details - PUT
/order/update
- Update order status
- POST
/payment/process
- Process payment - GET
/payment/{orderId}
- Get payment status
POST /product/create
{
"name": "Sample Product",
"price": 99.99,
"quantity": 100
}
resilience4j.circuitbreaker:
instances:
productService:
slidingWindowSize: 10
failureRateThreshold: 50
waitDurationInOpenState: 10000
permittedNumberOfCallsInHalfOpenState: 3
- JWT Authentication
- Service-to-service communication security
- Role-based access control
- AWS security groups configuration