# genocs/clean-architecture-template architecture

> Architecture diagram of the GitHub repository genocs/clean-architecture-template, 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/genocs/clean-architecture-template
- Repository: https://github.com/genocs/clean-architecture-template

## Overview

This is a Clean Architecture/DDD .NET template for a customer-account service. Its principal workflow is a client request entering a versioned Web API controller, invoking an application use case, and returning a presenter-built response; the domain models customers, accounts, and money transactions. The tree and sampled controllers support the API-to-use-case wiring, while README capabilities establish the database, broker, and background-worker options. Use-case internals and most worker/broker wiring were not sampled, so those connections are intentionally limited.

Main entry points: [`src/template/src/Application/UseCases`](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/UseCases) (Account use cases), [`src/template/src/Application/Repositories`](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Repositories) (Repository interfaces), [`src/template/src/WebApi/Program.cs`](https://github.com/genocs/clean-architecture-template/blob/main/src/template/src/WebApi/Program.cs) (Versioned REST API), [`src/template/src/WebApi/UseCases/V1`](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V1) (Account endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Web presentation"]
  node_webapi["Versioned REST API<br/>[Program.cs]"]
  node_account_routes["Account endpoints"]
  node_customer_routes["Customer endpoints"]
  node_account_v2["Account API v2"]
  node_presenters["Response presenters"]
end

subgraph group_application["Application workflows"]
  node_usecases["Account use cases"]
  node_boundaries["Use-case contracts"]
  node_repositories["Repository interfaces"]
  node_services["Application services"]
end

subgraph group_domain["Domain model"]
  node_domain_models["Customers and accounts"]
  node_domain_values["Money and value objects"]
end

subgraph group_infrastructure["Persistence and integrations"]
  node_inmemory[("In-memory storage")]
  node_mongodb[("MongoDB storage")]
  node_sqlserver[("SQL Server storage")]
  node_webclients["External API clients"]
end

subgraph group_messaging["Async messaging"]
  node_contracts["Commands and events"]
  node_bus_clients["Broker client options"]
  node_worker["Background worker<br/>[Program.cs]"]
  node_handlers["Message handlers"]
end

node_client(("API client"))
node_external_services(("Backend services"))
node_brokers["Message brokers"]

node_client -->|"sends request"| node_webapi
node_webapi -->|"routes requests"| node_account_routes
node_webapi -->|"routes requests"| node_customer_routes
node_account_routes -->|"executes use case"| node_usecases
node_customer_routes -->|"executes use case"| node_usecases
node_account_v2 -->|"executes use case"| node_usecases
node_account_routes -->|"returns view model"| node_presenters
node_customer_routes -->|"returns view model"| node_presenters
node_account_v2 -->|"returns view model"| node_presenters
node_usecases -->|"uses contracts"| node_boundaries
node_usecases -.->|"repository abstractions"| node_repositories
node_domain_models -->|"uses values"| node_domain_values
node_repositories -.->|"implemented by"| node_inmemory
node_repositories -.->|"implemented by"| node_mongodb
node_repositories -.->|"implemented by"| node_sqlserver
node_services -.->|"implemented by"| node_webclients
node_webclients -.->|"calls APIs"| node_external_services
node_worker -->|"hosts handlers"| node_handlers
node_handlers -.->|"handles messages"| node_contracts
node_worker -.->|"configures broker"| node_bus_clients
node_bus_clients -.->|"connects to"| node_brokers
node_handlers -.->|"receives messages"| node_brokers

click node_webapi "https://github.com/genocs/clean-architecture-template/blob/main/src/template/src/WebApi/Program.cs"
click node_account_routes "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V1"
click node_customer_routes "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V1"
click node_account_v2 "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V2/GetAccountDetails"
click node_presenters "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/Presenters"
click node_usecases "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/UseCases"
click node_boundaries "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Boundaries"
click node_repositories "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Repositories"
click node_services "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Services"
click node_domain_models "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Domain/Accounts"
click node_domain_values "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Domain/ValueObjects"
click node_inmemory "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/InMemory"
click node_mongodb "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/MongoDb"
click node_sqlserver "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/SQLServer"
click node_webclients "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/WebApiClient/ExternalServices"
click node_contracts "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Contracts"
click node_bus_clients "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure"
click node_worker "https://github.com/genocs/clean-architecture-template/blob/main/src/template/src/Worker/Program.cs"
click node_handlers "https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Worker"

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_webapi,node_account_routes,node_customer_routes,node_account_v2,node_presenters,node_client toneBlue
class node_usecases,node_boundaries,node_repositories,node_services toneAmber
class node_domain_models,node_domain_values toneMint
class node_inmemory,node_mongodb,node_sqlserver,node_webclients toneRose
class node_contracts,node_bus_clients,node_worker,node_handlers,node_external_services,node_brokers toneIndigo
```

## Components

### Web presentation

- [Versioned REST API](https://github.com/genocs/clean-architecture-template/blob/main/src/template/src/WebApi/Program.cs): `src/template/src/WebApi/Program.cs`
- [Account endpoints](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V1): `src/template/src/WebApi/UseCases/V1`
- [Customer endpoints](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V1): `src/template/src/WebApi/UseCases/V1`
- [Account API v2](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/WebApi/UseCases/V2/GetAccountDetails): `src/template/src/WebApi/UseCases/V2/GetAccountDetails`
- [Response presenters](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/Presenters): `src/template/src/Infrastructure/PersistenceLayer/Presenters`

### Application workflows

- [Account use cases](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/UseCases): `src/template/src/Application/UseCases`
- [Use-case contracts](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Boundaries): `src/template/src/Application/Boundaries`
- [Repository interfaces](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Repositories): `src/template/src/Application/Repositories`
- [Application services](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Application/Services): `src/template/src/Application/Services`

### Domain model

- [Customers and accounts](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Domain/Accounts): `src/template/src/Domain/Accounts`
- [Money and value objects](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Domain/ValueObjects): `src/template/src/Domain/ValueObjects`

### Persistence and integrations

- [In-memory storage](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/InMemory): `src/template/src/Infrastructure/PersistenceLayer/InMemory`
- [MongoDB storage](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/MongoDb): `src/template/src/Infrastructure/PersistenceLayer/MongoDb`
- [SQL Server storage](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/PersistenceLayer/SQLServer): `src/template/src/Infrastructure/PersistenceLayer/SQLServer`
- [External API clients](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure/WebApiClient/ExternalServices): `src/template/src/Infrastructure/WebApiClient/ExternalServices`

### Async messaging

- [Commands and events](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Contracts): `src/template/src/Contracts`
- [Broker client options](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Infrastructure): `src/template/src/Infrastructure`
- [Background worker](https://github.com/genocs/clean-architecture-template/blob/main/src/template/src/Worker/Program.cs): `src/template/src/Worker/Program.cs`
- [Message handlers](https://github.com/genocs/clean-architecture-template/tree/main/src/template/src/Worker): `src/template/src/Worker`

### Other components

- **API client**
- **Backend services**
- **Message brokers**

## Connections

- API client → Versioned REST API: sends request
- Versioned REST API → Account endpoints: routes requests
- Versioned REST API → Customer endpoints: routes requests
- Account endpoints → Account use cases: executes use case
- Customer endpoints → Account use cases: executes use case
- Account API v2 → Account use cases: executes use case
- Account endpoints → Response presenters: returns view model
- Customer endpoints → Response presenters: returns view model
- Account API v2 → Response presenters: returns view model
- Account use cases → Use-case contracts: uses contracts
- Account use cases → Repository interfaces: repository abstractions
- Customers and accounts → Money and value objects: uses values
- Repository interfaces → In-memory storage: implemented by
- Repository interfaces → MongoDB storage: implemented by
- Repository interfaces → SQL Server storage: implemented by
- Application services → External API clients: implemented by
- External API clients → Backend services: calls APIs
- Background worker → Message handlers: hosts handlers
- Message handlers → Commands and events: handles messages
- Background worker → Broker client options: configures broker
- Broker client options → Message brokers: connects to
- Message handlers → Message brokers: receives messages
