# maithanh1307/e-commerce architecture

> Architecture diagram of the GitHub repository maithanh1307/e-commerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maithanh1307/e-commerce
- Repository: https://github.com/maithanh1307/e-commerce

## Overview

This repository implements a multi-service e-commerce backend. The principal workflow runs from API requests through authentication and catalog/cart operations into order checkout, where the order service coordinates product, promotion and inventory checks; payment and review are separate order-related stages. Kafka carries order, payment and review events to notifications. Edges among sampled components are grounded in excerpts; the README documents gateway routes and service capabilities, but many controllers and integrations were not sampled, so uncertain links are omitted.

Main entry points: [`backend/api-gateway/src/main/java/com/ecommerce/api_gateway/ApiGatewayApplication.java`](https://github.com/maithanh1307/e-commerce/blob/main/backend/api-gateway/src/main/java/com/ecommerce/api_gateway/ApiGatewayApplication.java) (API Gateway), [`backend/order-service/src/main/java/com/ecommerce/order_service/service/OrderService.java`](https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/service/OrderService.java) (Checkout Orchestration), [`backend/payment-service/src/main/java/com/ecommerce/payment_service/service/PaymentService.java`](https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/service/PaymentService.java) (Payment Processing), [`backend/review-service/src/main/java/com/ecommerce/review_service/service/ReviewService.java`](https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/service/ReviewService.java) (Review Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and Identity"]
  node_gateway["API Gateway"]
  node_auth_api["Auth API"]
  node_auth_service["Authentication<br/>[AuthService.java]"]
  node_jwt["JWT Security<br/>[JwtService.java]"]
  node_users[("User Store")]
end

subgraph group_commerce["Shopping and Catalog"]
  node_product_api["Product API"]
  node_product_service["Product Catalog"]
  node_products[("Product Store")]
  node_cart_api["Cart API"]
  node_cart_service["Cart Management<br/>[CartService.java]"]
  node_cart_store[("Cart Store")]
  node_cart_cache["Cart Cache"]
  node_inventory_api["Inventory API"]
  node_inventory_service["Stock Management"]
  node_inventory_store[("Stock Store")]
end

subgraph group_fulfillment["Order and Payment"]
  node_orders_api["Order API"]
  node_order_service["Checkout Orchestration<br/>[OrderService.java]"]
  node_order_store[("Order Store")]
  node_promotions["Promotion Service"]
  node_payments_api["Payment API"]
  node_payment_service["Payment Processing"]
  node_payment_store[("Payment Store")]
end

subgraph group_engagement["Customer Engagement"]
  node_reviews_api["Review API"]
  node_review_service["Review Management<br/>[ReviewService.java]"]
  node_review_store[("Review Store")]
  node_notification_consumer["Event Consumer"]
  node_notification_service["Notifications"]
  node_notification_store[("Notification Store")]
end

subgraph group_platform["Platform Services"]
  node_event_bus["Kafka Events"]
  node_registry["Service Registry"]
end

node_shopper(("API Client"))

node_shopper -->|"sends requests"| node_gateway
node_gateway -->|"routes auth"| node_auth_api
node_gateway -->|"routes catalog"| node_product_api
node_gateway -->|"routes cart"| node_cart_api
node_gateway -->|"routes orders"| node_orders_api
node_gateway -->|"routes payments"| node_payments_api
node_gateway -->|"routes stock"| node_inventory_api
node_gateway -->|"routes reviews"| node_reviews_api
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"reads/writes users"| node_users
node_auth_service -->|"creates tokens"| node_jwt
node_product_api -->|"delegates"| node_product_service
node_product_service -->|"reads/writes products"| node_products
node_cart_api -->|"delegates"| node_cart_service
node_cart_service -->|"reads/writes carts"| node_cart_store
node_cart_service -->|"checks/invalidates"| node_cart_cache
node_inventory_api -->|"delegates"| node_inventory_service
node_inventory_service -->|"reads/writes stock"| node_inventory_store
node_orders_api -->|"delegates"| node_order_service
node_order_service -->|"reads/writes orders"| node_order_store
node_order_service -.->|"fetches cart"| node_cart_service
node_order_service -.->|"fetches products"| node_product_service
node_order_service -.->|"reserves stock"| node_inventory_service
node_order_service -.->|"validates code"| node_promotions
node_order_service -->|"publishes events"| node_event_bus
node_payments_api -->|"delegates"| node_payment_service
node_payment_service -.->|"fetches order"| node_order_service
node_payment_service -->|"reads/writes payments"| node_payment_store
node_payment_service -->|"publishes events"| node_event_bus
node_reviews_api -->|"delegates"| node_review_service
node_review_service -.->|"checks order"| node_order_service
node_review_service -->|"reads/writes reviews"| node_review_store
node_review_service -->|"publishes events"| node_event_bus
node_event_bus -->|"delivers events"| node_notification_consumer
node_notification_consumer -->|"handles events"| node_notification_service
node_notification_service -->|"reads/writes notifications"| node_notification_store
node_gateway -.->|"discovers services"| node_registry

click node_gateway "https://github.com/maithanh1307/e-commerce/blob/main/backend/api-gateway/src/main/java/com/ecommerce/api_gateway/ApiGatewayApplication.java"
click node_auth_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java"
click node_auth_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/service/AuthService.java"
click node_jwt "https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java"
click node_users "https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/repository/UserRepository.java"
click node_product_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/controller/ProductController.java"
click node_product_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/service/ProductService.java"
click node_products "https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/repository/ProductRepository.java"
click node_cart_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/controller/CartController.java"
click node_cart_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartService.java"
click node_cart_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/repository/CartRepository.java"
click node_cart_cache "https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartCacheService.java"
click node_inventory_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/controller/InventoryController.java"
click node_inventory_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/service/InventoryService.java"
click node_inventory_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/repository/InventoryRepository.java"
click node_orders_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/controller/OrderController.java"
click node_order_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/service/OrderService.java"
click node_order_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/repository/OrderRepository.java"
click node_promotions "https://github.com/maithanh1307/e-commerce/blob/main/backend/promotion-service/src/main/java/com/ecommerce/promotion_service/service/PromotionService.java"
click node_payments_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/controller/PaymentController.java"
click node_payment_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/service/PaymentService.java"
click node_payment_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/repository/PaymentRepository.java"
click node_reviews_api "https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/controller/ReviewController.java"
click node_review_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/service/ReviewService.java"
click node_review_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/repository/ReviewRepository.java"
click node_event_bus "https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/event/KafkaEventPublisher.java"
click node_notification_consumer "https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/event/NotificationKafkaConsumer.java"
click node_notification_service "https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/service/NotificationService.java"
click node_notification_store "https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/repository/NotificationRepository.java"
click node_registry "https://github.com/maithanh1307/e-commerce/blob/main/backend/service-registry/src/main/java/com/ecommerce/service_registry/ServiceRegistryApplication.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gateway,node_auth_api,node_auth_service,node_jwt,node_users,node_shopper toneBlue
class node_product_api,node_product_service,node_products,node_cart_api,node_cart_service,node_cart_store,node_cart_cache,node_inventory_api,node_inventory_service,node_inventory_store toneAmber
class node_orders_api,node_order_service,node_order_store,node_promotions,node_payments_api,node_payment_service,node_payment_store toneMint
class node_reviews_api,node_review_service,node_review_store,node_notification_consumer,node_notification_service,node_notification_store toneRose
class node_event_bus,node_registry toneIndigo
```

## Components

### Entry and Identity

- [API Gateway](https://github.com/maithanh1307/e-commerce/blob/main/backend/api-gateway/src/main/java/com/ecommerce/api_gateway/ApiGatewayApplication.java): `backend/api-gateway/src/main/java/com/ecommerce/api_gateway/ApiGatewayApplication.java`
- [Auth API](https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java): `backend/auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java`
- [Authentication](https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/service/AuthService.java): `backend/auth-service/src/main/java/com/ecommerce/auth_service/service/AuthService.java`
- [JWT Security](https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java): `backend/auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java`
- [User Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/auth-service/src/main/java/com/ecommerce/auth_service/repository/UserRepository.java): `backend/auth-service/src/main/java/com/ecommerce/auth_service/repository/UserRepository.java`

### Shopping and Catalog

- [Product API](https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/controller/ProductController.java): `backend/product-service/src/main/java/com/ecommerce/product_service/controller/ProductController.java`
- [Product Catalog](https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/service/ProductService.java): `backend/product-service/src/main/java/com/ecommerce/product_service/service/ProductService.java`
- [Product Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/product-service/src/main/java/com/ecommerce/product_service/repository/ProductRepository.java): `backend/product-service/src/main/java/com/ecommerce/product_service/repository/ProductRepository.java`
- [Cart API](https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/controller/CartController.java): `backend/cart-service/src/main/java/com/ecommerce/cart_service/controller/CartController.java`
- [Cart Management](https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartService.java): `backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartService.java`
- [Cart Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/repository/CartRepository.java): `backend/cart-service/src/main/java/com/ecommerce/cart_service/repository/CartRepository.java`
- [Cart Cache](https://github.com/maithanh1307/e-commerce/blob/main/backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartCacheService.java): `backend/cart-service/src/main/java/com/ecommerce/cart_service/service/CartCacheService.java`
- [Inventory API](https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/controller/InventoryController.java): `backend/inventory-service/src/main/java/com/ecommerce/inventory_service/controller/InventoryController.java`
- [Stock Management](https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/service/InventoryService.java): `backend/inventory-service/src/main/java/com/ecommerce/inventory_service/service/InventoryService.java`
- [Stock Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/inventory-service/src/main/java/com/ecommerce/inventory_service/repository/InventoryRepository.java): `backend/inventory-service/src/main/java/com/ecommerce/inventory_service/repository/InventoryRepository.java`

### Order and Payment

- [Order API](https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/controller/OrderController.java): `backend/order-service/src/main/java/com/ecommerce/order_service/controller/OrderController.java`
- [Checkout Orchestration](https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/service/OrderService.java): `backend/order-service/src/main/java/com/ecommerce/order_service/service/OrderService.java`
- [Order Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/repository/OrderRepository.java): `backend/order-service/src/main/java/com/ecommerce/order_service/repository/OrderRepository.java`
- [Promotion Service](https://github.com/maithanh1307/e-commerce/blob/main/backend/promotion-service/src/main/java/com/ecommerce/promotion_service/service/PromotionService.java): `backend/promotion-service/src/main/java/com/ecommerce/promotion_service/service/PromotionService.java`
- [Payment API](https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/controller/PaymentController.java): `backend/payment-service/src/main/java/com/ecommerce/payment_service/controller/PaymentController.java`
- [Payment Processing](https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/service/PaymentService.java): `backend/payment-service/src/main/java/com/ecommerce/payment_service/service/PaymentService.java`
- [Payment Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/payment-service/src/main/java/com/ecommerce/payment_service/repository/PaymentRepository.java): `backend/payment-service/src/main/java/com/ecommerce/payment_service/repository/PaymentRepository.java`

### Customer Engagement

- [Review API](https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/controller/ReviewController.java): `backend/review-service/src/main/java/com/ecommerce/review_service/controller/ReviewController.java`
- [Review Management](https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/service/ReviewService.java): `backend/review-service/src/main/java/com/ecommerce/review_service/service/ReviewService.java`
- [Review Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/review-service/src/main/java/com/ecommerce/review_service/repository/ReviewRepository.java): `backend/review-service/src/main/java/com/ecommerce/review_service/repository/ReviewRepository.java`
- [Event Consumer](https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/event/NotificationKafkaConsumer.java): `backend/notification-service/src/main/java/com/ecommerce/notification_service/event/NotificationKafkaConsumer.java`
- [Notifications](https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/service/NotificationService.java): `backend/notification-service/src/main/java/com/ecommerce/notification_service/service/NotificationService.java`
- [Notification Store](https://github.com/maithanh1307/e-commerce/blob/main/backend/notification-service/src/main/java/com/ecommerce/notification_service/repository/NotificationRepository.java): `backend/notification-service/src/main/java/com/ecommerce/notification_service/repository/NotificationRepository.java`

### Platform Services

- [Kafka Events](https://github.com/maithanh1307/e-commerce/blob/main/backend/order-service/src/main/java/com/ecommerce/order_service/event/KafkaEventPublisher.java): `backend/order-service/src/main/java/com/ecommerce/order_service/event/KafkaEventPublisher.java`
- [Service Registry](https://github.com/maithanh1307/e-commerce/blob/main/backend/service-registry/src/main/java/com/ecommerce/service_registry/ServiceRegistryApplication.java): `backend/service-registry/src/main/java/com/ecommerce/service_registry/ServiceRegistryApplication.java`

### Other components

- **API Client**

## Connections

- API Client → API Gateway: sends requests
- API Gateway → Auth API: routes auth
- API Gateway → Product API: routes catalog
- API Gateway → Cart API: routes cart
- API Gateway → Order API: routes orders
- API Gateway → Payment API: routes payments
- API Gateway → Inventory API: routes stock
- API Gateway → Review API: routes reviews
- Auth API → Authentication: delegates
- Authentication → User Store: reads/writes users
- Authentication → JWT Security: creates tokens
- Product API → Product Catalog: delegates
- Product Catalog → Product Store: reads/writes products
- Cart API → Cart Management: delegates
- Cart Management → Cart Store: reads/writes carts
- Cart Management → Cart Cache: checks/invalidates
- Inventory API → Stock Management: delegates
- Stock Management → Stock Store: reads/writes stock
- Order API → Checkout Orchestration: delegates
- Checkout Orchestration → Order Store: reads/writes orders
- Checkout Orchestration → Cart Management: fetches cart
- Checkout Orchestration → Product Catalog: fetches products
- Checkout Orchestration → Stock Management: reserves stock
- Checkout Orchestration → Promotion Service: validates code
- Checkout Orchestration → Kafka Events: publishes events
- Payment API → Payment Processing: delegates
- Payment Processing → Checkout Orchestration: fetches order
- Payment Processing → Payment Store: reads/writes payments
- Payment Processing → Kafka Events: publishes events
- Review API → Review Management: delegates
- Review Management → Checkout Orchestration: checks order
- Review Management → Review Store: reads/writes reviews
- Review Management → Kafka Events: publishes events
- Kafka Events → Event Consumer: delivers events
- Event Consumer → Notifications: handles events
- Notifications → Notification Store: reads/writes notifications
- API Gateway → Service Registry: discovers services
