# hayko588/e-commerce architecture

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

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

## Overview

CommerceCore is a microservice-based commerce backend. The principal workflow accepts an order, checks catalog pricing and stock, then coordinates payment and order state through messaging; catalog, payment, and notification APIs also expose reads. The tree documents the services and contracts, but the README provides no capability narrative, and the saga and most consumers were not sampled. Accordingly, cross-service event links are shown as unverified rather than asserting detailed choreography.

Main entry points: [`src/Services/CommerceCore.Ordering.Infrastructure/Messaging/OrderSaga.cs`](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/Messaging/OrderSaga.cs) (Order saga), [`src/Gateway/CommerceCore.Gateway/Program.cs`](https://github.com/hayko588/e-commerce/blob/master/src/Gateway/CommerceCore.Gateway/Program.cs) (Gateway routing), [`src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs`](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs) (Orders API), [`src/Services/CommerceCore.Ordering.Application/Commands/CreateOrder.cs`](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Application/Commands/CreateOrder.cs) (Order creation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["API Gateway"]
  node_gateway_app["Gateway routing<br/>[Program.cs]"]
end

subgraph group_catalog["Catalog and Stock"]
  node_catalog_api["Product API"]
  node_internal_prices["Internal prices API"]
  node_product_reads["Product reads"]
  node_catalog_db[("Catalog data")]
  node_catalog_domain["Products and stock<br/>[Product.cs]"]
  node_stock_reservation["Stock reservation"]
  node_catalog_consumers["Stock message consumers"]
end

subgraph group_ordering["Order Management"]
  node_orders_api["Orders API"]
  node_create_order["Order creation<br/>[CreateOrder.cs]"]
  node_catalog_client["Catalog HTTP client"]
  node_order_domain["Order lifecycle<br/>[Order.cs]"]
  node_order_reads["Order queries"]
  node_order_store[("Order data<br/>[OrderDbContext.cs]")]
  node_order_saga["Order saga<br/>[OrderSaga.cs]"]
end

subgraph group_payments["Payments"]
  node_payment_consumer["Charge consumer"]
  node_payment_processor["Payment processing<br/>[Payments.cs]"]
  node_payment_gateway["Payment gateway"]
  node_payment_store[("Payment data")]
  node_payments_api["Payment read API"]
end

subgraph group_notifications["Notifications"]
  node_notification_consumers["Event consumers"]
  node_notification_service["Notification service<br/>[Notifications.cs]"]
  node_notification_sender["Notification sender"]
  node_notification_store[("Notification data")]
  node_notifications_api["Notification reads"]
end

node_client(("Commerce client"))
node_contracts["Message contracts<br/>[Messages.cs]"]

node_client -.->|"sends requests"| node_gateway_app
node_gateway_app -.->|"routes requests"| node_orders_api
node_gateway_app -.->|"routes requests"| node_catalog_api
node_orders_api -->|"dispatches commands"| node_create_order
node_orders_api -->|"dispatches queries"| node_order_reads
node_create_order -.->|"checks catalog"| node_catalog_client
node_create_order -.->|"creates orders"| node_order_domain
node_catalog_api -.->|"reads products"| node_product_reads
node_internal_prices -.->|"reads prices"| node_product_reads
node_product_reads -->|"queries data"| node_catalog_db
node_catalog_domain -->|"persists entities"| node_catalog_db
node_stock_reservation -->|"uses stock entities"| node_catalog_domain
node_stock_reservation -.->|"handles reservations"| node_catalog_consumers
node_catalog_consumers -.->|"consumes messages"| node_contracts
node_order_domain -->|"persists orders"| node_order_store
node_order_reads -.->|"loads orders"| node_order_store
node_order_saga -.->|"coordinates messages"| node_contracts
node_order_saga -.->|"requests charges"| node_payment_consumer
node_payment_consumer -.->|"processes charges"| node_payment_processor
node_payment_processor -->|"charges payment"| node_payment_gateway
node_payment_processor -.->|"saves payment"| node_payment_store
node_payments_api -.->|"reads payment"| node_payment_store
node_order_saga -.->|"publishes events"| node_notification_consumers
node_notification_consumers -.->|"handles events"| node_notification_service
node_notification_service -->|"sends notices"| node_notification_sender
node_notification_service -.->|"records notices"| node_notification_store
node_notifications_api -.->|"reads notices"| node_notification_store

click node_gateway_app "https://github.com/hayko588/e-commerce/blob/master/src/Gateway/CommerceCore.Gateway/Program.cs"
click node_catalog_api "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Api/Controllers/ProductsControllers.cs"
click node_internal_prices "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Api/Controllers/InternalPricesController.cs"
click node_product_reads "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Persistence/ProductReadService.cs"
click node_catalog_db "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Persistence/CatalogDbContext.cs"
click node_catalog_domain "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Domain/Product.cs"
click node_stock_reservation "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Application/Stock/StockReservationService.cs"
click node_catalog_consumers "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Messaging/ReserveStockConsumer.cs"
click node_orders_api "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs"
click node_create_order "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Application/Commands/CreateOrder.cs"
click node_catalog_client "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/Catalog/HttpProductCatalogClient.cs"
click node_order_domain "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Domain/Order.cs"
click node_order_reads "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Application/DTOs/GetOrderByIdQueryHandler.cs"
click node_order_store "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/OrderDbContext.cs"
click node_order_saga "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/Messaging/OrderSaga.cs"
click node_payment_consumer "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Messaging/ChargePaymentConsumer.cs"
click node_payment_processor "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Application/Payments.cs"
click node_payment_gateway "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Gateway/SimulatedPaymentGateway.cs"
click node_payment_store "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Persistence/PaymentsDbContext.cs"
click node_payments_api "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Api/Controllers/PaymentsController.cs"
click node_notification_consumers "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Messaging/NotificationConsumers.cs"
click node_notification_service "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Application/Notifications.cs"
click node_notification_sender "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Sending/LoggingNotificationSender.cs"
click node_notification_store "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Persistence/NotificationsDbContext.cs"
click node_notifications_api "https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Api/Controllers/NotificationsController.cs"
click node_contracts "https://github.com/hayko588/e-commerce/blob/master/src/BuildingBlocks/CommerceCore.Contracts/Messages.cs"

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_app,node_client toneBlue
class node_catalog_api,node_internal_prices,node_product_reads,node_catalog_db,node_catalog_domain,node_stock_reservation,node_catalog_consumers toneAmber
class node_orders_api,node_create_order,node_catalog_client,node_order_domain,node_order_reads,node_order_store,node_order_saga toneMint
class node_payment_consumer,node_payment_processor,node_payment_gateway,node_payment_store,node_payments_api toneRose
class node_notification_consumers,node_notification_service,node_notification_sender,node_notification_store,node_notifications_api toneIndigo
class node_contracts toneTeal
```

## Components

### API Gateway

- [Gateway routing](https://github.com/hayko588/e-commerce/blob/master/src/Gateway/CommerceCore.Gateway/Program.cs): `src/Gateway/CommerceCore.Gateway/Program.cs`

### Catalog and Stock

- [Product API](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Api/Controllers/ProductsControllers.cs): `src/Services/CommerceCore.Catalog.Api/Controllers/ProductsControllers.cs`
- [Internal prices API](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Api/Controllers/InternalPricesController.cs): `src/Services/CommerceCore.Catalog.Api/Controllers/InternalPricesController.cs`
- [Product reads](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Persistence/ProductReadService.cs): `src/Services/CommerceCore.Catalog.Infrastructure/Persistence/ProductReadService.cs`
- [Catalog data](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Persistence/CatalogDbContext.cs): `src/Services/CommerceCore.Catalog.Infrastructure/Persistence/CatalogDbContext.cs`
- [Products and stock](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Domain/Product.cs): `src/Services/CommerceCore.Catalog.Domain/Product.cs`
- [Stock reservation](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Application/Stock/StockReservationService.cs): `src/Services/CommerceCore.Catalog.Application/Stock/StockReservationService.cs`
- [Stock message consumers](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Catalog.Infrastructure/Messaging/ReserveStockConsumer.cs): `src/Services/CommerceCore.Catalog.Infrastructure/Messaging/ReserveStockConsumer.cs`

### Order Management

- [Orders API](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs): `src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs`
- [Order creation](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Application/Commands/CreateOrder.cs): `src/Services/CommerceCore.Ordering.Application/Commands/CreateOrder.cs`
- [Catalog HTTP client](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/Catalog/HttpProductCatalogClient.cs): `src/Services/CommerceCore.Ordering.Infrastructure/Catalog/HttpProductCatalogClient.cs`
- [Order lifecycle](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Domain/Order.cs): `src/Services/CommerceCore.Ordering.Domain/Order.cs`
- [Order queries](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Application/DTOs/GetOrderByIdQueryHandler.cs): `src/Services/CommerceCore.Ordering.Application/DTOs/GetOrderByIdQueryHandler.cs`
- [Order data](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/OrderDbContext.cs): `src/Services/CommerceCore.Ordering.Infrastructure/OrderDbContext.cs`
- [Order saga](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Ordering.Infrastructure/Messaging/OrderSaga.cs): `src/Services/CommerceCore.Ordering.Infrastructure/Messaging/OrderSaga.cs`

### Payments

- [Charge consumer](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Messaging/ChargePaymentConsumer.cs): `src/Services/CommerceCore.Payments.Infrastructure/Messaging/ChargePaymentConsumer.cs`
- [Payment processing](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Application/Payments.cs): `src/Services/CommerceCore.Payments.Application/Payments.cs`
- [Payment gateway](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Gateway/SimulatedPaymentGateway.cs): `src/Services/CommerceCore.Payments.Infrastructure/Gateway/SimulatedPaymentGateway.cs`
- [Payment data](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Infrastructure/Persistence/PaymentsDbContext.cs): `src/Services/CommerceCore.Payments.Infrastructure/Persistence/PaymentsDbContext.cs`
- [Payment read API](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Payments.Api/Controllers/PaymentsController.cs): `src/Services/CommerceCore.Payments.Api/Controllers/PaymentsController.cs`

### Notifications

- [Event consumers](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Messaging/NotificationConsumers.cs): `src/Services/CommerceCore.Notifications.Infrastructure/Messaging/NotificationConsumers.cs`
- [Notification service](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Application/Notifications.cs): `src/Services/CommerceCore.Notifications.Application/Notifications.cs`
- [Notification sender](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Sending/LoggingNotificationSender.cs): `src/Services/CommerceCore.Notifications.Infrastructure/Sending/LoggingNotificationSender.cs`
- [Notification data](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Infrastructure/Persistence/NotificationsDbContext.cs): `src/Services/CommerceCore.Notifications.Infrastructure/Persistence/NotificationsDbContext.cs`
- [Notification reads](https://github.com/hayko588/e-commerce/blob/master/src/Services/CommerceCore.Notifications.Api/Controllers/NotificationsController.cs): `src/Services/CommerceCore.Notifications.Api/Controllers/NotificationsController.cs`

### Other components

- **Commerce client**
- [Message contracts](https://github.com/hayko588/e-commerce/blob/master/src/BuildingBlocks/CommerceCore.Contracts/Messages.cs): `src/BuildingBlocks/CommerceCore.Contracts/Messages.cs`

## Connections

- Commerce client → Gateway routing: sends requests
- Gateway routing → Orders API: routes requests
- Gateway routing → Product API: routes requests
- Orders API → Order creation: dispatches commands (evidence: `src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs`)
- Orders API → Order queries: dispatches queries (evidence: `src/Services/CommerceCore.Ordering.Api/Controllers/OrdersController.cs`)
- Order creation → Catalog HTTP client: checks catalog
- Order creation → Order lifecycle: creates orders
- Product API → Product reads: reads products
- Internal prices API → Product reads: reads prices
- Product reads → Catalog data: queries data (evidence: `src/Services/CommerceCore.Catalog.Infrastructure/Persistence/ProductReadService.cs`)
- Products and stock → Catalog data: persists entities (evidence: `src/Services/CommerceCore.Catalog.Infrastructure/Persistence/CatalogDbContext.cs`)
- Stock reservation → Products and stock: uses stock entities (evidence: `src/Services/CommerceCore.Catalog.Application/Stock/StockReservationService.cs`)
- Stock reservation → Stock message consumers: handles reservations
- Stock message consumers → Message contracts: consumes messages
- Order lifecycle → Order data: persists orders (evidence: `src/Services/CommerceCore.Ordering.Infrastructure/OrderDbContext.cs`)
- Order queries → Order data: loads orders
- Order saga → Message contracts: coordinates messages
- Order saga → Charge consumer: requests charges
- Charge consumer → Payment processing: processes charges
- Payment processing → Payment gateway: charges payment (evidence: `src/Services/CommerceCore.Payments.Application/Payments.cs`)
- Payment processing → Payment data: saves payment (evidence: `src/Services/CommerceCore.Payments.Infrastructure/Persistence/PaymentsDbContext.cs`)
- Payment read API → Payment data: reads payment
- Order saga → Event consumers: publishes events
- Event consumers → Notification service: handles events
- Notification service → Notification sender: sends notices (evidence: `src/Services/CommerceCore.Notifications.Application/Notifications.cs`)
- Notification service → Notification data: records notices (evidence: `src/Services/CommerceCore.Notifications.Infrastructure/Persistence/NotificationsDbContext.cs`)
- Notification reads → Notification data: reads notices
