# kuopacode/clean-architecture-template-with-dotnetcore architecture

> Architecture diagram of the GitHub repository kuopacode/clean-architecture-template-with-dotnetcore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kuopacode/clean-architecture-template-with-dotnetcore
- Repository: https://github.com/kuopacode/clean-architecture-template-with-dotnetcore

## Overview

##### Project type and purpose
- This is a backend microservice (Product Service) built with .NET Core 7, following “Clean Architecture” and Domain-Driven Design (DDD) principles.
- It exposes a REST API for managing product aggregates, implements CQRS (separate Commands/Queries via MediatR), and plans to publish domain events to Kafka.

##### File structure
- Top-level folders:
- sql – DDL scripts for MySQL schema/table creation
- src/Product.Api – Presentation & Application layers (Controllers, Commands, Queries, DTOs, Handlers, MediatR pipeline)
- src/Product.Domain – Domain layer (Aggregate roots, Entities, Value Objects, Repositories interfaces, Domain events)
- src/Product.Infrastructure – Infrastructure layer (EF Core/Dapper configs, Repository and UnitOfWork implementations, data context)
- src/Product.Test – Unit test project (currently minimal)
- Supporting files: Solution file, .gitignore, README.md, launchSettings, appsettings.json.

##### README for additional insights
- Emphasizes DDD, CQRS, and future event-driven capabilities with Kafka.
- MySQL is the primary datastore; connection string in appsettings.Development.json.
- Kafka integration, logging (NLog), and tests are on the TODO list.

##### Diagramming recommendations
- Blue: API/Controllers
- Green: Application/CQRS
- Orange: Domain
- Gray: Infrastructure
- Purple: External (MySQL, Kafka)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client (Postman/Frontend)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        Controllers["Controllers"]:::presentation
        Program["Program.cs"]:::presentation
        Launch["launchSettings.json"]:::presentation
        Appsettings["appsettings.json"]:::presentation
        AppsettingsDev["appsettings.Development.json"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        Commands["Commands (AddProductCommand)"]:::application
        Queries["Queries (GetProductQuery)"]:::application
        DTOs["DTOs (GetProductDto)"]:::application
        ViewModels["ViewModels (GetProductVo)"]:::application
        Models["Models (ProductEntityModel)"]:::application
        Verifications["Verifications"]:::application
        SeedworksApp["Seedworks"]:::application
        AutoMapper["AutoMapper Profiles"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Aggregates["Aggregate Roots & Entities"]:::domain
        ValueObjects["Value Objects & Enums"]:::domain
        RepoInterfaces["Repository Interfaces"]:::domain
        DomainSeedworks["Domain Seedworks"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        EFConfigs["EF Core Entity Configs"]:::infrastructure
        DbContext["ProductContext.cs"]:::infrastructure
        RepoImpl["Repository Implementations"]:::infrastructure
        DapperUoW["Dapper UnitOfWork Interface"]:::infrastructure
        MediatorExt["Mediator Extension"]:::infrastructure
    end

    %% External Systems & Support
    subgraph "External Systems"
        MySQL["MySQL Database"]:::external
        Kafka["Kafka (Future)"]:::external
        SQLScripts["SQL Scripts"]:::external
    end

    subgraph "Tests & Docs"
        Tests["Unit Tests"]:::external
        Usings["Global Usings"]:::external
        Solution["Product.Service.sln"]:::external
        Readme["README.md"]:::external
        Gitignore[".gitignore"]:::external
    end

    %% Data Flows
    Client --> Controllers
    Controllers -->|"Dispatch Command"| Commands
    Controllers -->|"Dispatch Query"| Queries
    Commands -->|"Invoke Repository Interface"| RepoInterfaces
    RepoInterfaces -->|"Implemented By"| RepoImpl
    RepoImpl -->|"Commit UoW"| DbContext
    DbContext -->|"Write Data"| MySQL
    RepoImpl -.->|"Publish DomainEvent"| Kafka
    Queries -->|"Fetch Data"| DapperUoW
    DapperUoW -->|"Read Data"| MySQL

    %% Click Events - Presentation
    click Controllers "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/tree/main/src/Product.Api/Controllers"
    click Program "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Program.cs"
    click Launch "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Properties/launchSettings.json"
    click Appsettings "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/appsettings.json"
    click AppsettingsDev "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/appsettings.Development.json"

    %% Click Events - Application
    click Commands "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/Commands/AddProductCommand.cs"
    click Queries "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/Queries/GetProductQuery.cs"
    click DTOs "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/Dtos/GetProductDto.cs"
    click ViewModels "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/ViewModels/GetProductVo.cs"
    click Verifications "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/Verifications/AddProductCommandVerification.cs"
    click SeedworksApp "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Applications/Seedworks/UnitOfWork.cs"
    click AutoMapper "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Api/Profiles/ProductProfile.cs"

    %% Click Events - Domain
    click Aggregates "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Doamin/AggregateModels/ProductAggrerate/ProductEntity.cs"
    click ValueObjects "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Doamin/AggregateModels/ProductAggrerate/ProductInfoType.cs"
    click RepoInterfaces "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Doamin/AggregateModels/ProductAggrerate/IProductRepository.cs"
    click DomainSeedworks "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Doamin/SeedWorks/IRepository.cs"

    %% Click Events - Infrastructure
    click EFConfigs "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Infrastucture/EntityConfigs/ProductEntityConfig.cs"
    click DbContext "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Infrastucture/ProductContext.cs"
    click RepoImpl "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Infrastucture/Repositories/ProductRepository.cs"
    click DapperUoW "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Infrastucture/Seedworks/IUnitOfWorkDapper.cs"
    click MediatorExt "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Infrastucture/Extensions/MediatorExtension.cs"

    %% Click Events - External & Support
    click SQLScripts "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/tree/main/sql"
    click Tests "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Test/Product.Test.csproj"
    click Usings "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/src/Product.Test/Usings.cs"
    click Solution "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/Product.Service.sln"
    click Readme "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/README.md"
    click Gitignore "https://github.com/kuopacode/clean-architecture-template-with-dotnetcore/blob/main/.gitignore"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#0000ff,color:#000;
    classDef application fill:#d4edda,stroke:#008000,color:#000;
    classDef domain fill:#fff3cd,stroke:#ffa500,color:#000;
    classDef infrastructure fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef external fill:#e2d5f7,stroke:#800080,color:#000;
```
