Skip to content

bakchic/system-design-with-spring-boot

Repository files navigation

🧩 System Design Lab – API Documentation

This project demonstrates a production-style microservices system design using Spring Boot, API Gateway, JWT security, Kafka, Resilience patterns, and Analytics.

All external traffic flows through the API Gateway, which handles:

  • Authentication (JWT)
  • Rate limiting
  • Request routing
  • Security enforcement

🏗️ Architecture Overview

Services involved:

  • API Gateway (8080)
  • Auth Service (8086)
  • Catalog Service (8081)
  • Order Service (8082)
  • Payment Service (8084)
  • Analytics Service (8085)

Key design patterns implemented:

  • API Gateway
  • JWT Authentication
  • Saga (event-driven)
  • Circuit Breaker
  • Rate Limiting
  • Idempotency
  • Event-driven analytics

🔐 Authentication

Generate JWT Token (via API Gateway)

Endpoint

POST /auth/login

URL

http://localhost:8080/auth/login

Request Body

{
  "username": "chiranjib",
  "password": "password"
}

Response

{
  "token": "<JWT_TOKEN>"
}

Use this token in the Authorization header for all secured APIs:

Authorization: Bearer <JWT_TOKEN>

🛍️ Catalog APIs

Get Product (via API Gateway – Secured)

GET /catalog/api/products/{id}

Example:

http://localhost:8080/catalog/api/products/1

Headers:

Authorization: Bearer <JWT_TOKEN>

Create Product (via API Gateway – Secured)

POST /catalog/api/products

Body:

{
  "name": "iPhone 15",
  "category": "Mobile",
  "price": 80000
}

📦 Order APIs

Place Order (Secured + Idempotent)

POST /orders/api/orders?userId=2&amount=102

Headers:

Authorization: Bearer <JWT_TOKEN>
Idempotency-Key: user-138

Place Order (Circuit Breaker Demo)

POST /orders/api/orders/{orderId}

💳 Payment APIs

POST /payments/api/payments?orderId=2&amount=1200.0

📊 Analytics APIs

GET /analytics/api/analytics/orders
GET /analytics/api/analytics/payments

🧠 System Design Concepts Demonstrated

  • Microservices Architecture
  • API Gateway Pattern
  • JWT Authentication & Authorization
  • Rate Limiting (Redis)
  • Idempotency
  • Saga Pattern
  • Circuit Breaker (Resilience4j)
  • Retry & Timeout
  • Event-driven Analytics

🚀 How to Run

docker compose build
docker compose up

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors