Skip to content

Siddharthpratapsingh/e-commerce-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

E-Commerce Microservices Platform

A full-stack e-commerce application built with Spring Boot 4, Spring Cloud 2025, and a microservices architecture. The platform handles customer management, product catalog, order processing, payments, and email notifications β€” all orchestrated through an API Gateway with service discovery.


Architecture Diagram

                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β”‚     Config Server   β”‚
                                    β”‚     (Port 8888)     β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                               β”‚ Centralized Config
                                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Client  β”‚    β”‚              Discovery Service (Eureka)                  β”‚
β”‚ (Browser/β”‚    β”‚                   (Port 8761)                            β”‚
β”‚   curl)  β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜                               β”‚ Service Registry
      β”‚                                    β”‚
      β”‚ HTTP                               β–Ό
      β–Ό                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚         Registered Services    β”‚
β”‚ API Gateway │◄──────────►│                                β”‚
β”‚ (Port 8088) β”‚  lb://     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚             β”‚  routing   β”‚  β”‚ Customer  β”‚ β”‚  Product   β”‚  β”‚
β”‚ Spring Cloudβ”‚            β”‚  β”‚ Service   β”‚ β”‚  Service   β”‚  β”‚
β”‚ Gateway     β”‚            β”‚  β”‚ (8081)    β”‚ β”‚  (8082)    β”‚  β”‚
β”‚ WebMVC      β”‚            β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚                                β”‚
                           β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                           β”‚  β”‚  Order    β”‚ β”‚  Payment   β”‚  β”‚
                           β”‚  β”‚  Service  β”‚ β”‚  Service   β”‚  β”‚
                           β”‚  β”‚  (8083)   β”‚ β”‚  (8084)    β”‚  β”‚
                           β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
                           β”‚        β”‚              β”‚        β”‚
                           β”‚  β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”  β”‚
                           β”‚  β”‚    Notification Service  β”‚  β”‚
                           β”‚  β”‚        (8085)            β”‚  β”‚
                           β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                           β–Ό                           β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚   PostgreSQL DB  β”‚       β”‚   Apache Kafka    β”‚       β”‚    MailDev       β”‚
   β”‚   (Port 5432)    β”‚       β”‚   (Port 9092)     β”‚       β”‚  SMTP (1025)     β”‚
   β”‚                  β”‚       β”‚                   β”‚       β”‚  Web UI (1080)   β”‚
   β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚       β”‚  Zookeeper (2181) β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   β”‚ β”‚ customer DB  β”‚ β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   β”‚ β”‚ product  DB  β”‚ β”‚              β”‚
   β”‚ β”‚ order    DB  β”‚ β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ β”‚ payment  DB  β”‚ β”‚     β”‚  Kafka Topics   β”‚
   β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚     β”‚ β€’ order-topic   β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚ β€’ payment-topic β”‚
                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Request Flow

