# markwinap/be_dotnet_template_saga architecture

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

- Interactive diagram: https://gitdiagram.com/markwinap/be_dotnet_template_saga
- Repository: https://github.com/markwinap/be_dotnet_template_saga

## Overview

OrderService is a .NET order-management API. Authenticated clients create, list, retrieve, submit, and delete customer-scoped orders; submission persists the state change, publishes an event, and invokes saga orchestration. The graph reflects sampled API, handler, repository, and publisher code plus README-documented capabilities; saga internals and some infrastructure wiring were not sampled, so their internal relationships are omitted.

Main entry points: [`OrderService.Api/Program.cs`](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Api/Program.cs) (Minimal API), [`OrderService.Infrastructure/Data/Repositories/OrderRepository.cs`](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Data/Repositories/OrderRepository.cs) (Order repository), [`OrderService.Application/Commands/SubmitOrder/SubmitOrderCommandHandler.cs`](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/SubmitOrder/SubmitOrderCommandHandler.cs) (Submit order), [`OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs`](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs) (Create order)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API access"]
  node_api["Minimal API<br/>[Program.cs]"]
  node_auth["JWT auth<br/>[Program.cs]"]
end

subgraph group_application["Order workflows"]
  node_orders["Order handlers"]
  node_list["List orders"]
  node_get["Get order"]
  node_create["Create order"]
  node_submit["Submit order"]
  node_delete["Delete order"]
  node_cachebehavior["Cache behavior<br/>[CachingBehavior.cs]"]
  node_validation["Validation"]
end

subgraph group_domain["Order domain"]
  node_domain["Order model<br/>[Order.cs]"]
  node_events["Order events"]
end

subgraph group_infrastructure["Infrastructure"]
  node_repository["Order repository<br/>[OrderRepository.cs]"]
  node_database[("Order database<br/>[OrderDbContext.cs]")]
  node_redis[("Redis cache")]
  node_publisher["Service Bus publisher"]
  node_saga["Saga orchestration"]
end

node_client(("API client"))
node_servicebus["Azure Service Bus"]

node_client -->|"sends requests"| node_api
node_api -->|"validates tokens"| node_auth
node_api -->|"dispatches query"| node_list
node_api -->|"dispatches query"| node_get
node_api -->|"dispatches command"| node_create
node_api -->|"dispatches command"| node_submit
node_api -->|"dispatches command"| node_delete
node_list -->|"reads orders"| node_repository
node_get -->|"reads order"| node_repository
node_create -->|"creates order"| node_domain
node_create -->|"saves order"| node_repository
node_create -->|"invalidates list"| node_redis
node_submit -->|"loads and saves"| node_repository
node_submit -->|"invalidates entries"| node_redis
node_submit -->|"publishes event"| node_publisher
node_submit -->|"starts orchestration"| node_saga
node_delete -->|"loads and removes"| node_repository
node_delete -->|"invalidates entries"| node_redis
node_repository -->|"queries and saves"| node_database
node_publisher -->|"sends message"| node_servicebus
node_cachebehavior -->|"reads and writes"| node_redis

