# mnabli94/ecommerce-microservices architecture

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

- Interactive diagram: https://gitdiagram.com/mnabli94/ecommerce-microservices
- Repository: https://github.com/mnabli94/ecommerce-microservices
- Video tour (about a minute): https://gitdiagram.com/mnabli94/ecommerce-microservices/video

## Overview

This is an event-driven e-commerce backend. A customer request enters through the API Gateway; order creation synchronously validates stock with the Product Service, while Kafka supports asynchronous consistency. Authentication and payment are distinct service capabilities in the repository. The README documents the gateway and stock-validation relationships; event-service routing and payment flow are not shown in the available evidence, so those links are omitted.

Main entry points: [`api-gateway/src/main/java/com/demo/apigateway/ApiGatewayApplication.java`](https://github.com/mnabli94/ecommerce-microservices/blob/main/api-gateway/src/main/java/com/demo/apigateway/ApiGatewayApplication.java) (API Gateway), [`order-service/src/main/java/com/demo/order/service/OrderService.java`](https://github.com/mnabli94/ecommerce-microservices/blob/main/order-service/src/main/java/com/demo/order/service/OrderService.java) (Order management), [`product-service/src/main/java/com/demo/product/service/StockService.java`](https://github.com/mnabli94/ecommerce-microservices/blob/main/product-service/src/main/java/com/demo/product/service/StockService.java) (Product catalog and stock), [`config-server/src/main/java/com/demo/config/ConfigServerApplication.java`](https://github.com/mnabli94/ecommerce-microservices/blob/main/config-server/src/main/java/com/demo/config/ConfigServerApplication.java) (Config Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Entry and identity"]
  node_gateway["API Gateway"]
  node_auth["Authentication"]
  node_authdb[("Users database")]
end

subgraph group_commerce["Commerce services"]
  node_orders["Order management<br/>[OrderService.java]"]
  node_ordersdb[("Orders database")]
  node_products["Product catalog and stock<br/>[StockService.java]"]
  node_productsdb[("Products database")]
  node_payments["Payment processing"]
end

subgraph group_messaging["Messaging"]
  node_eventcontracts["Event contracts"]
  node_kafka["Kafka"]
  node_kafkautils["Kafka utilities"]
end

subgraph group_platform["Configuration and monitoring"]
  node_configserver["Config Server"]
  node_configrepo["Service configuration"]
  node_monitoring["Monitoring<br/>[prometheus.yml]"]
end

node_customer(("API client"))

node_customer -->|"sends requests"| node_gateway
node_gateway -->|"routes requests"| node_auth
node_gateway -->|"routes requests"| node_orders
node_gateway -->|"routes requests"| node_products
node_orders -->|"checks stock"| node_products
node_configserver -.->|"loads configuration"| node_configrepo

click node_gateway "https://github.com/mnabli94/ecommerce-microservices/blob/main/api-gateway/src/main/java/com/demo/apigateway/ApiGatewayApplication.java"
click node_auth "https://github.com/mnabli94/ecommerce-microservices/blob/main/auth-service/src/main/java/com/demo/auth/controller/AuthController.java"
click node_authdb "https://github.com/mnabli94/ecommerce-microservices/tree/main/auth-service/src/main/resources/db/migration"
click node_orders "https://github.com/mnabli94/ecommerce-microservices/blob/main/order-service/src/main/java/com/demo/order/service/OrderService.java"
click node_ordersdb "https://github.com/mnabli94/ecommerce-microservices/tree/main/order-service/src/main/resources/db/migration"
click node_products "https://github.com/mnabli94/ecommerce-microservices/blob/main/product-service/src/main/java/com/demo/product/service/StockService.java"
click node_productsdb "https://github.com/mnabli94/ecommerce-microservices/tree/main/product-service/src/main/resources/db/migration"
click node_payments "https://github.com/mnabli94/ecommerce-microservices/blob/main/payment-service/src/main/java/com/demo/payment/service/PaymentService.java"
click node_eventcontracts "https://github.com/mnabli94/ecommerce-microservices/tree/main/events-api/src/main/java/com/demo/events"
click node_kafkautils "https://github.com/mnabli94/ecommerce-microservices/blob/main/kafka-utils/src/main/java/com/demo/kafka/utils/producer/EventPublisher.java"
click node_configserver "https://github.com/mnabli94/ecommerce-microservices/blob/main/config-server/src/main/java/com/demo/config/ConfigServerApplication.java"
click node_configrepo "https://github.com/mnabli94/ecommerce-microservices/tree/main/config-repo"
click node_monitoring "https://github.com/mnabli94/ecommerce-microservices/blob/main/prometheus.yml"

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,node_authdb,node_customer toneBlue
class node_orders,node_ordersdb,node_products,node_productsdb,node_payments toneAmber
class node_eventcontracts,node_kafka,node_kafkautils toneMint
class node_configserver,node_configrepo,node_monitoring toneRose
```

## Components

### Entry and identity

- [API Gateway](https://github.com/mnabli94/ecommerce-microservices/blob/main/api-gateway/src/main/java/com/demo/apigateway/ApiGatewayApplication.java): `api-gateway/src/main/java/com/demo/apigateway/ApiGatewayApplication.java`
- [Authentication](https://github.com/mnabli94/ecommerce-microservices/blob/main/auth-service/src/main/java/com/demo/auth/controller/AuthController.java): `auth-service/src/main/java/com/demo/auth/controller/AuthController.java`
- [Users database](https://github.com/mnabli94/ecommerce-microservices/tree/main/auth-service/src/main/resources/db/migration): `auth-service/src/main/resources/db/migration`

### Commerce services

- [Order management](https://github.com/mnabli94/ecommerce-microservices/blob/main/order-service/src/main/java/com/demo/order/service/OrderService.java): `order-service/src/main/java/com/demo/order/service/OrderService.java`
- [Orders database](https://github.com/mnabli94/ecommerce-microservices/tree/main/order-service/src/main/resources/db/migration): `order-service/src/main/resources/db/migration`
- [Product catalog and stock](https://github.com/mnabli94/ecommerce-microservices/blob/main/product-service/src/main/java/com/demo/product/service/StockService.java): `product-service/src/main/java/com/demo/product/service/StockService.java`
- [Products database](https://github.com/mnabli94/ecommerce-microservices/tree/main/product-service/src/main/resources/db/migration): `product-service/src/main/resources/db/migration`
- [Payment processing](https://github.com/mnabli94/ecommerce-microservices/blob/main/payment-service/src/main/java/com/demo/payment/service/PaymentService.java): `payment-service/src/main/java/com/demo/payment/service/PaymentService.java`

### Messaging

- [Event contracts](https://github.com/mnabli94/ecommerce-microservices/tree/main/events-api/src/main/java/com/demo/events): `events-api/src/main/java/com/demo/events`
- **Kafka**
- [Kafka utilities](https://github.com/mnabli94/ecommerce-microservices/blob/main/kafka-utils/src/main/java/com/demo/kafka/utils/producer/EventPublisher.java): `kafka-utils/src/main/java/com/demo/kafka/utils/producer/EventPublisher.java`

### Configuration and monitoring

- [Config Server](https://github.com/mnabli94/ecommerce-microservices/blob/main/config-server/src/main/java/com/demo/config/ConfigServerApplication.java): `config-server/src/main/java/com/demo/config/ConfigServerApplication.java`
- [Service configuration](https://github.com/mnabli94/ecommerce-microservices/tree/main/config-repo): `config-repo`
- [Monitoring](https://github.com/mnabli94/ecommerce-microservices/blob/main/prometheus.yml): `prometheus.yml`

### Other components

- **API client**

## Connections

- API client → API Gateway: sends requests (evidence: `README.md`)
- API Gateway → Authentication: routes requests (evidence: `README.md`)
- API Gateway → Order management: routes requests (evidence: `README.md`)
- API Gateway → Product catalog and stock: routes requests (evidence: `README.md`)
- Order management → Product catalog and stock: checks stock (evidence: `README.md`)
- Config Server → Service configuration: loads configuration
