# vaibhavgobre08/distrubuted-ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/vaibhavgobre08/distrubuted-ecommerce
- Repository: https://github.com/vaibhavgobre08/distrubuted-ecommerce

## Overview

OrderFlow is a distributed e-commerce backend. A client request reaches the API Gateway and Order Service, which records a pending order and an outbox event; Kafka carries the event to the Saga Orchestrator, which coordinates inventory, payment, and shipping. Order confirmation or cancellation then drives lifecycle updates and notifications. Authentication issues JWTs that the gateway validates. README documents the broader event flow; source excerpts and the index support selected internal calls, but unsampled Kafka wiring is represented only where the README documents it.

Main entry points: [`saga-orchestrator/src/main/java/com/ecommerce/saga/consumer/OrderEventConsumer.java`](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/saga-orchestrator/src/main/java/com/ecommerce/saga/consumer/OrderEventConsumer.java) (Saga orchestrator), [`order-service/src/main/java/com/ecommerce/order/service/OrderService.java`](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/service/OrderService.java) (Order lifecycle), [`api-gateway/src/main/java/com/ecommerce/gateway/ApiGatewayApplication.java`](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/api-gateway/src/main/java/com/ecommerce/gateway/ApiGatewayApplication.java) (API Gateway), [`inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java`](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java) (Inventory and reservations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and identity"]
  node_gateway["API Gateway"]
  node_auth["Authentication"]
  node_jwt["JWT issuance<br/>[JwtService.java]"]
end

subgraph group_orders["Order lifecycle"]
  node_order_api["Order API"]
  node_order_service["Order lifecycle<br/>[OrderService.java]"]
  node_order_store[("Order database")]
  node_outbox[("Transactional outbox<br/>[OutboxEvent.java]")]
  node_publisher["Outbox publisher"]
end

subgraph group_coordination["Saga coordination"]
  node_saga["Saga orchestrator"]
end

subgraph group_fulfillment["Fulfillment services"]
  node_inventory["Inventory and reservations"]
  node_inventory_store[("Inventory database")]
  node_payment["Payment processing"]
  node_shipping["Shipping management"]
end

subgraph group_messaging["Events and notifications"]
  node_kafka["Kafka"]
  node_notification["Order notifications"]
  node_notification_store[("Notification database")]
end

node_client(("Client"))

node_client -->|"sends requests"| node_gateway
node_gateway -->|"routes orders"| node_order_api
node_client -->|"registers or logs in"| node_auth
node_auth -->|"issues token"| node_jwt
node_gateway -->|"validates token"| node_jwt
node_order_api -->|"delegates"| node_order_service
node_order_service -->|"saves order"| node_order_store
node_order_service -->|"records event"| node_outbox
node_publisher -->|"publishes event"| node_kafka
node_outbox -->|"supplies pending events"| node_publisher
node_kafka -->|"delivers order event"| node_saga
node_saga -->|"requests reservation"| node_inventory
node_inventory -->|"reads and updates stock"| node_inventory_store
node_inventory -->|"reports reservation"| node_kafka
node_saga -->|"requests payment"| node_payment
node_payment -->|"reports payment result"| node_kafka
node_saga -->|"requests shipment"| node_shipping
node_shipping -->|"reports shipment"| node_kafka
node_saga -->|"publishes order outcome"| node_kafka
node_kafka -->|"signals confirmation or cancellation"| node_order_service
node_kafka -->|"delivers order outcome"| node_notification
node_notification -->|"saves notification"| node_notification_store

click node_gateway "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/api-gateway/src/main/java/com/ecommerce/gateway/ApiGatewayApplication.java"
click node_auth "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java"
click node_jwt "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java"
click node_order_api "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/controller/OrderController.java"
click node_order_service "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/service/OrderService.java"
click node_order_store "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/repository/OrderRepository.java"
click node_outbox "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/entity/OutboxEvent.java"
click node_publisher "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/outbox/OutboxEventPublisher.java"
click node_saga "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/saga-orchestrator/src/main/java/com/ecommerce/saga/consumer/OrderEventConsumer.java"
click node_inventory "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java"
click node_inventory_store "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/inventory-service/src/main/java/com/ecommerce/inventory/repository/ProductRepository.java"
click node_payment "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/payment-service/src/main/java/com/ecommerce/payment/service/PaymentService.java"
click node_shipping "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/shipping-service/src/main/java/com/ecommerce/shipping/service/ShippingService.java"
click node_notification "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/notification-service/src/main/java/com/ecommerce/notification/service/NotificationService.java"
click node_notification_store "https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/notification-service/src/main/java/com/ecommerce/notification/repository/NotificationRepository.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,node_jwt,node_client toneBlue
class node_order_api,node_order_service,node_order_store,node_outbox,node_publisher toneAmber
class node_saga toneMint
class node_inventory,node_inventory_store,node_payment,node_shipping toneRose
class node_kafka,node_notification,node_notification_store toneIndigo
```

## Components

### Access and identity

- [API Gateway](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/api-gateway/src/main/java/com/ecommerce/gateway/ApiGatewayApplication.java): `api-gateway/src/main/java/com/ecommerce/gateway/ApiGatewayApplication.java`
- [Authentication](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java): `auth-service/src/main/java/com/ecommerce/auth_service/controller/AuthController.java`
- [JWT issuance](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java): `auth-service/src/main/java/com/ecommerce/auth_service/security/JwtService.java`

### Order lifecycle

- [Order API](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/controller/OrderController.java): `order-service/src/main/java/com/ecommerce/order/controller/OrderController.java`
- [Order lifecycle](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/service/OrderService.java): `order-service/src/main/java/com/ecommerce/order/service/OrderService.java`
- [Order database](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/repository/OrderRepository.java): `order-service/src/main/java/com/ecommerce/order/repository/OrderRepository.java`
- [Transactional outbox](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/entity/OutboxEvent.java): `order-service/src/main/java/com/ecommerce/order/entity/OutboxEvent.java`
- [Outbox publisher](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/order-service/src/main/java/com/ecommerce/order/outbox/OutboxEventPublisher.java): `order-service/src/main/java/com/ecommerce/order/outbox/OutboxEventPublisher.java`

### Saga coordination

- [Saga orchestrator](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/saga-orchestrator/src/main/java/com/ecommerce/saga/consumer/OrderEventConsumer.java): `saga-orchestrator/src/main/java/com/ecommerce/saga/consumer/OrderEventConsumer.java`

### Fulfillment services

- [Inventory and reservations](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java): `inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java`
- [Inventory database](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/inventory-service/src/main/java/com/ecommerce/inventory/repository/ProductRepository.java): `inventory-service/src/main/java/com/ecommerce/inventory/repository/ProductRepository.java`
- [Payment processing](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/payment-service/src/main/java/com/ecommerce/payment/service/PaymentService.java): `payment-service/src/main/java/com/ecommerce/payment/service/PaymentService.java`
- [Shipping management](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/shipping-service/src/main/java/com/ecommerce/shipping/service/ShippingService.java): `shipping-service/src/main/java/com/ecommerce/shipping/service/ShippingService.java`

### Events and notifications

- **Kafka**
- [Order notifications](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/notification-service/src/main/java/com/ecommerce/notification/service/NotificationService.java): `notification-service/src/main/java/com/ecommerce/notification/service/NotificationService.java`
- [Notification database](https://github.com/vaibhavgobre08/distrubuted-ecommerce/blob/main/notification-service/src/main/java/com/ecommerce/notification/repository/NotificationRepository.java): `notification-service/src/main/java/com/ecommerce/notification/repository/NotificationRepository.java`

### Other components

- **Client**

## Connections

- Client → API Gateway: sends requests
- API Gateway → Order API: routes orders
- Client → Authentication: registers or logs in
- Authentication → JWT issuance: issues token
- API Gateway → JWT issuance: validates token
- Order API → Order lifecycle: delegates (evidence: `order-service/src/main/java/com/ecommerce/order/controller/OrderController.java`)
- Order lifecycle → Order database: saves order (evidence: `order-service/src/main/java/com/ecommerce/order/service/OrderService.java`)
- Order lifecycle → Transactional outbox: records event (evidence: `order-service/src/main/java/com/ecommerce/order/service/OrderService.java`)
- Outbox publisher → Kafka: publishes event
- Transactional outbox → Outbox publisher: supplies pending events
- Kafka → Saga orchestrator: delivers order event
- Saga orchestrator → Inventory and reservations: requests reservation
- Inventory and reservations → Inventory database: reads and updates stock (evidence: `inventory-service/src/main/java/com/ecommerce/inventory/service/InventoryService.java`)
- Inventory and reservations → Kafka: reports reservation
- Saga orchestrator → Payment processing: requests payment
- Payment processing → Kafka: reports payment result
- Saga orchestrator → Shipping management: requests shipment
- Shipping management → Kafka: reports shipment
- Saga orchestrator → Kafka: publishes order outcome
- Kafka → Order lifecycle: signals confirmation or cancellation
- Kafka → Order notifications: delivers order outcome
- Order notifications → Notification database: saves notification (evidence: `notification-service/src/main/java/com/ecommerce/notification/service/NotificationService.java`)
