# evolutionary-architecture/evolutionary-architecture-by-example architecture

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

- Interactive diagram: https://gitdiagram.com/evolutionary-architecture/evolutionary-architecture-by-example
- Repository: https://github.com/evolutionary-architecture/evolutionary-architecture-by-example

## Overview

This repository is an educational .NET fitness-domain application presented as an architectural evolution across four chapters, not one deployable system. Its examples progress from a simple vertical-slice monolith, through separated modules, to microservice extraction and tactical domain-driven design. The tree documents contracts, passes, offers, and monthly registration reporting as domain capabilities; sampled code confirms contract signing, persistence abstractions, and event publication. Many feature implementations and chapter-to-chapter connections are represented only by paths or README descriptions, so those relationships are left unverified rather than inferred.

Main entry points: [`Chapter-1-initial-architecture/Src/Fitnet/Program.cs`](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Program.cs) (Vertical-slice monolith), [`Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs`](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs) (Command handlers), [`Chapter-2-modules-separation/Src/Fitnet/Program.cs`](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Fitnet/Program.cs) (Separated modules), [`Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs`](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs) (Microservice extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evolution["Architecture Evolution"]
  node_chapter1["Vertical-slice monolith<br/>[Program.cs]"]
  node_chapter2["Separated modules<br/>[Program.cs]"]
  node_chapter3["Microservice extraction<br/>[Program.cs]"]
  node_chapter4["Tactical DDD<br/>[Program.cs]"]
end

subgraph group_features["Fitness Features"]
  node_chapter1_contracts["Contract workflows"]
  node_chapter1_passes["Pass lifecycle"]
  node_chapter1_offers["Offer preparation"]
  node_chapter1_reports["Monthly report"]
  node_event_bus["In-memory event bus"]
end

subgraph group_contracts["Contracts Service"]
  node_contracts_api["Contracts API"]
  node_contracts_application["Command handlers"]
  node_contracts_core["Contract domain<br/>[Contract.cs]"]
  node_contracts_infrastructure["Contracts persistence"]
  node_chapter3_contract_handler["Contract command handler"]
  node_binding_contract["Binding contracts<br/>[BindingContract.cs]"]
  node_signature["Signature validation<br/>[Signature.cs]"]
  node_binding_repository["Binding contract repository"]
  node_signed_event["Contract signed event"]
end

node_fitness_users(("Fitness users"))

node_chapter1 -->|"registers"| node_chapter1_contracts
node_chapter1 -->|"registers"| node_chapter1_passes
node_chapter1 -->|"registers"| node_chapter1_offers
node_chapter1 -->|"registers"| node_chapter1_reports
node_chapter1 -->|"configures"| node_event_bus
node_chapter1 -.->|"evolves into"| node_chapter2
node_chapter2 -.->|"registers"| node_contracts_api
node_chapter2 -.->|"evolves into"| node_chapter3
node_chapter3 -.->|"hosts"| node_chapter3_contract_handler
node_chapter3 -.->|"evolves into"| node_chapter4
node_chapter4 -.->|"registers"| node_contracts_application
node_contracts_application -->|"validates with"| node_signature
node_contracts_application -->|"writes through"| node_binding_repository
node_binding_repository -->|"returns"| node_binding_contract
node_contracts_application -.->|"publishes"| node_signed_event

click node_chapter1 "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Program.cs"
click node_chapter1_contracts "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Contracts/PrepareContract/PrepareContractEndpoint.cs"
click node_chapter1_passes "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Passes/RegisterPass/RegisterEndpoint.cs"
click node_chapter1_offers "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Offers/Prepare/PassExpiredEventHandler.cs"
click node_chapter1_reports "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Reports/GenerateNewPassesRegistrationsPerMonthReport/GenerateNewPassesPerMonthReportEndpoint.cs"
click node_event_bus "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Common/Events/EventBus/InMemory/InMemoryEventBus.cs"
click node_chapter2 "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Fitnet/Program.cs"
click node_contracts_api "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Api/Prepare/PrepareContractEndpoint.cs"
click node_contracts_application "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs"
click node_contracts_core "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Core/Contract.cs"
click node_contracts_infrastructure "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Infrastructure/Database/Repositories/ContractsRepository.cs"
click node_chapter3 "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs"
click node_chapter3_contract_handler "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs"
click node_chapter4 "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs"
click node_binding_contract "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/BindingContract.cs"
click node_signature "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/SignContract/Signatures/Signature.cs"
click node_binding_repository "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/IBindingContractsRepository.cs"
click node_signed_event "https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.IntegrationEvents/ContractSignedEvent.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_chapter1,node_chapter2,node_chapter3,node_chapter4,node_fitness_users toneBlue
class node_chapter1_contracts,node_chapter1_passes,node_chapter1_offers,node_chapter1_reports,node_event_bus toneAmber
class node_contracts_api,node_contracts_application,node_contracts_core,node_contracts_infrastructure,node_chapter3_contract_handler,node_binding_contract,node_signature,node_binding_repository,node_signed_event toneMint
```

## Components

### Architecture Evolution

- [Vertical-slice monolith](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Program.cs): `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`
- [Separated modules](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Fitnet/Program.cs): `Chapter-2-modules-separation/Src/Fitnet/Program.cs`
- [Microservice extraction](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs): `Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs`
- [Tactical DDD](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs): `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts/Program.cs`

### Fitness Features

- [Contract workflows](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Contracts/PrepareContract/PrepareContractEndpoint.cs): `Chapter-1-initial-architecture/Src/Fitnet/Contracts/PrepareContract/PrepareContractEndpoint.cs`
- [Pass lifecycle](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Passes/RegisterPass/RegisterEndpoint.cs): `Chapter-1-initial-architecture/Src/Fitnet/Passes/RegisterPass/RegisterEndpoint.cs`
- [Offer preparation](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Offers/Prepare/PassExpiredEventHandler.cs): `Chapter-1-initial-architecture/Src/Fitnet/Offers/Prepare/PassExpiredEventHandler.cs`
- [Monthly report](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Reports/GenerateNewPassesRegistrationsPerMonthReport/GenerateNewPassesPerMonthReportEndpoint.cs): `Chapter-1-initial-architecture/Src/Fitnet/Reports/GenerateNewPassesRegistrationsPerMonthReport/GenerateNewPassesPerMonthReportEndpoint.cs`
- [In-memory event bus](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-1-initial-architecture/Src/Fitnet/Common/Events/EventBus/InMemory/InMemoryEventBus.cs): `Chapter-1-initial-architecture/Src/Fitnet/Common/Events/EventBus/InMemory/InMemoryEventBus.cs`

### Contracts Service

- [Contracts API](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Api/Prepare/PrepareContractEndpoint.cs): `Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Api/Prepare/PrepareContractEndpoint.cs`
- [Command handlers](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs): `Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs`
- [Contract domain](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Core/Contract.cs): `Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Core/Contract.cs`
- [Contracts persistence](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Infrastructure/Database/Repositories/ContractsRepository.cs): `Chapter-2-modules-separation/Src/Contracts/Fitnet.Contracts.Infrastructure/Database/Repositories/ContractsRepository.cs`
- [Contract command handler](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs): `Chapter-3-microservice-extraction/Fitnet.Contracts/Src/Fitnet.Contracts.Application/Sign/SignContractCommandHandler.cs`
- [Binding contracts](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/BindingContract.cs): `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/BindingContract.cs`
- [Signature validation](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/SignContract/Signatures/Signature.cs): `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Core/SignContract/Signatures/Signature.cs`
- [Binding contract repository](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/IBindingContractsRepository.cs): `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/IBindingContractsRepository.cs`
- [Contract signed event](https://github.com/evolutionary-architecture/evolutionary-architecture-by-example/blob/main/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.IntegrationEvents/ContractSignedEvent.cs): `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.IntegrationEvents/ContractSignedEvent.cs`

### Other components

- **Fitness users**

## Connections

- Vertical-slice monolith → Contract workflows: registers (evidence: `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`)
- Vertical-slice monolith → Pass lifecycle: registers (evidence: `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`)
- Vertical-slice monolith → Offer preparation: registers (evidence: `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`)
- Vertical-slice monolith → Monthly report: registers (evidence: `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`)
- Vertical-slice monolith → In-memory event bus: configures (evidence: `Chapter-1-initial-architecture/Src/Fitnet/Program.cs`)
- Vertical-slice monolith → Separated modules: evolves into
- Separated modules → Contracts API: registers
- Separated modules → Microservice extraction: evolves into
- Microservice extraction → Contract command handler: hosts
- Microservice extraction → Tactical DDD: evolves into
- Tactical DDD → Command handlers: registers
- Command handlers → Signature validation: validates with
- Command handlers → Binding contract repository: writes through
- Binding contract repository → Binding contracts: returns (evidence: `Chapter-4-applying-tactical-domain-driven-design/Fitnet.Contracts/Src/Fitnet.Contracts.Application/IBindingContractsRepository.cs`)
- Command handlers → Contract signed event: publishes