Client ──► API Gateway (8088)
               β”‚
               β”œβ”€β”€β–Ί /api/customer/** ──► Customer Service (8081) ──► PostgreSQL
               β”œβ”€β”€β–Ί /api/product/**  ──► Product Service  (8082) ──► PostgreSQL
               β”œβ”€β”€β–Ί /api/order/**    ──► Order Service    (8083) ──► PostgreSQL
               └──► /api/payment/**  ──► Payment Service  (8084) ──► PostgreSQL

Order Creation Flow

1. Client ──► POST /api/order/
2. Order Service ──► (Feign) ──► Customer Service   [Validate customer]
3. Order Service ──► (Feign) ──► Product Service    [Purchase & deduct stock]
4. Order Service ──► (Feign) ──► Payment Service    [Process payment]
5. Payment Service ──► (Kafka) ──► Notification Service [Send email]
6. Order Service ──► (Kafka) ──► Notification Service   [Order confirmation email]

Tech Stack

Layer Technology
Language Java 21
Framework Spring Boot 4.0.2
Cloud Spring Cloud 2025.1.0
API Gateway Spring Cloud Gateway Server WebMVC
Service Discovery Netflix Eureka
Config Management Spring Cloud Config Server (native)
Inter-Service Comm OpenFeign (sync), Apache Kafka (async)
Database PostgreSQL
ORM Spring Data JPA / Hibernate
API Docs SpringDoc OpenAPI (Swagger UI)
Tracing Zipkin + Micrometer Brave
Email MailDev (development SMTP)
Containerization Docker & Docker Compose

Services

Infrastructure Services

Service Port Description
Config Server 8888 Centralized configuration for all services using native file-based profiles
Discovery Service 8761 Eureka server for service registration and discovery
API Gateway 8088 Single entry point; routes requests to downstream services via load balancer

Business Services

Service Port Description
Customer Service 8081 CRUD operations for customer management
Product Service 8082 Product catalog and category management, stock tracking
Order Service 8083 Order creation, orchestrates customer validation, product purchase, and payment
Payment Service 8084 Payment processing, sends Kafka notifications on success
Notification Service 8085 Consumes Kafka events and sends email notifications via MailDev

Infrastructure Components

Component Port Description
PostgreSQL 5432 Shared database server with separate databases per service
Kafka 9092 Message broker for async event-driven communication
Zookeeper 2181 Kafka cluster coordination
Zipkin 9411 Distributed tracing UI
MailDev 1080 (UI) / 1025 (SMTP) Development email server with web UI
pgAdmin 8080 PostgreSQL admin UI

API Endpoints

Customer Service (/api/customer)

Method Endpoint Description
POST /create Create a new customer
GET /get?id={id} Get customer by ID
GET /get-all Get all customers
PUT /update/{id} Update customer
DELETE /delete/{id} Delete customer

Product Service (/api/product)

Method Endpoint Description
POST / Create a new product
GET /all-products Get all products
GET /product/{id} Get product by ID
DELETE /product/{id} Delete product
POST /purchase Purchase products (deducts stock)
POST /category/ Create a category
GET /category/ Get all categories
GET /category/{categoryId} Get category by ID

Order Service (/api/order)

Method Endpoint Description
POST / Create a new order
GET / Get all orders
GET /{id} Get order by ID

Payment Service (/api/payment)

Method Endpoint Description
POST / Process a payment

Getting Started

Prerequisites

  • Docker & Docker Compose
  • Ports 5432, 8080–8088, 9092, 9411, 1025, 1080, 2181 available

Run the Platform

cd services
docker compose up -d --build

Services start in dependency order:

  1. PostgreSQL, Zookeeper, Kafka, Zipkin, MailDev
  2. Config Server (waits for health check)
  3. Discovery Service
  4. All business services + Gateway

Startup time: Allow ~2 minutes for all services to register with Eureka.

Verify Services

# Check all containers are running
docker ps

# Eureka dashboard
open http://localhost:8761

# Test gateway routing
curl http://localhost:8088/api/customer/get-all
curl http://localhost:8088/api/product/all-products
curl http://localhost:8088/api/order/

Swagger UI

Each service exposes Swagger UI for interactive API documentation:

Service Swagger UI
Customer http://localhost:8081/swagger-ui/index.html
Product http://localhost:8082/swagger-ui/index.html
Order http://localhost:8083/swagger-ui/index.html
Payment http://localhost:8084/swagger-ui/index.html

Sample API Usage

Create a Customer

curl -X POST http://localhost:8088/api/customer/create \
  -H "Content-Type: application/json" \
  -d '{"name": "John Doe", "email": "john@example.com"}'

Create a Category

curl -X POST http://localhost:8088/api/product/category/ \
  -H "Content-Type: application/json" \
  -d '{"name": "Electronics", "description": "Electronic devices and gadgets"}'

Create a Product

curl -X POST http://localhost:8088/api/product/ \
  -H "Content-Type: application/json" \
  -d '{
    "name": "iPhone 15",
    "description": "Apple smartphone",
    "price": 999.99,
    "stock": 50,
    "categoryId": {"id": 1}
  }'

Place an Order

curl -X POST http://localhost:8088/api/order/ \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": 1,
    "amount": 999.99,
    "paymentMethod": "CREDIT_CARD",
    "purchaseList": [
      {"productId": 1, "quantity": 1}
    ]
  }'

Supported payment methods: CREDIT_CARD, DEBIT_CARD, UPI, NETBANKING, VISA, STRIPE


Monitoring & Tools

Tool URL Description
Eureka Dashboard http://localhost:8761 View registered services
Zipkin http://localhost:9411 Distributed tracing
pgAdmin http://localhost:8080 Database management (admin@admin.com / admin)
MailDev http://localhost:1080 View sent emails

Project Structure

services/
β”œβ”€β”€ config-server/          # Centralized configuration server
β”‚   └── configurations/     # Property files for each service
β”œβ”€β”€ discovery/              # Eureka service discovery server
β”œβ”€β”€ gateway/                # API Gateway (Spring Cloud Gateway WebMVC)
β”œβ”€β”€ customer/               # Customer microservice
β”œβ”€β”€ product/                # Product & Category microservice
β”œβ”€β”€ order/                  # Order microservice (orchestrator)
β”œβ”€β”€ payment/                # Payment microservice
β”œβ”€β”€ notification/           # Notification microservice (Kafka consumer)
β”œβ”€β”€ postgres/
β”‚   └── init.sql            # Database initialization script
└── docker-compose.yml      # Full platform orchestration

License

This project is for educational and demonstration purposes.

About

Backend application created using spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors