A comprehensive e-commerce platform built with Java 25, Spring Boot 4, and React (Vite). Features event-driven microservices, Saga choreography, and modern frontend aesthetics.
- Key Features
- Architecture Overview
- Services Overview
- Design Patterns
- Technology Stack
- Database Schema
- API Documentation
- How to Run (Docker Only)
- Credentials & Testing
- Development Guidelines
- Production Deployment
- Full E-Commerce Flow: Browse products, add to cart, checkout, and payment.
- Admin Dashboard: Manage products (Add/Edit/Delete) with image upload (Cloudinary).
- Authentication: Keycloak OAuth 2.0 / OpenID Connect with Role-Based Access Control (Admin/User).
- Payment Integration: Razorpay integration for secure payments.
- Event-Driven: Order placement triggers payment and notification events via Kafka.
- Resilience: Circuit breakers, retries, and dead-letter topics (DLT).
- Real-time Updates: Kafka-based event streaming for order status.
- Image Management: Cloudinary integration for product images.
- Responsive Design: Mobile-first design with Tailwind CSS.
- Search & Filtering: Product search and category-based filtering.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Frontend │ │ API Gateway │ │ Keycloak │
│ (React) │◄──►│ (Spring │◄──►│ (OAuth 2.0) │
│ Port: 5173 │ │ Cloud) │ │ Port: 8080 │
└─────────────────┘ │ Port: 8095 │ └─────────────────┘
└─────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ Service Mesh │
│ │
┌─────────────┬─────────────┬─────────────┐
│Product │Order │Payment │
│Service │Service │Service │
│:8090 │:8097 │:8098 │
└─────────────┴─────────────┴─────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ Infrastructure & Data Layer │
│ │
┌─────────────┬─────────────┬─────────────┐
│PostgreSQL │MongoDB │Kafka │
│(Orders) │(Products) │(Events) │
│:5432 │:27017 │:9092 │
└─────────────┴─────────────┴─────────────┘
- Order Initiated → Order Service creates order with PENDING status
- Payment Processed → Payment Service attempts Razorpay payment
- Payment Success → Order Service updates status to CONFIRMED
- Inventory Updated → Product Service updates stock levels
- Notification Sent → Notification Service sends confirmation
- Failure Handling → DLT Replay Service handles failed events
| Service | Port | Description | Key Responsibilities |
| :--- | :--- |:--- |
| Frontend | 5173 | React + TypeScript UI with Tailwind CSS. Product browsing, cart, checkout, user management. |
| API Gateway | 8095 | Central entry point, routing, rate limiting, JWT validation, load balancing. |
| Auth Service | 8096 | Keycloak proxy for login/signup (facade pattern). User authentication and token management. |
| Product Service | 8090 | Product management, inventory tracking, image upload to Cloudinary. |
| Order Service | 8097 | Order lifecycle, Saga orchestration, status management. |
| Payment Service | 8098 | Payment processing (Razorpay), transaction logging. |
| Notification Service | 8099 | Email/SMS notifications (simulated), event-driven updates. |
| DLT Replay Admin | 8088 | Admin tool for replaying failed events, system monitoring. |
- Order Management Saga: Coordinates distributed transaction across services
- Compensation Actions: Automatic rollback on payment failures
- State Management: Order status tracking through lifecycle
- Single Entry Point: All client requests go through gateway
- Cross-Cutting Concerns: Authentication, rate limiting, logging
- Service Discovery: Dynamic routing to microservices
- Kafka Topics:
order-events: Order lifecycle eventspayment-events: Payment processing eventsnotification-events: Customer notifications
- Event Sourcing: Audit trail through event logs
- Command Query Separation: Write operations (commands) vs read operations (queries)
- Eventual Consistency: Synchronized state through events
- Java 25: Latest LTS with modern features
- Spring Boot 4: Auto-configuration, production-ready defaults
- Spring Cloud Gateway: API gateway with filters and routing
- Spring Data JPA: Database abstraction layer
- Spring Kafka: Event streaming and messaging
- React 18: Modern hooks and concurrent features
- TypeScript: Type safety and better IDE support
- Vite: Fast development server and optimized builds
- Tailwind CSS: Utility-first CSS framework
- Keycloak 22: OAuth 2.0/OpenID Connect server
- JWT Tokens: Stateless authentication
- Role-Based Access: ADMIN vs USER permissions
- Docker: Containerization and orchestration
- Docker Compose: Multi-container deployment
- PostgreSQL: Primary relational database (orders, users)
- MongoDB: Document database (products, catalogs)
- Redis: Caching and session storage
- Kafka: Event streaming and message queue
- Zookeeper: Kafka cluster coordination
- Cloudinary: Cloud image storage and CDN
- Razorpay: Indian payment gateway integration
- Circuit Breaker: Resilience4j for fault tolerance
-- Users table (simplified)
CREATE TABLE users (
id VARCHAR(255) PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255),
role VARCHAR(50) DEFAULT 'USER',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Orders table
CREATE TABLE orders (
id VARCHAR(255) PRIMARY KEY,
user_id VARCHAR(255) NOT NULL,
total_amount DECIMAL(10,2) NOT NULL,
status VARCHAR(50) DEFAULT 'PENDING',
items JSONB,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);// Products collection
{
_id: ObjectId,
name: String,
description: String,
price: Number,
category: String,
stock: Number,
image_url: String, // Cloudinary URL
created_at: Date,
updated_at: Date
}
// Categories collection
{
_id: ObjectId,
name: String,
description: String,
created_at: Date
}GET /products/* → Product Service
GET /categories/* → Product Service
POST /api/orders/* → Order Service
POST /api/payments/* → Payment Service
GET /admin/dlt/* → DLT Replay Service
- Login:
POST /auth/login→ JWT token + refresh token - Register:
POST /auth/register→ User creation with default USER role - Token Refresh: Automatic background refresh
- Logout: Token invalidation and Keycloak logout
GET /products → List all products
POST /products → Create new product
PUT /products/{id} → Update product
DELETE /products/{id} → Delete product
POST /products/{id}/image → Upload product image
Prerequisites: Docker and Docker Compose installed.
git clone <repository-url>
cd micro-e-com
docker-compose up --buildUpdate environment files with your credentials:
product-service/.env: Cloudinary API credentialspayment-service/.env: Razorpay API keysfrontend/.env: External service URLs
# Start infrastructure only
docker-compose up postgres kafka redis mongo keycloak
# Start specific service
docker-compose up product-service --build
# View logs
docker-compose logs -f product-service- Frontend: http://localhost:5173
- API Gateway: http://localhost:8095
- Keycloak Admin: http://localhost:8080
- URL: http://localhost:8080
- Username:
admin - Password:
admin - Purpose: Manage users, roles, and OAuth clients
- Setup Guide: See KEYCLOAK_SETUP.md for complete configuration
- URL: http://localhost:5173/login
- Username:
admin1 - Password:
admin123 - Capabilities: Access Admin Dashboard, Add/Edit/Delete Products.
- Note: User must be created in Keycloak with ADMIN role (see setup guide)
- Sign Up: http://localhost:5173/signup
- Login: Use your created credentials.
- Capabilities: Browse products, Add to Cart, Checkout.
- Note: New users are automatically assigned USER role in Keycloak
- Admin:
admin1/admin123 - User:
santosh@yopmail.com/Password#123
micro-e-com/
├── api-gateway/ # Spring Cloud Gateway
├── auth-microservice/ # Authentication facade
├── product-service/ # Product catalog management
├── order-service/ # Order processing & sagas
├── payment-service/ # Razorpay integration
├── notification-service/ # Event-driven notifications
├── dlt-replay-service/ # Failed event handling
├── frontend/ # React + TypeScript UI
└── KEYCLOAK_SETUP.md # Authentication setup guide
Each service uses environment-specific configuration:
- Development:
.envfiles in service directories - Production: Docker environment variables
- Secrets: Never commit to version control
- Unit Tests: Service layer testing with JUnit
- Integration Tests: API testing with TestContainers
- E2E Tests: Frontend user flow testing
- Load Testing: Kafka event throughput testing
# docker-compose.prod.yml
version: '3.8'
services:
frontend:
environment:
- NODE_ENV=production
deploy:
replicas: 3
api-gateway:
environment:
- SPRING_PROFILES_ACTIVE=prod
deploy:
replicas: 2- Health Checks:
/actuator/healthendpoints - Metrics: Prometheus integration via Actuator
- Logging: Structured JSON logging
- Tracing: Distributed tracing with Spring Cloud Sleuth
- Stateless Services: All services designed for horizontal scaling
- Database Pooling: Connection pooling for high throughput
- Kafka Partitions: Event distribution across instances
- Redis Clustering: Session replication
Note: This project demonstrates a production-ready architecture. Ensure your .env files are correctly populated for full functionality.
- Admin:
admin1/admin123 - User:
santosh@yopmail.com/Password#123
This project is licensed under the MIT License © 2026 Aaditya B Chatterjee
- order history (with delivery status, pagination) & status updation by admin
- products display by category
- user profile image upload & mobile number update
- wishlist
- ratings & feedback
- cancellation & refund