A production-grade full-stack e-commerce platform built using Spring Boot microservices with API Gateway, Eureka service discovery, Kafka event-driven communication, Saga pattern for distributed transactions, Redis caching, Elasticsearch search, and Razorpay payment integration.
This diagram represents the complete microservices ecosystem including:
- API Gateway for routing
- Eureka for service discovery
- Kafka for asynchronous event communication
- Redis for cart storage & idempotency
- Elasticsearch for search functionality
- Separate database per service
- Razorpay external payment integration
The frontend application provides:
- Product browsing
- Search functionality
- Cart management
- Checkout flow
- Order history
- User authentication
The frontend communicates with backend services through the API Gateway.
- product-service – Manages product catalog.
- search-service – Handles search functionality using Elasticsearch.
- cart-service – Stores cart data in Redis (key-value store).
- checkout-service – Manages checkout session & idempotency.
- order-service – Handles order lifecycle & acts as Saga Orchestrator.
- inventory-service – Manages stock reservation & release.
- payment-service – Integrates with Razorpay and manages payments.
- user-service – User profile & authentication.
- wishlist-service – Wishlist management.
- rating-service – Product ratings & reviews.
- notification-service – Handles notifications.
- Checkout-service calls order-service (sync REST).
- Order-service creates order (status = PENDING).
- Order-service locks inventory (sync REST).
- Order-service creates payment (sync REST).
- Razorpay webhook confirms payment.
- Payment-service publishes
PaymentSuccessEventto Kafka. - Order-service consumes event and updates status → PLACED.
- Order status → CANCEL_REQUESTED.
- Order-service publishes
OrderCancelEvent. - Inventory-service releases stock.
- Payment-service processes refund.
- Saga state tracked in
saga_statetable. - When both compensation steps complete → status = CANCELLED.
To ensure reliable event publishing:
- inventory-service uses
outbox_eventtable. - order-service uses
order_outboxtable. - Events are written in the same DB transaction.
- Scheduled publisher sends events to Kafka.
- Prevents data inconsistency and event loss.
- checkout → order
- order → inventory
- order → payment
- PaymentSuccessEvent
- PaymentRefundedEvent
- InventoryReleasedEvent
- OrderCancelEvent
- Separate database per microservice.
- Redis used by:
- cart-service (cart storage)
- checkout-service (idempotency)
- Elasticsearch used by search-service.
- Saga state stored in
saga_state. - Outbox tables used for reliable messaging.
- Java
- Spring Boot
- Spring Data JPA
- Spring Kafka
- Feign Client
- Resilience4j
- (Add your frontend tech here)
- Kafka
- Redis
- Elasticsearch
- MySQL / PostgreSQL
- Docker
- Maven
- Docker
- Kafka
- Redis
- MySQL / PostgreSQL
docker-compose up --buildnpm install
npm startConfigure the following environment variables:
- Razorpay API Keys
- Kafka Broker URL
- Database credentials
- Redis configuration
- Circuit breaker using Resilience4j
- Retry mechanisms
- Saga retry scheduler
- Idempotent consumers
- Transactional outbox pattern
- At-least-once Kafka delivery
Common issues:
- Kafka consumer not receiving messages
- Razorpay webhook signature validation failure
- Duplicate event processing
- Saga stuck in intermediate state
- Redis cache expiration issues