# lucasnobsob/todolistchallenge architecture

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

- Interactive diagram: https://gitdiagram.com/lucasnobsob/todolistchallenge
- Repository: https://github.com/lucasnobsob/todolistchallenge

## Overview

#### Purpose and entry points
A .NET 9 REST backend for authenticated to-do task management. The HTTP host starts at `src/1 - Presentation/ToDoListChallenge.Presentation.API/Program.cs`; API endpoints are in `src/1 - Presentation/ToDoListChallenge.Presentation.API/Controllers/TaskController.cs` and `src/1 - Presentation/ToDoListChallenge.Presentation.API/Controllers/AccountController.cs`. It runs locally or as a Docker Compose/container deployment.

#### Presentation and host composition
The API project owns routing, Swagger, error handling, health checks, authentication, database setup, migrations, and HTTP integrations through startup extensions, notably `src/1 - Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/AuthExtension.cs`, `src/1 - Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs`, and `src/1 - Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/MigrationExtension.cs`. Controllers map HTTP DTOs to application services and return standardized result models.

#### Application query/command facade
`src/2 - Application/ToDoListChallenge.Application/Services/TaskAppService.cs` implements `src/2 - Application/ToDoListChallenge.Application/Interfaces/ITaskAppService.cs`. It is the main use-case boundary: maps task view models, paginates/filter queries, and dispatches mutations into the domain command pipeline. Mapping is split between `src/2 - Application/ToDoListChallenge.Application/AutoMapper/DomainToViewModelMappingProfile.cs` and `src/2 - Application/ToDoListChallenge.Application/AutoMapper/ViewModelToDomainMappingProfile.cs`.

#### Domain task lifecycle
Task writes use CQRS-style commands and validation: `src/3 - Domain/ToDoListChallenge.Domain/Commands/RegisterNewTaskCommand.cs`, `src/3 - Domain/ToDoListChallenge.Domain/Commands/UpdateTaskCommand.cs`, and `src/3 - Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs`. The handler applies rules over `src/3 - Domain/ToDoListChallenge.Domain/Models/TaskItem.cs`, persists via repository/unit-of-work abstractions, emits task events, and reports failures through domain notifications rather than leaking domain exceptions directly to HTTP.

#### Mediation, notifications, and events
The in-process mediator/bus is `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs`, behind core mediator contracts at `src/3 - Domain/ToDoListChallenge.Domain.Core/Interfaces/IMediatorHandler.cs`. Command handlers publish `TaskRegistered`, `TaskUpdated`, and `TaskRemoved` events; `src/3 - Domain/ToDoListChallenge.Domain/EventHandlers/TaskEventHandler.cs` is the event-side boundary. `src/3 - Domain/ToDoListChallenge.Domain.Core/Notifications/DomainNotificationHandler.cs` carries validation/business failures back through the request flow.

#### Persistence and event history
EF Core SQL Server uses separate operational and event-store contexts: `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/Context/ApplicationDbContext.cs` and `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/Context/EventStoreSQLContext.cs`. Task reads/writes use `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/Repository/TaskItemRepository.cs` with specifications; transaction coordination is `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/UoW/UnitOfWork.cs`. Domain events are stored through `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/EventSourcing/SqlEventStore.cs` and normalized into task history by `src/2 - Application/ToDoListChallenge.Application/EventSourcedNormalizers/TaskHistory.cs`.

#### Identity and external boundaries
ASP.NET Identity models and JWT issuance are provided by `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Identity/Services/JwtFactory.cs` and authorization requirements in `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Identity/Authorization/ClaimsRequirementHandler.cs`. Dependency bindings are centralized in `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.IoC/NativeInjectorBootStrapper.cs`. The domain also defines HTTP, mail, and typed-client boundaries (`src/3 - Domain/ToDoListChallenge.Domain/Services/HttpService.cs`, `src/3 - Domain/ToDoListChallenge.Domain/Services/IFooClient.cs`), with Polly/Refit indicated as integration infrastructure.

