# alaa-hani101/orderflow architecture

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

- Interactive diagram: https://gitdiagram.com/alaa-hani101/orderflow
- Repository: https://github.com/alaa-hani101/orderflow

## Overview

OrderFlow is an educational .NET e-commerce backend. Its main user flow is order creation and order retrieval through REST endpoints, with CQRS handlers separating writes from reads; order-by-ID reads use Redis caching. A separate dashboard query reads a materialized model refreshed by a background worker, which also processes pending orders. SQL Server is the transactional source of truth. The graph reflects README-documented capabilities where implementation details were not sampled; edges cite the README or shown/indexed source, and unsampled wiring is not inferred.

Main entry points: [`OrderFlow.Application/common/IApplicationDbContext.cs`](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/common/IApplicationDbContext.cs) (Database Contract), [`OrderFlow.API/Controllers/OrderController.cs`](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.API/Controllers/OrderController.cs) (Order Endpoints), [`OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs`](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs) (Create Order), [`OrderFlow.Domain/Entities/Order.cs`](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Order.cs) (Order Aggregate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_orderapi["Order Endpoints<br/>[OrderController.cs]"]
  node_dashboardapi["Dashboard Endpoint"]
end

subgraph group_application["CQRS Features"]
  node_create["Create Order"]
  node_validator["Order Validation"]
  node_getorder["Get Order"]
  node_listorders["List Orders<br/>[GetOrdesHandler.cs]"]
  node_dashboardquery["Dashboard Query"]
  node_dbcontract["Database Contract"]
  node_cachecontract["Cache Contract<br/>[ICacheService.cs]"]
  node_readmodel["Dashboard Read Model"]
end

subgraph group_domain["Order Domain"]
  node_customer["Customer<br/>[Customer.cs]"]
  node_orders["Order Aggregate<br/>[Order.cs]"]
  node_orderitem["Order Item<br/>[OrderItem.cs]"]
  node_orderstatus["Order Status<br/>[OrderStatus.cs]"]
end

subgraph group_infrastructure["Infrastructure"]
  node_dbcontext["EF DbContext"]
  node_redisservice["Redis Cache"]
  node_refreshworker["Background Worker"]
  node_pendingprocessor["Pending Processor"]
  node_refreshservice["Dashboard Refresher"]
end

node_apiuser(("API Caller"))
node_sqlserver[("SQL Server")]
node_redis[("Redis Store")]

node_apiuser -->|"calls"| node_orderapi
node_apiuser -->|"requests"| node_dashboardapi
node_orderapi -->|"dispatches"| node_create
node_orderapi -->|"dispatches"| node_getorder
node_orderapi -->|"dispatches"| node_listorders
node_dashboardapi -->|"dispatches"| node_dashboardquery
node_create -->|"writes through"| node_dbcontract
node_create -->|"creates"| node_orders
node_validator -->|"validates"| node_create
node_getorder -->|"reads through"| node_dbcontract
node_getorder -->|"checks and caches"| node_cachecontract
node_listorders -->|"reads through"| node_dbcontract
node_dashboardquery -->|"queries through"| node_dbcontract
node_dbcontext -->|"implements"| node_dbcontract
node_dbcontext -->|"persists data"| node_sqlserver
node_redisservice -->|"implements"| node_cachecontract
node_redisservice -->|"reads and writes"| node_redis
node_refreshworker -->|"invokes"| node_refreshservice
node_refreshworker -->|"invokes"| node_pendingprocessor
node_refreshservice -->|"refreshes via"| node_dbcontext
node_refreshservice -->|"rebuilds"| node_readmodel
node_pendingprocessor -->|"processes via"| node_dbcontext
node_pendingprocessor -->|"invalidates"| node_cachecontract
node_customer -->|"has orders"| node_orders
node_orders -->|"contains"| node_orderitem
node_orders -->|"uses status"| node_orderstatus

click node_customer "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Customer.cs"
click node_orders "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Order.cs"
click node_orderitem "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/OrderItem.cs"
click node_orderstatus "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Enums/OrderStatus.cs"
click node_orderapi "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.API/Controllers/OrderController.cs"
click node_dashboardapi "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.API/Controllers/DashboardController.cs"
click node_create "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs"
click node_validator "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderValidator.cs"
click node_getorder "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/GetOrderById/GetOrderByIdHandler.cs"
click node_listorders "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/GetOrders/GetOrdesHandler.cs"
click node_dashboardquery "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Dashboard/GetDashboardHandler.cs"
click node_dbcontract "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/common/IApplicationDbContext.cs"
click node_cachecontract "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/common/ICacheService.cs"
click node_readmodel "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Dashboard/ReadModels/OrderDashboardReadModel.cs"
click node_dbcontext "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Persistence/ApplicationDbContext.cs"
click node_redisservice "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Persistence/Caching/RedisCacheService.cs"
click node_refreshworker "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/BackgroundJobs/DashboardRefreshBackgroundService.cs"
click node_pendingprocessor "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Services/PendingOrdersProcessor.cs"
click node_refreshservice "https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Services/DashboardRefreshService.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_orderapi,node_dashboardapi toneBlue
class node_create,node_validator,node_getorder,node_listorders,node_dashboardquery,node_dbcontract,node_cachecontract,node_readmodel,node_sqlserver,node_redis toneAmber
class node_customer,node_orders,node_orderitem,node_orderstatus,node_apiuser toneMint
class node_dbcontext,node_redisservice,node_refreshworker,node_pendingprocessor,node_refreshservice toneRose
```

## Components

### REST API

- [Order Endpoints](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.API/Controllers/OrderController.cs): `OrderFlow.API/Controllers/OrderController.cs`
- [Dashboard Endpoint](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.API/Controllers/DashboardController.cs): `OrderFlow.API/Controllers/DashboardController.cs`

### CQRS Features

- [Create Order](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs): `OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs`
- [Order Validation](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderValidator.cs): `OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderValidator.cs`
- [Get Order](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/GetOrderById/GetOrderByIdHandler.cs): `OrderFlow.Application/Features/Orders/GetOrderById/GetOrderByIdHandler.cs`
- [List Orders](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Orders/GetOrders/GetOrdesHandler.cs): `OrderFlow.Application/Features/Orders/GetOrders/GetOrdesHandler.cs`
- [Dashboard Query](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Dashboard/GetDashboardHandler.cs): `OrderFlow.Application/Features/Dashboard/GetDashboardHandler.cs`
- [Database Contract](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/common/IApplicationDbContext.cs): `OrderFlow.Application/common/IApplicationDbContext.cs`
- [Cache Contract](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/common/ICacheService.cs): `OrderFlow.Application/common/ICacheService.cs`
- [Dashboard Read Model](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Application/Features/Dashboard/ReadModels/OrderDashboardReadModel.cs): `OrderFlow.Application/Features/Dashboard/ReadModels/OrderDashboardReadModel.cs`

### Order Domain

- [Customer](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Customer.cs): `OrderFlow.Domain/Entities/Customer.cs`
- [Order Aggregate](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Order.cs): `OrderFlow.Domain/Entities/Order.cs`
- [Order Item](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/OrderItem.cs): `OrderFlow.Domain/Entities/OrderItem.cs`
- [Order Status](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Domain/Entities/Enums/OrderStatus.cs): `OrderFlow.Domain/Entities/Enums/OrderStatus.cs`

### Infrastructure

- [EF DbContext](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Persistence/ApplicationDbContext.cs): `OrderFlow.Infrastructure/Persistence/ApplicationDbContext.cs`
- [Redis Cache](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Persistence/Caching/RedisCacheService.cs): `OrderFlow.Infrastructure/Persistence/Caching/RedisCacheService.cs`
- [Background Worker](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/BackgroundJobs/DashboardRefreshBackgroundService.cs): `OrderFlow.Infrastructure/BackgroundJobs/DashboardRefreshBackgroundService.cs`
- [Pending Processor](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Services/PendingOrdersProcessor.cs): `OrderFlow.Infrastructure/Services/PendingOrdersProcessor.cs`
- [Dashboard Refresher](https://github.com/alaa-hani101/orderflow/blob/master/OrderFlow.Infrastructure/Services/DashboardRefreshService.cs): `OrderFlow.Infrastructure/Services/DashboardRefreshService.cs`

### Other components

- **API Caller**
- **SQL Server**
- **Redis Store**

## Connections

- API Caller → Order Endpoints: calls (evidence: `README.md`)
- API Caller → Dashboard Endpoint: requests (evidence: `README.md`)
- Order Endpoints → Create Order: dispatches (evidence: `OrderFlow.API/Controllers/OrderController.cs`)
- Order Endpoints → Get Order: dispatches (evidence: `OrderFlow.API/Controllers/OrderController.cs`)
- Order Endpoints → List Orders: dispatches (evidence: `OrderFlow.API/Controllers/OrderController.cs`)
- Dashboard Endpoint → Dashboard Query: dispatches (evidence: `OrderFlow.API/Controllers/DashboardController.cs`)
- Create Order → Database Contract: writes through (evidence: `OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs`)
- Create Order → Order Aggregate: creates (evidence: `OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderHandler.cs`)
- Order Validation → Create Order: validates (evidence: `OrderFlow.Application/Features/Orders/CreateOrder/CreateOrderValidator.cs`)
- Get Order → Database Contract: reads through (evidence: `OrderFlow.Application/Features/Orders/GetOrderById/GetOrderByIdHandler.cs`)
- Get Order → Cache Contract: checks and caches (evidence: `OrderFlow.Application/Features/Orders/GetOrderById/GetOrderByIdHandler.cs`)
- List Orders → Database Contract: reads through (evidence: `OrderFlow.Application/Features/Orders/GetOrders/GetOrdesHandler.cs`)
- Dashboard Query → Database Contract: queries through (evidence: `OrderFlow.Application/Features/Dashboard/GetDashboardHandler.cs`)
- EF DbContext → Database Contract: implements (evidence: `OrderFlow.Infrastructure/Persistence/ApplicationDbContext.cs`)
- EF DbContext → SQL Server: persists data (evidence: `README.md`)
- Redis Cache → Cache Contract: implements (evidence: `OrderFlow.Infrastructure/Persistence/DependencyInjection.cs`)
- Redis Cache → Redis Store: reads and writes (evidence: `README.md`)
- Background Worker → Dashboard Refresher: invokes (evidence: `OrderFlow.Infrastructure/BackgroundJobs/DashboardRefreshBackgroundService.cs`)
- Background Worker → Pending Processor: invokes (evidence: `OrderFlow.Infrastructure/BackgroundJobs/DashboardRefreshBackgroundService.cs`)
- Dashboard Refresher → EF DbContext: refreshes via (evidence: `OrderFlow.Infrastructure/Services/DashboardRefreshService.cs`)
- Dashboard Refresher → Dashboard Read Model: rebuilds (evidence: `OrderFlow.Infrastructure/Services/DashboardRefreshService.cs`)
- Pending Processor → EF DbContext: processes via (evidence: `OrderFlow.Infrastructure/Services/PendingOrdersProcessor.cs`)
- Pending Processor → Cache Contract: invalidates (evidence: `OrderFlow.Infrastructure/Services/PendingOrdersProcessor.cs`)
- Customer → Order Aggregate: has orders (evidence: `OrderFlow.Domain/Entities/Customer.cs`)
- Order Aggregate → Order Item: contains (evidence: `OrderFlow.Domain/Entities/Order.cs`)
- Order Aggregate → Order Status: uses status (evidence: `OrderFlow.Domain/Entities/Order.cs`)
