# truongphuckhue/ecommerce-microservices architecture

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

- Interactive diagram: https://gitdiagram.com/truongphuckhue/ecommerce-microservices
- Repository: https://github.com/truongphuckhue/ecommerce-microservices

## Overview

This repository is documented as an e-commerce microservices platform with a separate PromoX marketing platform. The principal workflow is a customer request through the gateway into commerce services, followed by order, inventory, and payment coordination through a compensating Saga. The tree contains only README.md and no source excerpts, so paths and undocumented service wiring are omitted; the diagram reflects documented capabilities and relationships only.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API Entry"]
  node_gateway["API Gateway"]
end

subgraph group_commerce["E-Commerce"]
  node_user["User Service"]
  node_product["Product Service"]
  node_cart["Cart Service"]
  node_notification["Notification Service"]
end

subgraph group_saga["Order Saga"]
  node_order["Order Service"]
  node_inventory["Inventory Service"]
  node_payment["Payment Service"]
end

subgraph group_promox["PromoX Marketing"]
  node_campaign["Campaign Service"]
  node_promotion["Promotion Service"]
  node_flashsale["FlashSale Service"]
  node_coupon["Coupon Service"]
  node_reward["Reward Service"]
  node_analytics["Analytics Service"]
end

subgraph group_platform["Platform Services"]
  node_kafka["Kafka"]
  node_eureka["Eureka Server"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
end

node_customer(("Customer"))
node_payment_gateway["Payment Gateway"]

node_customer -->|"requests"| node_gateway
node_gateway -->|"authenticates"| node_user
node_gateway -->|"routes requests"| node_product
node_gateway -->|"routes requests"| node_cart
node_gateway -->|"routes requests"| node_order
node_order -->|"publishes order"| node_kafka
node_kafka -->|"dispatches event"| node_inventory
node_inventory -->|"publishes result"| node_kafka
node_kafka -->|"dispatches event"| node_payment
node_payment -->|"processes payment"| node_payment_gateway
node_payment -->|"publishes outcome"| node_kafka
node_kafka -.->|"dispatches compensation"| node_inventory
node_kafka -->|"dispatches status event"| node_order
node_kafka -->|"delivers events"| node_notification
node_gateway -->|"routes requests"| node_campaign
node_gateway -->|"routes requests"| node_promotion
node_gateway -->|"routes requests"| node_flashsale
node_gateway -->|"routes requests"| node_coupon
node_gateway -->|"routes requests"| node_reward
node_gateway -->|"routes requests"| node_analytics
node_gateway -->|"discovers services"| node_eureka
node_product -->|"stores catalog"| node_postgres
node_inventory -->|"stores stock"| node_postgres
node_order -->|"stores orders"| node_postgres
node_cart -->|"caches sessions"| node_redis

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 toneBlue
class node_user,node_product,node_cart,node_notification toneAmber
class node_order,node_inventory,node_payment toneMint
class node_campaign,node_promotion,node_flashsale,node_coupon,node_reward,node_analytics toneRose
class node_kafka,node_eureka,node_postgres,node_redis,node_customer,node_payment_gateway toneIndigo
```

## Components

### API Entry

- **API Gateway**

### E-Commerce

- **User Service**
- **Product Service**
- **Cart Service**
- **Notification Service**

### Order Saga

- **Order Service**
- **Inventory Service**
- **Payment Service**

### PromoX Marketing

- **Campaign Service**
- **Promotion Service**
- **FlashSale Service**
- **Coupon Service**
- **Reward Service**
- **Analytics Service**

### Platform Services

- **Kafka**
- **Eureka Server**
- **PostgreSQL**
- **Redis**

### Other components

- **Customer**
- **Payment Gateway**

## Connections

- Customer → API Gateway: requests
- API Gateway → User Service: authenticates
- API Gateway → Product Service: routes requests
- API Gateway → Cart Service: routes requests
- API Gateway → Order Service: routes requests
- Order Service → Kafka: publishes order
- Kafka → Inventory Service: dispatches event
- Inventory Service → Kafka: publishes result
- Kafka → Payment Service: dispatches event
- Payment Service → Payment Gateway: processes payment
- Payment Service → Kafka: publishes outcome
- Kafka → Inventory Service: dispatches compensation
- Kafka → Order Service: dispatches status event
- Kafka → Notification Service: delivers events
- API Gateway → Campaign Service: routes requests
- API Gateway → Promotion Service: routes requests
- API Gateway → FlashSale Service: routes requests
- API Gateway → Coupon Service: routes requests
- API Gateway → Reward Service: routes requests
- API Gateway → Analytics Service: routes requests
- API Gateway → Eureka Server: discovers services
- Product Service → PostgreSQL: stores catalog
- Inventory Service → PostgreSQL: stores stock
- Order Service → PostgreSQL: stores orders
- Cart Service → Redis: caches sessions
