# lylio/distributed-commerce-platform architecture

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

- Interactive diagram: https://gitdiagram.com/lylio/distributed-commerce-platform
- Repository: https://github.com/lylio/distributed-commerce-platform

## Overview

Distributed Commerce Platform is a development storefront backed by separate Order, Inventory, and Payment services. A shopper browses catalogue and live stock, persists a bag, checks out, then polls the order receipt; Kafka choreography reserves stock, simulates payment, and confirms or cancels the order, with compensation on payment failure. The graph includes the major dashboard and monitoring capabilities. Unsampled service internals are represented only where the README documents their behavior; edges reflect shown calls or documented HTTP/event flows.

Main entry points: [`frontend/src/App.tsx`](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/App.tsx) (Storefront UI), [`frontend/src/api.ts`](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/api.ts) (Browser API), [`order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java`](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java) (Create Order), [`order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java`](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java) (Lifecycle Coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Storefront UI<br/>[App.tsx]"]
  node_productart["Product Art<br/>[ProductArt.tsx]"]
  node_cart[("Persisted Bag<br/>[cart.ts]")]
  node_frontendapi["Browser API<br/>[api.ts]"]
  node_orderui["Order Views<br/>[OrdersPage.tsx]"]
  node_monitorui["System Monitor<br/>[SystemMonitor.tsx]"]
end

subgraph group_orders["Order Service"]
  node_orderhttp["Order HTTP API"]
  node_storefrontapi["Storefront API"]
  node_createorder["Create Order"]
  node_orderstate["Order State<br/>[Order.java]"]
  node_orderstore[("Order Database")]
  node_orderworkflow["Lifecycle Coordinator"]
  node_orderevents["Order Event Relay"]
  node_dashboard["Order Dashboard"]
end

subgraph group_inventory["Inventory Service"]
  node_inventoryevents["Inventory Event Consumers"]
  node_reserve["Stock Reservation"]
  node_release["Stock Compensation"]
  node_stockstore[("Inventory Database")]
  node_stockhttp["Stock HTTP API"]
end

subgraph group_payments["Payment Service"]
  node_paymentlistener["Reservation Consumer"]
  node_paymentprocessor["Payment Simulator"]
  node_paymentstore[("Payment Database<br/>[OutboxStore.java]")]
end

subgraph group_operations["Monitoring"]
  node_monitoring["Service Monitoring"]
end

node_shopper(("Shopper"))
node_kafka["Kafka"]

node_shopper -->|"uses"| node_app
node_app -->|"renders"| node_productart
node_app -->|"persists bag"| node_cart
node_app -->|"fetches catalogue"| node_frontendapi
node_app -->|"renders orders"| node_orderui
node_app -->|"routes to"| node_monitorui
node_frontendapi -->|"requests catalogue"| node_storefrontapi
node_frontendapi -->|"submits checkout"| node_storefrontapi
node_frontendapi -->|"requests stock"| node_stockhttp
node_frontendapi -->|"polls orders"| node_orderhttp
node_storefrontapi -->|"creates order"| node_createorder
node_orderhttp -->|"creates order"| node_createorder
node_createorder -->|"saves order"| node_orderstore
node_createorder -->|"publishes event"| node_orderevents
node_orderevents -->|"publishes order-created"| node_kafka
node_kafka -->|"delivers order-created"| node_inventoryevents
node_inventoryevents -.->|"invokes reservation"| node_reserve
node_reserve -->|"locks and updates"| node_stockstore
node_reserve -->|"emits reservation outcome"| node_kafka
node_kafka -->|"delivers reservation"| node_paymentlistener
node_paymentlistener -.->|"starts simulation"| node_paymentprocessor
node_paymentprocessor -->|"persists decision"| node_paymentstore
node_paymentprocessor -->|"publishes payment result"| node_kafka
node_kafka -->|"delivers outcomes"| node_orderworkflow
node_orderworkflow -->|"updates lifecycle"| node_orderstore
node_orderworkflow -->|"emits cancellation"| node_kafka
node_kafka -->|"delivers cancellation"| node_release
node_release -->|"restores stock"| node_stockstore
node_stockhttp -.->|"reads stock"| node_stockstore
node_orderui -.->|"loads dashboard"| node_dashboard
node_dashboard -.->|"exposes order state"| node_monitoring
node_monitorui -.->|"shows health"| node_monitoring

click node_app "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/App.tsx"
click node_productart "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/ProductArt.tsx"
click node_cart "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/cart.ts"
click node_frontendapi "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/api.ts"
click node_orderui "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/OrdersPage.tsx"
click node_orderhttp "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/api/OrderController.java"
click node_storefrontapi "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/StorefrontController.java"
click node_createorder "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java"
click node_orderstate "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/domain/Order.java"
click node_orderstore "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/JpaOrderRepositoryAdapter.java"
click node_orderworkflow "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java"
click node_orderevents "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/messaging/OrderEventPublisherImpl.java"
click node_inventoryevents "https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/messaging/OrderCreatedEventListener.java"
click node_reserve "https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/application/ReserveInventoryService.java"
click node_release "https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/application/ReleaseInventoryService.java"
click node_stockstore "https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/infrastructure/persistence/JpaInventoryRepositoryAdapter.java"
click node_stockhttp "https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/api/InventoryController.java"
click node_paymentlistener "https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/messaging/InventoryReservedEventListener.java"
click node_paymentprocessor "https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/application/PaymentProcessor.java"
click node_paymentstore "https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/infrastructure/outbox/OutboxStore.java"
click node_monitorui "https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/SystemMonitor.tsx"
click node_monitoring "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/monitoring/MonitoringController.java"
click node_dashboard "https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/api/OrderDashboardController.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_app,node_productart,node_cart,node_frontendapi,node_orderui,node_monitorui toneBlue
class node_orderhttp,node_storefrontapi,node_createorder,node_orderstate,node_orderstore,node_orderworkflow,node_orderevents,node_dashboard toneAmber
class node_inventoryevents,node_reserve,node_release,node_stockstore,node_stockhttp toneMint
class node_paymentlistener,node_paymentprocessor,node_paymentstore toneRose
class node_monitoring,node_shopper,node_kafka toneIndigo
```

## Components

### Storefront

- [Storefront UI](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Product Art](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/ProductArt.tsx): `frontend/src/ProductArt.tsx`
- [Persisted Bag](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/cart.ts): `frontend/src/cart.ts`
- [Browser API](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Order Views](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/OrdersPage.tsx): `frontend/src/OrdersPage.tsx`
- [System Monitor](https://github.com/lylio/distributed-commerce-platform/blob/main/frontend/src/SystemMonitor.tsx): `frontend/src/SystemMonitor.tsx`

### Order Service

- [Order HTTP API](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/api/OrderController.java): `order-service/src/main/java/com/lylecommerce/order/api/OrderController.java`
- [Storefront API](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/StorefrontController.java): `order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/StorefrontController.java`
- [Create Order](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java): `order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java`
- [Order State](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/domain/Order.java): `order-service/src/main/java/com/lylecommerce/order/domain/Order.java`
- [Order Database](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/JpaOrderRepositoryAdapter.java): `order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/JpaOrderRepositoryAdapter.java`
- [Lifecycle Coordinator](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java): `order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java`
- [Order Event Relay](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/infrastructure/messaging/OrderEventPublisherImpl.java): `order-service/src/main/java/com/lylecommerce/order/infrastructure/messaging/OrderEventPublisherImpl.java`
- [Order Dashboard](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/api/OrderDashboardController.java): `order-service/src/main/java/com/lylecommerce/order/api/OrderDashboardController.java`

### Inventory Service

- [Inventory Event Consumers](https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/messaging/OrderCreatedEventListener.java): `inventory-service/src/main/java/com/lylecommerce/inventory/messaging/OrderCreatedEventListener.java`
- [Stock Reservation](https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/application/ReserveInventoryService.java): `inventory-service/src/main/java/com/lylecommerce/inventory/application/ReserveInventoryService.java`
- [Stock Compensation](https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/application/ReleaseInventoryService.java): `inventory-service/src/main/java/com/lylecommerce/inventory/application/ReleaseInventoryService.java`
- [Inventory Database](https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/infrastructure/persistence/JpaInventoryRepositoryAdapter.java): `inventory-service/src/main/java/com/lylecommerce/inventory/infrastructure/persistence/JpaInventoryRepositoryAdapter.java`
- [Stock HTTP API](https://github.com/lylio/distributed-commerce-platform/blob/main/inventory-service/src/main/java/com/lylecommerce/inventory/api/InventoryController.java): `inventory-service/src/main/java/com/lylecommerce/inventory/api/InventoryController.java`

### Payment Service

- [Reservation Consumer](https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/messaging/InventoryReservedEventListener.java): `payment-service/src/main/java/com/lylecommerce/payment/messaging/InventoryReservedEventListener.java`
- [Payment Simulator](https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/application/PaymentProcessor.java): `payment-service/src/main/java/com/lylecommerce/payment/application/PaymentProcessor.java`
- [Payment Database](https://github.com/lylio/distributed-commerce-platform/blob/main/payment-service/src/main/java/com/lylecommerce/payment/infrastructure/outbox/OutboxStore.java): `payment-service/src/main/java/com/lylecommerce/payment/infrastructure/outbox/OutboxStore.java`

### Monitoring

- [Service Monitoring](https://github.com/lylio/distributed-commerce-platform/blob/main/order-service/src/main/java/com/lylecommerce/order/monitoring/MonitoringController.java): `order-service/src/main/java/com/lylecommerce/order/monitoring/MonitoringController.java`

### Other components

- **Shopper**
- **Kafka**

## Connections

- Shopper → Storefront UI: uses (evidence: `README.md`)
- Storefront UI → Product Art: renders (evidence: `frontend/src/App.tsx`)
- Storefront UI → Persisted Bag: persists bag (evidence: `frontend/src/App.tsx`)
- Storefront UI → Browser API: fetches catalogue (evidence: `frontend/src/App.tsx`)
- Storefront UI → Order Views: renders orders (evidence: `frontend/src/App.tsx`)
- Storefront UI → System Monitor: routes to (evidence: `frontend/src/App.tsx`)
- Browser API → Storefront API: requests catalogue (evidence: `README.md`)
- Browser API → Storefront API: submits checkout (evidence: `README.md`)
- Browser API → Stock HTTP API: requests stock (evidence: `README.md`)
- Browser API → Order HTTP API: polls orders (evidence: `README.md`)
- Storefront API → Create Order: creates order (evidence: `order-service/src/main/java/com/lylecommerce/order/infrastructure/persistence/StorefrontController.java`)
- Order HTTP API → Create Order: creates order (evidence: `order-service/src/main/java/com/lylecommerce/order/api/OrderController.java`)
- Create Order → Order Database: saves order (evidence: `order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java`)
- Create Order → Order Event Relay: publishes event (evidence: `order-service/src/main/java/com/lylecommerce/order/application/CreateOrderService.java`)
- Order Event Relay → Kafka: publishes order-created (evidence: `README.md`)
- Kafka → Inventory Event Consumers: delivers order-created (evidence: `README.md`)
- Inventory Event Consumers → Stock Reservation: invokes reservation
- Stock Reservation → Inventory Database: locks and updates (evidence: `inventory-service/src/main/java/com/lylecommerce/inventory/application/ReserveInventoryService.java`)
- Stock Reservation → Kafka: emits reservation outcome (evidence: `README.md`)
- Kafka → Reservation Consumer: delivers reservation (evidence: `README.md`)
- Reservation Consumer → Payment Simulator: starts simulation
- Payment Simulator → Payment Database: persists decision (evidence: `README.md`)
- Payment Simulator → Kafka: publishes payment result (evidence: `README.md`)
- Kafka → Lifecycle Coordinator: delivers outcomes (evidence: `README.md`)
- Lifecycle Coordinator → Order Database: updates lifecycle (evidence: `order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java`)
- Lifecycle Coordinator → Kafka: emits cancellation (evidence: `order-service/src/main/java/com/lylecommerce/order/application/OrderWorkflowService.java`)
- Kafka → Stock Compensation: delivers cancellation (evidence: `README.md`)
- Stock Compensation → Inventory Database: restores stock (evidence: `inventory-service/src/main/java/com/lylecommerce/inventory/application/ReleaseInventoryService.java`)
- Stock HTTP API → Inventory Database: reads stock
- Order Views → Order Dashboard: loads dashboard
- Order Dashboard → Service Monitoring: exposes order state
- System Monitor → Service Monitoring: shows health
