Build Scalable Microservices Architecture

Production-ready e-commerce platform with 8 microservices using Spring Boot, Kafka, and Docker

Java 17 Spring Boot Kafka PostgreSQL MongoDB Docker

8

Microservices

5

Databases

9

Design Patterns

100%

Containerized

What's Inside

The key patterns and technologies used

Service Discovery

Eureka handles service registration and discovery automatically

API Gateway

Single entry point that routes requests to the right service

Centralized Config

All service configurations managed in one place

Event Streaming

Kafka handles async messaging between services

Multiple Databases

PostgreSQL and MongoDB - each service owns its data

Distributed Tracing

Track requests across all services with Zipkin

Saga Pattern

Handles distributed transactions across multiple services

Fully Dockerized

Everything runs in containers with docker-compose

Email Notifications

Automatic HTML emails for orders and payments

System Architecture

Modern microservices architecture with cloud-native patterns

Demo: Complete walkthrough of the microservices platform

Implemented Patterns

Service Registry & Discovery
API Gateway Pattern
Database per Service
Event-Driven Architecture
Externalized Configuration
Distributed Tracing
Saga Pattern
Circuit Breaker Ready
Health Check API

Microservices Overview

8 independent services working together seamlessly

Infrastructure Services

Config Server

:8888

Centralized configuration management using Spring Cloud Config

  • Manages configurations for all services
  • Support for multiple profiles (dev, prod)
  • Hot reload configuration updates
Spring Cloud Config

Discovery Service

:8082

Service registry for dynamic service discovery

  • Netflix Eureka Server
  • Automatic service registration
  • Client-side load balancing
  • Health monitoring dashboard
Netflix Eureka

API Gateway

:8080

Single entry point for all client requests

  • Dynamic routing to microservices
  • Request/response logging
  • Distributed tracing integration
Spring Cloud Gateway

Business Services

Customer Service

:8081

Customer profile and address management

  • CRUD operations for customers
  • Address information management
  • Customer existence validation
MongoDB Spring Data MongoDB

Product Service

:8086

Product catalog and inventory management

  • 25+ pre-loaded products
  • 5 product categories
  • Inventory tracking and validation
  • Flyway database migrations
PostgreSQL Flyway

Order Service

:8084

Order orchestration and workflow management

  • Complete order lifecycle management
  • Customer and product validation
  • Payment processing integration
  • Kafka event publishing
PostgreSQL OpenFeign Kafka Producer

Payment Service

:8085

Payment processing and transaction management

  • Multiple payment methods support
  • Credit Card, Debit Card, PayPal, UPI
  • Payment confirmation events
PostgreSQL Kafka Producer

Notification Service

:8083

Event-driven email notification system

  • Order confirmation emails
  • Payment confirmation emails
  • HTML email templates (Thymeleaf)
  • Notification history persistence
MongoDB Kafka Consumer Thymeleaf

Live Demo & Screenshots

See the platform in action

Eureka Dashboard

Service Registry Dashboard

http://localhost:8082

Zipkin Tracing

Distributed Tracing UI

http://localhost:9411

PgAdmin

PostgreSQL Management

http://localhost:5050

Mongo Express

MongoDB Management

http://localhost:8081

Try the API

Example API calls you can test once the platform is running:

Create a Customer
curl -X POST http://localhost:8080/api/v1/customers \
  -H "Content-Type: application/json" \
  -d '{
    "firstname": "John",
    "lastname": "Doe",
    "email": "john.doe@example.com",
    "address": {
      "street": "Main Street",
      "houseNumber": "123",
      "zipCode": "12345"
    }
  }'
Browse Products
curl http://localhost:8080/api/v1/products
Place an Order
curl -X POST http://localhost:8080/api/v1/orders \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "customer-id-here",
    "paymentMethod": "CREDIT_CARD",
    "products": [
      {
        "productId": 1,
        "quantity": 2
      }
    ]
  }'

Getting Started

Get up and running in minutes

1

Prerequisites

Ensure you have the following installed:

  • Java 17 or higher
  • Docker & Docker Compose
  • Git
  • Maven 3.6+ (optional, wrapper included)
# Verify installations
java -version
docker --version
docker-compose --version
2

Clone the Repository

git clone https://github.com/RakeshSingh38/ekart-microservices.git
cd microservices-java
3

Start the Platform

Launch all services with Docker Compose:

# Start all services
docker-compose up -d

# Check service status
docker-compose ps

# View logs
docker-compose logs -f

Services will start in the correct order. Config Server starts first, followed by Discovery, then Gateway, and finally business services.

5

Run End-to-End Test

Test the complete order flow:

# Run automated E2E test
./scripts/test-e2e.sh

# Or manually test APIs
curl http://localhost:8080/api/v1/products
curl http://localhost:8080/api/v1/customers

If successful, you'll see order confirmation and payment confirmation emails in MailDev!

Technology Stack

Backend

  • Java 17
  • Spring Boot 3.2.5
  • Spring Cloud 2023.0.1
  • Spring Data JPA
  • Spring Data MongoDB
  • Spring Kafka

Microservices

  • Spring Cloud Config
  • Netflix Eureka
  • Spring Cloud Gateway
  • OpenFeign
  • Resilience4j Ready

Databases

  • PostgreSQL 15
  • MongoDB 7
  • Flyway Migrations
  • HikariCP Connection Pool

Messaging

  • Apache Kafka 6.2.0
  • Zookeeper
  • Spring Kafka

Observability

  • Zipkin Tracing
  • Micrometer
  • Spring Boot Actuator

DevOps

  • Docker
  • Docker Compose
  • Multi-stage Builds
  • GitHub Actions