# tempoodev/booking architecture

> Architecture diagram of the GitHub repository tempoodev/booking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tempoodev/booking
- Repository: https://github.com/tempoodev/booking

## Overview

##### Main Components
- • .NET Aspire Orchestration: Represented by the “Aspire/Booking.AppHost” component, which is the entry point for running the microservices.
- • API Layer: Located in “src/Booking/Api”. This component exposes HTTP endpoints for client interactions.
- • Application Layer: Shown under “src/Booking/Application”. This layer includes common/shared logic and feature-specific modules (e.g., TodoItems and TodoLists) that coordinate business operations.
- • Domain Layer: Within the Application modules, the Domain folders (and ValueObjects) hold the core business entities and rules.
- • Infrastructure Layer: Included in parts of “src/Booking/Application/Common/Infrastructure” and “src/Booking/Application/TodoItems/Infrastructure” where database context, migrations, and external service implementations reside.
- • Migration Service: Under “src/Booking/Booking.MigrationService”, which is responsible for applying EF Core migrations at deployment.
- • Shared Library: Found in “src/Shared/Shared” that provides common shared components like API base controllers, behaviours, and security utilities.
- • Test Suite: Depicted as separate units (unit tests and integration tests in the “tests” directory) verifying both business logic and integration points.
- • HTTP Request Samples: The “requests” folder contains HTTP files to simulate API interactions, useful for integration testing and verification.

##### Component Relationships and Data Flows
- The API layer then calls into the Application Layer, which coordinates business logic in the Domain Layer.
- Domain operations often trigger Domain Events (as seen in the TodoItems feature) that are handled by event handlers.
- The Infrastructure layer supports the Application and Domain layers by providing persistence (via EF Core DbContext) and other processes like CSV file generation.
- The Migration Service interacts directly with the database to ensure schema updates are applied automatically.
- Optionally, include a depiction of external dependencies (e.g., PostgreSQL from ‘sqlServer’ defined in the Aspire configuration).

##### Architectural Patterns
- DDD: Emphasize the separation between the Domain, Application, and Infrastructure layers.
- Microservices: Each “service” (like Booking.Api, Booking.MigrationService, and potential future services) should be graphically isolated but connected via the Aspire orchestration.
- Clean Architecture principles: Clearly separate concerns – for example, showing that business logic (Domain) is independent from external frameworks and delivery mechanisms (API).

##### Incorporate Relevant Technologies and Frameworks
- .NET 9 and EF Core for database migrations and ORM.
- Entity Framework Core specifics, such as migration scripts and configuration classes.
- .NET Aspire features for container orchestration, service discovery, and health monitoring.
- ASP.NET Core for the API layer.
- Use of Dependency Injection (DI) as seen in Program.cs files across microservices.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    Client["Client (User)"]:::client

    subgraph "Orchestration"
        A1["Aspire/Booking.AppHost"]:::orchestration
    end

    subgraph "API Layer"
        API["Booking API"]:::api
        Shared["Shared Library"]:::shared
    end

    subgraph "Application Layer"
        App["Booking Application"]:::application
    end

    subgraph "Domain Layer"
        DomainCommon["Common Domain"]:::domain
        DomainTodoItems["TodoItems Domain"]:::domain
        DomainTodoLists["TodoLists Domain"]:::domain
    end

    subgraph "Infrastructure Layer"
        InfraCommon["Common Infrastructure"]:::infrastructure
        InfraTodoItems["TodoItems Infrastructure"]:::infrastructure
        InfraTodoLists["TodoLists Infrastructure"]:::infrastructure
    end

    subgraph "Migration Service"
        Migr["Booking Migration Service"]:::migration
    end

    subgraph "Testing & Samples"
        Tests["Test Suite"]:::testing
        HTTP["HTTP Request Samples"]:::testing
    end

    %% Connections
    Client -->|"sendsHTTPrequest"| API
    API -->|"calls"| App
    API -->|"utilizes"| Shared
    App -->|"executesLogic"| DomainCommon
    App -->|"executesLogic"| DomainTodoItems
    App -->|"executesLogic"| DomainTodoLists
    DomainTodoItems -->|"triggersEvent"| App
    DomainTodoLists -->|"triggersEvent"| App
    App -->|"uses"| InfraCommon
    DomainCommon -->|"persistsTo"| InfraCommon
    DomainTodoItems -->|"persistsTo"| InfraTodoItems
    DomainTodoLists -->|"persistsTo"| InfraTodoLists
    A1 -->|"orchestrates"| API
    A1 -->|"orchestrates"| Migr
    Migr -->|"migrationComplete"| API
    HTTP -->|"simulateRequest"| API
    Tests -->|"verifies"| App

    %% Click events
    click A1 "https://github.com/tempoodev/booking/blob/main/src/Aspire/Booking.AppHost"
    click API "https://github.com/tempoodev/booking/tree/main/src/Booking/Api"
    click App "https://github.com/tempoodev/booking/tree/main/src/Booking/Application"
    click DomainCommon "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/Common/Domain"
    click DomainTodoItems "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/TodoItems/Domain"
    click DomainTodoLists "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/TodoLists/Domain"
    click InfraCommon "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/Common/Infrastructure"
    click InfraTodoItems "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/TodoItems/Infrastructure"
    click InfraTodoLists "https://github.com/tempoodev/booking/tree/main/src/Booking/Application/TodoLists/Infrastructure"
    click Migr "https://github.com/tempoodev/booking/blob/main/src/Booking/Booking.MigrationService"
    click Shared "https://github.com/tempoodev/booking/tree/main/src/Shared/Shared"
    click Tests "https://github.com/tempoodev/booking/tree/main/tests"
    click HTTP "https://github.com/tempoodev/booking/tree/main/requests"

    %% Class styles
    classDef orchestration fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef application fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef domain fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef infrastructure fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef migration fill:#EBDEF0,stroke:#884EA0,stroke-width:2px;
    classDef shared fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef testing fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef client fill:#FDEBD0,stroke:#D35400,stroke-width:2px;
```