Main entry points: [`src/3 - Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs`](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs) (Task command handler), [`src/2 - Application/ToDoListChallenge.Application/Services/TaskAppService.cs`](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/Services/TaskAppService.cs) (Task application facade), [`src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs`](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs) (In-memory bus), [`src/1 - Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs`](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs) (Auth, DB & migrations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Host"]
  node_program["API bootstrap<br/>host<br/>[Program.cs]"]
  node_startup["Auth, DB &amp; migrations<br/>startup extensions"]
  node_task_controller["Task endpoints<br/>controller<br/>[TaskController.cs]"]
  node_account_controller["Account endpoints<br/>controller"]
end

subgraph group_application["Application &amp; Domain"]
  node_task_app_service["Task application facade<br/>application service<br/>[TaskAppService.cs]"]
  node_task_service_contract["Task service contract<br/>interface<br/>[ITaskAppService.cs]"]
  node_mappings["Task mappings<br/>AutoMapper profiles"]
  node_mediator_contract["Mediator contract<br/>domain interface"]
  node_task_commands["Task commands<br/>CQRS commands"]
  node_task_handler["Task command handler"]
  node_task_model["Task aggregate<br/>domain model<br/>[TaskItem.cs]"]
  node_notifications["Domain notifications<br/>failure channel"]
  node_task_events["Task event side<br/>event handler"]
  node_task_history["Task history normalizer<br/>event normalizer<br/>[TaskHistory.cs]"]
end

subgraph group_data["Persistence &amp; Infrastructure"]
  node_bus["In-memory bus<br/>mediator implementation<br/>[InMemoryBus.cs]"]
  node_task_repository["Task repository"]
  node_unit_of_work["Unit of work<br/>transaction coordinator<br/>[UnitOfWork.cs]"]
  node_application_db[("Operational EF context<br/>EF Core context")]
  node_event_store[("SQL event store<br/>[SqlEventStore.cs]")]
  node_identity["JWT identity &amp; claims<br/>authentication<br/>[JwtFactory.cs]"]
  node_ioc["Dependency bindings<br/>composition root"]
end

node_program -->|"configures"| node_startup
node_program -->|"registers"| node_ioc
node_startup -->|"configures"| node_application_db
node_startup -->|"enables JWT"| node_identity
node_task_controller -->|"uses"| node_task_service_contract
node_task_service_contract -.->|"implemented by"| node_task_app_service
node_task_app_service -->|"maps DTOs"| node_mappings
node_task_app_service -->|"dispatches writes"| node_mediator_contract
node_task_app_service -->|"queries tasks"| node_task_repository
node_account_controller -->|"issues tokens"| node_identity
node_mediator_contract -.->|"implemented by"| node_bus
node_bus -->|"dispatches commands"| node_task_handler
node_task_commands -->|"handled by"| node_task_handler
node_task_handler -->|"applies rules"| node_task_model
node_task_handler -->|"persists"| node_task_repository
node_task_handler -->|"commits through"| node_unit_of_work
node_task_handler -->|"reports failures"| node_notifications
node_task_handler -->|"publishes events"| node_bus
node_bus -->|"dispatches events"| node_task_events
node_task_events -->|"stores events"| node_event_store
node_event_store -->|"normalizes history"| node_task_history
node_task_repository -->|"uses"| node_application_db
node_unit_of_work -->|"coordinates"| node_application_db
node_ioc -.->|"binds"| node_bus
node_ioc -.->|"binds"| node_task_app_service

click node_program "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Program.cs"
click node_startup "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs"
click node_task_controller "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Controllers/TaskController.cs"
click node_account_controller "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Controllers/AccountController.cs"
click node_task_app_service "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/Services/TaskAppService.cs"
click node_task_service_contract "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/Interfaces/ITaskAppService.cs"
click node_mappings "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/AutoMapper/DomainToViewModelMappingProfile.cs"
click node_mediator_contract "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain.Core/Interfaces/IMediatorHandler.cs"
click node_task_commands "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/Commands/RegisterNewTaskCommand.cs"
click node_task_handler "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs"
click node_task_model "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/Models/TaskItem.cs"
click node_notifications "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain.Core/Notifications/DomainNotificationHandler.cs"
click node_task_events "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/EventHandlers/TaskEventHandler.cs"
click node_bus "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs"
click node_task_repository "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/Repository/TaskItemRepository.cs"
click node_unit_of_work "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/UoW/UnitOfWork.cs"
click node_application_db "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/Context/ApplicationDbContext.cs"
click node_event_store "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/EventSourcing/SqlEventStore.cs"
click node_task_history "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/EventSourcedNormalizers/TaskHistory.cs"
click node_identity "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.Identity/Services/JwtFactory.cs"
click node_ioc "https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.IoC/NativeInjectorBootStrapper.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_program,node_startup,node_task_controller,node_account_controller toneBlue
class node_task_app_service,node_task_service_contract,node_mappings,node_mediator_contract,node_task_commands,node_task_handler,node_task_model,node_notifications,node_task_events,node_task_history toneAmber
class node_bus,node_task_repository,node_unit_of_work,node_application_db,node_event_store,node_identity,node_ioc toneMint
```

## Components

### API Host

- [API bootstrap](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Program.cs): host · Composes the HTTP application and startup pipeline. · `src/1 - Presentation/ToDoListChallenge.Presentation.API/Program.cs`
- [Auth, DB & migrations](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs): startup extensions · Configures JWT, database access, migrations, health checks, and HTTP integrations. · `src/1 - Presentation/ToDoListChallenge.Presentation.API/StartupExtensions/DatabaseExtension.cs`
- [Task endpoints](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Controllers/TaskController.cs): controller · `src/1 - Presentation/ToDoListChallenge.Presentation.API/Controllers/TaskController.cs`
- [Account endpoints](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/1%20-%20Presentation/ToDoListChallenge.Presentation.API/Controllers/AccountController.cs): controller · `src/1 - Presentation/ToDoListChallenge.Presentation.API/Controllers/AccountController.cs`

### Application & Domain

- [Task application facade](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/Services/TaskAppService.cs): application service · Maps view models and coordinates task queries and mutations. · `src/2 - Application/ToDoListChallenge.Application/Services/TaskAppService.cs`
- [Task service contract](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/Interfaces/ITaskAppService.cs): interface · `src/2 - Application/ToDoListChallenge.Application/Interfaces/ITaskAppService.cs`
- [Task mappings](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/AutoMapper/DomainToViewModelMappingProfile.cs): AutoMapper profiles · Maps task domain models and API view models in both directions. · `src/2 - Application/ToDoListChallenge.Application/AutoMapper/DomainToViewModelMappingProfile.cs`
- [Mediator contract](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain.Core/Interfaces/IMediatorHandler.cs): domain interface · `src/3 - Domain/ToDoListChallenge.Domain.Core/Interfaces/IMediatorHandler.cs`
- [Task commands](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/Commands/RegisterNewTaskCommand.cs): CQRS commands · Register and update task mutations. · `src/3 - Domain/ToDoListChallenge.Domain/Commands/RegisterNewTaskCommand.cs`
- [Task command handler](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs): command handler · Validates task changes, persists them, and emits domain events. · `src/3 - Domain/ToDoListChallenge.Domain/CommandHandlers/TaskCommandHandler.cs`
- [Task aggregate](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/Models/TaskItem.cs): domain model · `src/3 - Domain/ToDoListChallenge.Domain/Models/TaskItem.cs`
- [Domain notifications](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain.Core/Notifications/DomainNotificationHandler.cs): failure channel · Returns validation and business failures through the request flow. · `src/3 - Domain/ToDoListChallenge.Domain.Core/Notifications/DomainNotificationHandler.cs`
- [Task event side](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/3%20-%20Domain/ToDoListChallenge.Domain/EventHandlers/TaskEventHandler.cs): event handler · Handles registered, updated, and removed task events. · `src/3 - Domain/ToDoListChallenge.Domain/EventHandlers/TaskEventHandler.cs`
- [Task history normalizer](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/2%20-%20Application/ToDoListChallenge.Application/EventSourcedNormalizers/TaskHistory.cs): event normalizer · `src/2 - Application/ToDoListChallenge.Application/EventSourcedNormalizers/TaskHistory.cs`

### Persistence & Infrastructure

- [In-memory bus](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs): mediator implementation · `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Bus/InMemoryBus.cs`
- [Task repository](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/Repository/TaskItemRepository.cs): repository · Applies task specifications for operational reads and writes. · `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/Repository/TaskItemRepository.cs`
- [Unit of work](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/UoW/UnitOfWork.cs): transaction coordinator · `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/UoW/UnitOfWork.cs`
- [Operational EF context](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/Context/ApplicationDbContext.cs): EF Core context · `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/Context/ApplicationDbContext.cs`
- [SQL event store](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.1%20-%20Data/ToDoListChallenge.Infra.Data/EventSourcing/SqlEventStore.cs): event store · Persists domain events in a dedicated EF Core context. · `src/4 - Infra/4.1 - Data/ToDoListChallenge.Infra.Data/EventSourcing/SqlEventStore.cs`
- [JWT identity & claims](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.Identity/Services/JwtFactory.cs): authentication · Issues JWTs and evaluates authorization requirements. · `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.Identity/Services/JwtFactory.cs`
- [Dependency bindings](https://github.com/lucasnobsob/todolistchallenge/blob/main/src/4%20-%20Infra/4.2%20-%20CrossCutting/ToDoListChallenge.CrossCutting.IoC/NativeInjectorBootStrapper.cs): composition root · `src/4 - Infra/4.2 - CrossCutting/ToDoListChallenge.CrossCutting.IoC/NativeInjectorBootStrapper.cs`

## Connections

- API bootstrap → Auth, DB & migrations: configures
- API bootstrap → Dependency bindings: registers
- Auth, DB & migrations → Operational EF context: configures
- Auth, DB & migrations → JWT identity & claims: enables JWT
- Task endpoints → Task service contract: uses
- Task service contract → Task application facade: implemented by
- Task application facade → Task mappings: maps DTOs
- Task application facade → Mediator contract: dispatches writes
- Task application facade → Task repository: queries tasks
- Account endpoints → JWT identity & claims: issues tokens
- Mediator contract → In-memory bus: implemented by
- In-memory bus → Task command handler: dispatches commands
- Task commands → Task command handler: handled by
- Task command handler → Task aggregate: applies rules
- Task command handler → Task repository: persists
- Task command handler → Unit of work: commits through
- Task command handler → Domain notifications: reports failures
- Task command handler → In-memory bus: publishes events
- In-memory bus → Task event side: dispatches events
- Task event side → SQL event store: stores events
- SQL event store → Task history normalizer: normalizes history
- Task repository → Operational EF context: uses
- Unit of work → Operational EF context: coordinates
- Dependency bindings → In-memory bus: binds
- Dependency bindings → Task application facade: binds
