# sabirshah/flightapi-dotnet8-coverage architecture

> Architecture diagram of the GitHub repository sabirshah/flightapi-dotnet8-coverage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sabirshah/flightapi-dotnet8-coverage
- Repository: https://github.com/sabirshah/flightapi-dotnet8-coverage

## Overview

##### Project Type and Purpose
- Type: A RESTful full-stack Web API built on .NET 8.
- Purpose: Provide full CRUD operations over Brndintelle records stored via Entity Framework Core in an in-memory database. Exposes endpoints for create, read, update, delete, and search of Brndintelle entities.

##### File Structure
- Top-level: src (main API) and tests (unit & integration).
- Layers under src:
- Controllers (HTTP interface)
- Services (business logic & CSV loader)
- DBContext (EF Core context)
- Data (CSV file for seeding)
- DTOs (BrndintelleCreateDto, BrndintelleDto, BrndintelleUpdateDto)
- Models (domain entity: Brndintelle)
- Interfaces (IBrndintelleService, IBrndintelleCSVLoader)
- Mapper (AutoMapper profile)
- Validators (FluentValidation rules)
- Middlewares (exception handling)
- Config & launch: appsettings.json, Program.cs, launchSettings.json.

##### README Insights
- Confirms n-layered architecture and separation of concerns.
- Describes main projects (API and UnitTests.Tests).
- Lists endpoint mappings and HTTP operations.
- Technology stack: .NET 8, EF Core (InMemory), AutoMapper, FluentValidation, xUnit & Moq.

##### Main Components
a. BrndintelleAPI (entry point)
b. HTTP Interface
- BrndintelleController
- Swagger/OpenAPI
c. Middleware
- ExceptionHandlingMiddleware
d. Service Layer
- IBrndintelleService / BrndintelleService
- IBrndintelleCSVLoader / BrndintelleCsvLoader
- BrndintelleDataSeeder
e. Data Access
- BrndintelleDbContext (EF Core InMemory)
f. Domain
- Model: Brndintelle
g. Data Transfer
- DTOs and AutoMapper profile
h. Validation
- FluentValidation validators
i. Storage
- In-memory database
- CSV file (seed data)
j. External Tools
- Swagger UI
- Postman collection
- Test suite (xUnit, Moq)

##### Relationships & Data Flow
- HTTP Request → ExceptionHandlingMiddleware → BrndintelleController
- Controller → Validation (FluentValidation)
- Controller → AutoMapper mapping to DTO/Model
- Controller calls BrndintelleService
- BrndintelleService either:
- Reads/Writes via BrndintelleDbContext
- Loads/Seeds data via BrndintelleCsvLoader & BrndintelleDataSeeder
- EF Core InMemory simulates persistence
- Service returns data → Controller → HTTP Response
- Swagger UI communicates with Controller endpoints
- Tests exercise Controller and Service layers, mocking dependencies

##### Architectural Patterns & Principles
- N-Layered (Presentation, Service, Data Access)
- Dependency Injection for services, loaders, DbContext
- Single Responsibility and Separation of Concerns
- DTOs shield domain model from external contracts
- Middleware centralizes error handling
- InMemory DB simplifies testing and development

##### Essential Details
- Configuration via appsettings.json.
- Code coverage process as an external pipeline/tool connected to the tests module.
- Do not over-fragment: group similar components (all DTOs under one block, all validators under one block).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        HTTPClient["HTTP Client"]:::external
        Middleware["ExceptionHandlingMiddleware"]:::presentation
        Controller["BrndintelleController"]:::presentation
        Swagger["Swagger / OpenAPI"]:::presentation
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        Mapper["AutoMapper Profile"]:::business
        ValidatorCreate["BrndintelleCreateDto Validator"]:::business
        ValidatorUpdate["BrndintelleUpdateDto Validator"]:::business
        IService["IBrndintelleService"]:::business
        Service["BrndintelleService"]:::business
        ILoader["IBrndintelleCSVLoader"]:::business
        Loader["BrndintelleCsvLoader"]:::business
        Seeder["BrndintelleDataSeeder"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DbContext["BrndintelleDbContext"]:::data
        Model["Brndintelle Model"]:::data
        Enum["FlightStatus Enum"]:::data
        CSVFile["BrndintelleData.csv"]:::data
        InMemoryDB["In-Memory Database"]:::external
        DTOs["DTOs"]:::data
    end

    %% External Tools & Tests
    subgraph "External Tools & Tests"
        direction TB
        Postman["Postman Collection"]:::external
        Tests["Tests (xUnit, Moq)"]:::external
        Coverage["Code Coverage Pipeline"]:::external
    end

    %% Startup/Config
    Program["Program.cs"]:::presentation
    Settings["appsettings.json\nappsettings.Development.json"]:::presentation
    Launch["launchSettings.json"]:::presentation

    %% Relationships
    HTTPClient -->|sends HTTP request| Middleware
    Middleware -->|forwards| Controller
    Swagger -->|documents endpoints| Controller
    Controller -->|validates| ValidatorCreate
    Controller -->|validates| ValidatorUpdate
    Controller -->|maps| Mapper
    Controller -->|calls| Service
    Service -->|uses| DbContext
    Service -->|loads seed| Loader
    Service -->|seeds data| Seeder
    DbContext -->|stores/reads| InMemoryDB
    Loader -->|reads| CSVFile
    Controller -->|returns response| HTTPClient
    Program -->|configures middleware/DI| Middleware
    Program -->|configures endpoints| Controller
    Program -->|sets up Swagger| Swagger
    Program -->|loads configuration| Settings
    Program -->|loads launch settings| Launch
    Tests -->|mock tests| Controller
    Tests -->|integration tests| Service
    Coverage -->|reports| Tests
    Postman -->|calls| Controller

    %% Click Events
    click Program "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Program.cs"
    click Controller "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Controllers/FlightController.cs"
    click Swagger "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Program.cs"
    click Launch "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Properties/launchSettings.json"
    click Middleware "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Middlewares/ExceptionHandlingMiddleware.cs"
    click IService "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Interfaces/IFlightService.cs"
    click Service "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Services/FlightService.cs"
    click ILoader "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Interfaces/IFlightCSVLoader.cs"
    click Loader "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Services/FlightCsvLoader.cs"
    click Seeder "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Services/FlightDataSeeder.cs"
    click DbContext "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/DBContext/DBContext.cs"
    click Model "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Models/Flight.cs"
    click Enum "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Enumerations/FlightStatus.cs"
    click DTOs "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/DTOs/FlightCreateDto.cs"
    click DTOs "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/DTOs/FlightDto.cs"
    click DTOs "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/DTOs/FlightUpdateDto.cs"
    click Mapper "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Mapper/FlightMappingProfile.cs"
    click ValidatorCreate "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Validators/FlightCreateDataValidators.cs"
    click ValidatorUpdate "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Validators/FlightUpdateDtoValidator.cs"
    click CSVFile "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/Data/FlightInformation.csv"
    click Settings "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/src/appsettings.json"
    click Postman "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/tests/FlightsControllerTests.cs"
    click Tests "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/tests/UnitTests.Tests.csproj"
    click Coverage "https://github.com/sabirshah/flightapi-dotnet8-coverage/blob/main/tests/CodeCoverage.runsettings"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef business fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
