Skip to content

berkayerdemsoy/e-commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroMart

Typing SVG

Cloud-Native E-Commerce & Warehouse Management Platform

MicroMart is a production-grade, end-to-end e-commerce system built on a microservices architecture with Domain-Driven Design (DDD) and Event-Driven principles. The platform handles the full commercial lifecycle — product catalog, cart management, order orchestration, payment processing, warehouse operations, and shipment tracking — across independent, loosely coupled services.

Designed as a direct response to the scaling and maintenance limitations of monolithic systems, MicroMart applies Loose Coupling and High Cohesion throughout its domain boundaries.


Architecture Overview

The system is decomposed into eight bounded contexts, each deployed as an independent service. All external traffic enters through a single API Gateway, while inter-service communication uses both synchronous (OpenFeign/REST) and asynchronous (Kafka) channels depending on consistency requirements.

┌─────────────────────────────────────────────────────────────────────┐
│                            CLIENT                                   │
└─────────────────────────────┬───────────────────────────────────────┘
                              │ HTTP
                              ▼
                    ┌─────────────────┐
                    │   API Gateway   │  :8080
                    │ Spring Cloud GW │
                    └────────┬────────┘
                             │ Routes
          ┌──────────────────┼──────────────────────┐
          │                  │                      │
          ▼                  ▼                      ▼
  ┌───────────────┐  ┌───────────────┐   ┌──────────────────┐
  │  User Service │  │  Shop Service │   │  Cart Service    │
  │    :8081      │  │    :8082      │   │    :8084         │
  │  [user-db]    │  │  [shop-db]    │   │    [Redis]       │
  └───────────────┘  └───────────────┘   └────────┬─────────┘
                                                   │ OpenFeign
          ┌────────────────────────────────────────▼─────────┐
          │                  Order Service  :8085             │
          │              [order-db]  [Keycloak OAuth2]        │
          └────────────┬──────────────────────────────────────┘
                       │
              Kafka Events
                       │
          ┌────────────┴─────────────────────────────────────┐
          │                                                   │
          ▼                                                   ▼
  ┌───────────────────┐                         ┌────────────────────┐
  │  Payment Service  │                         │ Warehouse Service  │
  │      :8086        │                         │      :8083         │
  │  [payment-db]     │                         │  [warehouse-db]    │
  └───────────────────┘                         └────────────────────┘
                                                         │
                                                  Kafka Events
                                                         │
                                               ┌─────────▼──────────┐
                                               │ Shipment Service   │
                                               │      :8087         │
                                               │  [shipment-db]     │
                                               └────────────────────┘

Order Lifecycle Flow

The following sequence illustrates how a purchase flows through the system asynchronously once an order is placed.

Client          API Gateway      Order Service     Kafka Broker
  │                  │                │                  │
  │── POST /orders ─►│                │                  │
  │                  │── forward ────►│                  │
  │                  │                │── ORDER_CREATED ►│
  │                  │                │                  │
  │                  │                │          ┌───────┴────────┐
  │                  │                │          │                │
  │                  │                │    Payment Svc       Warehouse Svc
  │                  │                │     processes            reserves
  │                  │                │     payment              stock
  │                  │                │          │                │
  │                  │                │◄─ PAYMENT_SUCCESS ────────┘
  │                  │                │
  │                  │                │── SHIPMENT_INITIATED ►│
  │                  │                │                       │
  │                  │                │                 Shipment Svc
  │                  │                │                  creates
  │                  │                │                  tracking
  │◄─ 201 Created ───│◄───────────────│

Design Principles

Principle Implementation
Database per Service Each service owns an isolated PostgreSQL instance; no shared schema
Event-Driven Architecture Order, payment, and shipment flows are decoupled via Apache Kafka topics
Distributed Caching Cart state is stored entirely in Redis for sub-millisecond read/write latency
Centralized Security All authentication and authorization delegated to Keycloak (OAuth2 / OIDC / JWT)
Optimistic Locking Warehouse service uses optimistic locking to prevent overselling under concurrent load
Idempotent Payments Payment service guards against duplicate charges using idempotency keys
Strategy Pattern Shipment service selects a carrier at runtime via the Strategy design pattern
Infrastructure as Code The full stack — 12+ containers — is defined and launched with a single docker-compose up

Technology Stack

Backend & Framework

Java Spring Boot Spring Security Spring Cloud OpenFeign

Messaging & Caching

Apache Kafka Redis Zookeeper

Persistence

PostgreSQL Liquibase

Security

Keycloak OAuth2 JWT

Infrastructure & DevOps

Docker Docker Compose Maven Git


Service Catalog

Service Port Responsibility
API Gateway 8080 Single ingress point. Handles routing, JWT validation, and rate limiting
User Service 8081 User profile and role management integrated with Keycloak
Shop Service 8082 Product catalog, categories, and pricing (read-optimised)
Warehouse Service 8083 Stock, shelf, and aisle management with optimistic concurrency control
Cart Service 8084 Redis-backed cart with high-throughput I/O
Order Service 8085 Full order lifecycle and state-machine orchestration
Payment Service 8086 Payment simulation with idempotency and duplicate-charge prevention
Shipment Service 8087 Carrier selection and delivery tracking via Strategy pattern

Getting Started

Prerequisites: Docker and Docker Compose must be installed locally.

Step 1 — Clone the repository

git clone https://github.com/berkayerdemsoy/e-commerce.git
cd e-commerce

Step 2 — Configure environment variables

cp backend/.env.example backend/.env

Open backend/.env and replace ORDER_SERVICE_CLIENT_SECRET with the client secret generated in the Keycloak admin console.

Step 3 — Build all service JARs

cd backend
./mvnw clean package -DskipTests

Step 4 — Start the full stack

docker-compose up -d --build

This command starts all infrastructure components and application services (~12 containers) in dependency order.


Access Points

Interface URL Credentials
API Gateway http://localhost:8080
Keycloak Admin Console http://localhost:8180 admin / admin
Kafka UI http://localhost:8090
PgAdmin http://localhost:8888 Configured via PGADMIN_DEFAULT_EMAIL / PGADMIN_DEFAULT_PASSWORD in .env

Roadmap

  • Kubernetes migration with Helm chart definitions
  • Centralised log aggregation with the ELK Stack (Elasticsearch, Logstash, Kibana)
  • Observability layer with Prometheus metrics and Grafana dashboards
  • Distributed tracing with OpenTelemetry
  • Kubernetes-native service discovery replacing manual configuration

Author

Berkay Erdemsoy

LinkedIn · berkayerdemsoy@gmail.com

Developed as part of the HAVELSAN A.Ş. Workplace Training Programme.

About

A production-grade, cloud-native e-commerce platform demonstrating Domain-Driven Design (DDD) and Event-Driven microservices architecture using Java 21, Spring Boot, and Apache Kafka.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors