# qwazsx/dotnet-webapi-starter-kit architecture

> Architecture diagram of the GitHub repository qwazsx/dotnet-webapi-starter-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qwazsx/dotnet-webapi-starter-kit
- Repository: https://github.com/qwazsx/dotnet-webapi-starter-kit

## Overview

##### Core Components and Layers
- API/Host Layer:
- Represented by the “src/Host” directory.
- Contains controllers (e.g., Catalog, Identity, Dashboard) and configuration files.
- Acts as the HTTP entry point, handling routing, requests, and response logic.
- Application Layer (Core Application):
- Found in “src/Core/Application.”
- Contains business logic, use case implementations (such as Catalog, Identity, Multitenancy, Auditing), MediatR pipelines, CQRS commands and queries.
- Includes validation, caching, event notifications, and request/response DTOs.
- Domain Layer:
- In “src/Core/Domain.”
- Represents the domain entities, business rules, domain events, and aggregates—the heart of the business model.
- Infrastructure Layer:
- Located in “src/Infrastructure.”
- Provides implementations for persistence (EF Core, Dapper, repositories), external integrations (file storage, caching, mailing, logging), authentication services, middleware (e.g., error handling, logging), and even background job processing via Hangfire.
- Integration & Migration:
- “src/Migrators” contains different database migration projects for various database providers.
- DevOps and Deployment:
- Docker-compose files for container orchestration (in “docker-compose”) and Terraform scripts for AWS deployment (in “terraform”).
- The Makefile and CI/CD configuration (under .github/workflows) show how the project is built and deployed.
- Additional Tools:
- The “fsh-cli” tool is used to scaffold and update projects.
- Code snippets and example Postman collections illustrate API testing and developer support utilities.

##### Relationships and Data Flow
- The Application Layer communicates with the Domain Layer where all the business entities and rules reside, so indicate this “dependency inward.”
- That the persistence mechanisms (EF Core and Dapper in the Infrastructure/Persistence folder) interact with one or more relational databases (MSSQL, MySQL, Oracle, PostgreSQL) used in multi-tenancy.

##### Architectural Patterns and Design Principles
- Clearly demarcate the separation between the layers (Host, Application, Domain, Infrastructure).
- That this is an example of Clean Architecture (Onion Architecture) where dependencies point inward.
- Use of CQRS/MediatR for command/query separation and the repository pattern in the persistence layer.
- Multi-tenancy aspects by showing a “Tenant Management” component in both the Application and Infrastructure layers.

##### Detail Technologies, Frameworks, and External Tools
- .NET 7 and associated Clean Architecture implementations.
- Entity Framework Core for ORM plus Dapper for performance optimization.
- Hangfire for background job processing.
- MediatR for CQRS.
- Mapster for mapping between DTOs and domain entities.
- Serilog for logging.
- Integration with containerization (Docker) and infrastructure-as-code (Terraform for AWS ECS deployment).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Client["External Client (Swagger, Postman)"]:::client
    end

    %% API/Host Layer
    subgraph "API/Host Layer"
        API["Controllers & Config (Catalog, Identity, Dashboard)"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        App["Business Logic & Use Cases (CQRS, MediatR, Validation)"]:::app
        MultiApp["Tenant Management"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Domain["Domain Entities & Business Rules"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Infra["Persistence & External Services (EF Core, Dapper, Caching, Authentication, Hangfire, Logging)"]:::infra
        MultiInfra["Multi-tenancy Support"]:::infra
    end

    %% Integration & Migration
    subgraph "Integration & Migration"
        Migrators["Database Migrations"]:::integration
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        DevDocker["Container Orchestration (docker-compose)"]:::devops
        DevTerraform["Infrastructure as Code (terraform)"]:::devops
        DevCI["CI/CD (.github/workflows)"]:::devops
        DevMake["Build Automation (Makefile)"]:::devops
    end

    %% Additional Tools
    subgraph "Additional Tools"
        Tools["Scaffolding Tool (fsh-cli)"]:::tools
    end

    %% Connections
    Client -->|"HTTP_Request"| API
    API -->|"Delegates_Request"| App
    API -->|"Triggers_AuthLogging"| Infra
    App -->|"Executes_BusinessLogic"| Domain
    App -->|"Uses_ExternalServices"| Infra
    MultiApp -->|"Synchronizes_TenantInfo"| MultiInfra
    Infra -->|"Manages_DB_Schema"| Migrators
    Infra -->|"Deployed_via_Containers"| DevDocker
    DevDocker -->|"Infrastructure_Setup"| DevTerraform
    DevTerraform -->|"CI_CD_Pipeline"| DevCI
    DevCI -->|"Automates_Builds"| DevMake
    DevMake -->|"Supports_Scaffolding"| Tools

    %% Styling classes
    classDef client fill:#bbf,stroke:#000,stroke-width:2px;
    classDef api fill:#cceeff,stroke:#000,stroke-width:2px;
    classDef app fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef domain fill:#ffffcc,stroke:#000,stroke-width:2px;
    classDef infra fill:#ffcccc,stroke:#000,stroke-width:2px;
    classDef integration fill:#e0ccff,stroke:#000,stroke-width:2px;
    classDef devops fill:#dcdcdc,stroke:#000,stroke-width:2px;
    classDef tools fill:#ffc,stroke:#000,stroke-width:2px;

    %% Click events
    click API "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/src/Host"
    click App "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/src/Core/Application"
    click Domain "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/src/Core/Domain"
    click Infra "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/src/Infrastructure"
    click Migrators "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/src/Migrators"
    click DevDocker "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/docker-compose"
    click DevTerraform "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/terraform"
    click DevCI "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/.github/workflows"
    click DevMake "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/Makefile"
    click Tools "https://github.com/qwazsx/dotnet-webapi-starter-kit/tree/master/fsh-cli"
```
