# entelect-incubator/.net-template architecture

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

- Interactive diagram: https://gitdiagram.com/entelect-incubator/.net-template
- Repository: https://github.com/entelect-incubator/.net-template

## Overview

##### Main Components

a. API Layer (Common to all patterns):
- Controllers (PizzaController)
- Middleware components (LoggingMiddleware)
- Startup configuration

b. Core Business Logic Layer:
- For Layered Architecture:
- Commands/Queries
- Validation
- Business Logic
- Entity Framework Context

- For Clean Architecture:
- Application Layer (Use Cases)
- Domain Layer (Entities, Value Objects)
- Infrastructure Layer (Persistence)

- For Vertical Slice Architecture:
- Feature Modules (Pizza Feature)
- Cross-cutting Concerns

c. Cross-cutting Concerns:
- Logging
- Validation
- Error Handling
- Performance Monitoring

##### Relationships and Data Flow

- API requests flow from controllers to business logic
- Database operations flow through Entity Framework
- Cross-cutting concerns' interaction with other components
- Command/Query flow through MediatR

##### Specific Architectural Patterns

For Layered Architecture:
**[API Layer]**
- ↓
**[Business Logic Layer]**
- ↓
**[Data Access Layer]**
- ↓
**[Database]**

For Clean Architecture:
**[API/UI Layer]**
- ↓
**[Application Layer]**
- ↓
**[Domain Layer]**
- ↓
**[Infrastructure Layer]**

For Vertical Slice Architecture:
**[API Endpoint] → [Feature Slice]**
- ↓
- [Domain Logic]
- ↓
- [Data Access]

##### Important Elements to Highlight

- MediatR pipeline
- FluentValidation integration
- Entity Framework Core context
- Logging configuration
- Rate limiting
- Feature management
- API versioning (v1)

##### Technical Details

- .NET 9 framework
- Entity Framework Core 9
- MediatR for CQRS
- FluentValidation
- NSwag for API documentation
- Testing framework integration

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph API
        API[REST API Gateway]
        CTRL[Pizza Controller]
        MID[Logging Middleware]
        START[Startup Config]
    end

    subgraph Business_Logic
        CMD[Commands]
        QRY[Queries]
        VAL[Validation]
        DOM[Domain Entities]
    end

    subgraph Infrastructure
        DB[(Database)]
        DBCTX[Database Context]
        MAP[Data Mappings]
    end

    subgraph CrossCutting
        LOG[Logging Config]
        PERF[Performance Monitor]
        VALID[Validation Behavior]
        ERR[Error Handling]
    end

    subgraph Testing
        TEST[Test Setup]
        BENCH[Performance Testing]
        LOAD[Load Testing]
    end

    subgraph Common
        PROV[Providers]
        EXT[Extensions]
        HELP[Helpers]
    end

    API --> CTRL
    CTRL --> CMD
    CTRL --> QRY
    CMD --> VAL
    QRY --> DOM
    DOM --> DBCTX
    DBCTX --> DB
    DBCTX --> MAP

    CrossCutting --> API
    CrossCutting --> Business_Logic
    CrossCutting --> Infrastructure

    Testing --> API
    Testing --> Business_Logic
    Testing --> Infrastructure

    Common --> API
    Common --> Business_Logic
    Common --> Infrastructure

    %% Click events for component mapping
    click API "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Api/Controllers/V1/ApiController.cs"
    click CTRL "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Api/Controllers/V1/PizzaController.cs"
    click MID "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Api/Middleware/LoggingMiddleware.cs"
    click START "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Api/Startup.cs"
    click CMD "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Application/Pizzas/V1/Commands"
    click QRY "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Application/Pizzas/V1/Queries"
    click VAL "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Application/Pizzas/V1/Commands/CreatePizzaCommandValidator.cs"
    click DOM "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Domain/Entities/V1/Pizza.cs"
    click DBCTX "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Infrastructure/DatabaseContext.cs"
    click MAP "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Infrastructure/Mapping/PizzaMap.cs"
    click LOG "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Domain/Logging/Config/LoggingConfiguration.cs"
    click PERF "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Domain/Behaviours/PerformanceBehaviour.cs"
    click VALID "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Domain/Behaviours/ValidationBehavior.cs"
    click ERR "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Domain/Models/Shared/ErrorResult.cs"
    click TEST "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Test/Setup"
    click BENCH "https://github.com/entelect-incubator/.NET-Template/blob/master/CleanArchitecture/Benchmark.Testing"
    click LOAD "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/LoadTesting"
    click PROV "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Domain/Providers"
    click EXT "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Domain/Extensions"
    click HELP "https://github.com/entelect-incubator/.NET-Template/tree/master/CleanArchitecture/Domain/Helpers"

    classDef api fill:#2374f7,stroke:#fff,stroke-width:2px,color:#fff
    classDef business fill:#48a04a,stroke:#fff,stroke-width:2px,color:#fff
    classDef infra fill:#9949d6,stroke:#fff,stroke-width:2px,color:#fff
    classDef cross fill:#f7b731,stroke:#fff,stroke-width:2px,color:#fff
    classDef test fill:#eb4d4b,stroke:#fff,stroke-width:2px,color:#fff
    classDef common fill:#45aaf2,stroke:#fff,stroke-width:2px,color:#fff

    class API,CTRL,MID,START api
    class CMD,QRY,VAL,DOM business
    class DB,DBCTX,MAP infra
    class LOG,PERF,VALID,ERR cross
    class TEST,BENCH,LOAD test
    class PROV,EXT,HELP common
```
