A production-inspired E-Commerce Backend built using Java 21, Spring Boot, and a Microservices Architecture. This project demonstrates how modern distributed systems are designed by combining secure authentication, scalable communication, fault tolerance, and event-driven architecture.
The application follows industry-standard backend practices such as API Gateway, Service Discovery, OAuth2 authentication with Keycloak, Circuit Breakers, asynchronous messaging, distributed caching, and containerized deployment.
This project was built to gain hands-on experience with enterprise backend architecture and demonstrate real-world Java backend engineering skills.
- Microservices Architecture
- API Gateway
- Service Discovery (Eureka)
- OAuth2 Authentication & JWT Authorization
- Role-Based Access Control (RBAC)
- Product Catalog Management
- Shopping Cart
- Secure Checkout
- Order Management
- Stock Reservation & Validation
- Distributed Caching using Redis
- Asynchronous Messaging using RabbitMQ
- Fault Tolerance using Resilience4j
- Dockerized Deployment
- PostgreSQL Database
- Centralized Configuration
- RESTful APIs
Acts as the single entry point for all client requests.
Responsibilities:
- Request Routing
- JWT Validation
- Authentication
- Authorization
- Load Balancing
- Security
Provides service discovery allowing microservices to communicate dynamically without hardcoding URLs.
Responsible for:
- User Information
- Customer Profile
- User APIs
Authentication is handled by Keycloak, while user-related business data is managed here.
Responsible for:
- Product CRUD
- Categories
- Inventory
- Stock Management
Provides APIs for stock validation and reservation during checkout.
Responsible for:
- Add to Cart
- Update Quantity
- Remove Product
- View Cart
When a user adds an item:
- Product availability is checked.
- Stock availability is verified.
- Invalid products cannot be added.
During Checkout:
- Cart is revalidated.
- Out-of-stock products are automatically removed.
- User receives updated cart before placing the order.
Responsible for:
- Order Creation
- Order History
- Order Status
Checkout Flow:
- Fetch authenticated user.
- Retrieve cart items.
- Validate latest inventory.
- Reserve stock.
- Create order.
- Save order.
- Publish order event.
Authentication is implemented using Keycloak.
Every request follows this flow:
Client
│
▼
API Gateway
│
JWT Validation
│
Route Request
│
Target Microservice
Each microservice is configured as an OAuth2 Resource Server and independently validates JWT tokens.
No service trusts client-provided user IDs.
Implemented using Resilience4j.
Patterns used:
- Circuit Breaker
- Retry
- Timeout
- Fallback Methods
Example:
Order Service
│
▼
Product Service
If Product Service becomes unavailable:
Circuit Breaker Opens
↓
Fallback Response
↓
System remains responsive
RabbitMQ is used for event-driven communication between services.
Benefits:
- Loose Coupling
- Better Scalability
- Reliable Event Processing
- Improved Performance
Example flow:
Order Created
│
▼
RabbitMQ
│
▼
Interested Services Consume Event
Redis is used to improve application performance through distributed caching.
Benefits:
- Faster Read Operations
- Reduced Database Load
- Improved Response Time
Every microservice is containerized.
Services can be started together using Docker Compose.
Example components:
- API Gateway
- Eureka Server
- User Service
- Product Service
- Cart Service
- Order Service
- PostgreSQL
- Redis
- RabbitMQ
- Keycloak
- Java 21
- Spring Boot
- Spring MVC
- Spring Cloud Gateway
- Eureka Discovery
- Spring Security
- OAuth2 Resource Server
- JWT
- Keycloak
- PostgreSQL
- RabbitMQ
- Redis
- Resilience4j
- Maven
- Docker
- Docker Compose
E-Commerce-Microservice
│
├── api-gateway
├── eureka-server
├── user-service
├── product-service
├── cart-service
├── order-service
│
├── docker-compose.yml
└── README.md
Client
│
▼
API Gateway
│
▼
Order Service
│
├────────► User Service
│
├────────► Cart Service
│
├────────► Product Service
│ │
│ └── Reserve Stock
│
▼
Save Order
│
Publish Event
│
RabbitMQ
This project was built to gain practical experience with:
- Microservices Architecture
- Distributed Systems
- API Gateway
- Service Discovery
- JWT Authentication
- OAuth2
- Keycloak
- Event-Driven Architecture
- RabbitMQ
- Redis
- Resilience4j
- Docker
- Production-style Backend Design
- Kubernetes Deployment
- Distributed Tracing (Zipkin/OpenTelemetry)
- Centralized Logging (ELK Stack)
- API Rate Limiting
- Payment Service Integration
- Notification Service
- Distributed Transactions (Saga Pattern)
- Monitoring with Prometheus & Grafana
- CI/CD Pipeline using GitHub Actions or Jenkins
Suraj Mondal
Backend Developer | Java | Spring Boot | Microservices | Distributed Systems
GitHub: https://github.com/Surajhub21