click node_api "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Api/Program.cs"
click node_auth "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Api/Program.cs"
click node_orders "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs"
click node_list "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Queries/ListOrders/ListOrdersQueryHandler.cs"
click node_get "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Queries/GetOrderById/GetOrderByIdQueryHandler.cs"
click node_create "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs"
click node_submit "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/SubmitOrder/SubmitOrderCommandHandler.cs"
click node_delete "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/DeleteOrder/DeleteOrderCommandHandler.cs"
click node_cachebehavior "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Common/Behaviors/CachingBehavior.cs"
click node_validation "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Common/Behaviors/ValidationBehavior.cs"
click node_domain "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Domain/Entities/Order.cs"
click node_events "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Domain/Events/OrderSubmittedEvent.cs"
click node_repository "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Data/Repositories/OrderRepository.cs"
click node_database "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Data/OrderDbContext.cs"
click node_redis "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Caching/RedisCacheService.cs"
click node_publisher "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Messaging/AzureServiceBusPublisher.cs"
click node_saga "https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Saga/OrderProcessingSaga.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_api,node_auth,node_client toneBlue
class node_orders,node_list,node_get,node_create,node_submit,node_delete,node_cachebehavior,node_validation toneAmber
class node_domain,node_events toneMint
class node_repository,node_database,node_redis,node_publisher,node_saga toneRose
class node_servicebus toneIndigo
```

## Components

### API access

- [Minimal API](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Api/Program.cs): `OrderService.Api/Program.cs`
- [JWT auth](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Api/Program.cs): `OrderService.Api/Program.cs`

### Order workflows

- [Order handlers](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs): `OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs`
- [List orders](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Queries/ListOrders/ListOrdersQueryHandler.cs): `OrderService.Application/Queries/ListOrders/ListOrdersQueryHandler.cs`
- [Get order](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Queries/GetOrderById/GetOrderByIdQueryHandler.cs): `OrderService.Application/Queries/GetOrderById/GetOrderByIdQueryHandler.cs`
- [Create order](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs): `OrderService.Application/Commands/CreateOrder/CreateOrderCommandHandler.cs`
- [Submit order](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/SubmitOrder/SubmitOrderCommandHandler.cs): `OrderService.Application/Commands/SubmitOrder/SubmitOrderCommandHandler.cs`
- [Delete order](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Commands/DeleteOrder/DeleteOrderCommandHandler.cs): `OrderService.Application/Commands/DeleteOrder/DeleteOrderCommandHandler.cs`
- [Cache behavior](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Common/Behaviors/CachingBehavior.cs): `OrderService.Application/Common/Behaviors/CachingBehavior.cs`
- [Validation](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Application/Common/Behaviors/ValidationBehavior.cs): `OrderService.Application/Common/Behaviors/ValidationBehavior.cs`

### Order domain

- [Order model](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Domain/Entities/Order.cs): `OrderService.Domain/Entities/Order.cs`
- [Order events](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Domain/Events/OrderSubmittedEvent.cs): `OrderService.Domain/Events/OrderSubmittedEvent.cs`

### Infrastructure

- [Order repository](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Data/Repositories/OrderRepository.cs): `OrderService.Infrastructure/Data/Repositories/OrderRepository.cs`
- [Order database](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Data/OrderDbContext.cs): `OrderService.Infrastructure/Data/OrderDbContext.cs`
- [Redis cache](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Caching/RedisCacheService.cs): `OrderService.Infrastructure/Caching/RedisCacheService.cs`
- [Service Bus publisher](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Messaging/AzureServiceBusPublisher.cs): `OrderService.Infrastructure/Messaging/AzureServiceBusPublisher.cs`
- [Saga orchestration](https://github.com/markwinap/be_dotnet_template_saga/blob/main/OrderService.Infrastructure/Saga/OrderProcessingSaga.cs): `OrderService.Infrastructure/Saga/OrderProcessingSaga.cs`

### Other components

- **API client**
- **Azure Service Bus**

## Connections

- API client → Minimal API: sends requests
- Minimal API → JWT auth: validates tokens
- Minimal API → List orders: dispatches query
- Minimal API → Get order: dispatches query
- Minimal API → Create order: dispatches command
- Minimal API → Submit order: dispatches command
- Minimal API → Delete order: dispatches command
- List orders → Order repository: reads orders
- Get order → Order repository: reads order
- Create order → Order model: creates order
- Create order → Order repository: saves order
- Create order → Redis cache: invalidates list
- Submit order → Order repository: loads and saves
- Submit order → Redis cache: invalidates entries
- Submit order → Service Bus publisher: publishes event
- Submit order → Saga orchestration: starts orchestration
- Delete order → Order repository: loads and removes
- Delete order → Redis cache: invalidates entries
- Order repository → Order database: queries and saves
- Service Bus publisher → Azure Service Bus: sends message
- Cache behavior → Redis cache: reads and writes
