# nowaxial/tournamentsandgamesindividualprojectapilexicon architecture

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

- Interactive diagram: https://gitdiagram.com/nowaxial/tournamentsandgamesindividualprojectapilexicon
- Repository: https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon

## Overview

##### Project type and purpose
- This is a .NET 8 Web API called “Tournaments and Games API.”
- It exposes REST endpoints for CRUD operations on Tournaments and Games.
- It follows a clean, layered (onion) architecture:
- Presentation (API) layer
- Domain (Core) layer
- Infrastructure (Data) layer

##### File structure
- Top‐level solution file: `TournamentsAndGames.sln`
- Tournament.Api
- Controllers: HTTP entry points (`GamesController.cs`, `TournamentDetailsController.cs`)
- Extensions & middleware registration (`ApplicationBuilderExtensions.cs`)
- Config files (`appsettings.json`, `launchSettings.json`)
- Swagger/OpenAPI via Swashbuckle
- Tournament.Core
- Entities (`Game.cs`, `TournamentDetails.cs`)
- DTOs for API contracts (`GameDto`, `TournamentDetailsDto`, create/update variants)
- Repository interfaces (`IGameRepository`, `ITournamentRepository`, `IUnitOfWork`)
- Tournament.Data
- EF Core DbContext (`TournamentContext`) and entity mappings
- Migrations & seed data (`SeedData.cs`)
- Implementations of repository interfaces and UnitOfWork
- Cross‐cutting: AutoMapper profiles (in Data or Core), JSON Patch via Newtonsoft.Json

##### Key README insights
- Clean separation of concerns (no Core dependencies on Data or Api).
- Uses Repository + Unit of Work patterns to manage transactions.
- Auto‐application of migrations and seeding on startup.
- Swagger UI for interactive documentation.
- Supports sorting, filtering, partial updates with PATCH/JSON Patch.

a. Main components
- Client(s):
- REST client or browser hitting Swagger UI
- API Layer (`Tournament.Api`):
- Controllers → Middleware (JSON serialization, error handling, Swagger)
- Domain/Core (`Tournament.Core`):
- Entities, DTOs, business interfaces
- Infrastructure/Data (`Tournament.Data`):
- EF Core DbContext → Mappings, Migrations, SeedData
- Repository implementations + UnitOfWork
- Database: SQL Server LocalDB
- External Tools & Services:
- Swagger/OpenAPI
- .NET 8 runtime

b. Relationships & interactions
1. Client → HTTP → Controllers
2. Controllers → (via injected IUnitOfWork & repositories) → Core interfaces
3. Core interfaces → implemented by Data layer repositories
4. Repositories → EF Core `TournamentContext` → SQL LocalDB
5. Startup pipeline applies migrations & seed data before accepting requests
6. AutoMapper maps between Entities ↔ DTOs in Controllers/Core

c. Architectural patterns
- Dependency Injection: Controllers depend on Core interfaces, Data implements those
- Repository + Unit of Work: Single transaction boundary for multiple operations
- JSON Patch for partial updates
- Migrations & SeedData for DB lifecycle management

d. Key technologies
- ASP.NET Core Web API (.NET 8)
- Entity Framework Core 8
- SQL Server LocalDB
- AutoMapper
- Swashbuckle/Swagger
- Newtonsoft.Json for JSON Patch

##### Detailed capture of essential elements
- Don’t omit:
- DbContext & Mappings
- Migrations & SeedData
- AutoMapper configuration
- Swagger middleware
- Interfaces in Core with no dependencies inward
- Data layer implementing those interfaces

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        RESTClient["REST Client"]:::ext
        Browser["Browser (Swagger UI)"]:::ext
    end

    %% Presentation/API Layer
    subgraph "Presentation/API Layer"
        direction TB
        API_Dir["Tournament.Api"]:::api
        Program["Program.cs"]:::api
        AppExtensions["ApplicationBuilderExtensions.cs"]:::api
        Swagger["Swagger Middleware"]:::api
        JSONSer["JSON Serialization / Error Handling"]:::api
        GamesCtrl["GamesController.cs"]:::api
        DetailsCtrl["TournamentDetailsController.cs"]:::api
        ConfigFiles["appsettings & launchSettings"]:::api
    end

    %% Domain/Core Layer
    subgraph "Domain/Core Layer"
        direction TB
        Core_Dir["Tournament.Core"]:::core
        GameEntity["Game.cs"]:::core
        TourEntity["TournamentDetails.cs"]:::core
        GameDto["GameDto & Variants"]:::core
        TourDto["TournamentDetailsDto & Variants"]:::core
        IGameRepo["IGameRepository.cs"]:::core
        ITourRepo["ITournamentRepository.cs"]:::core
        IUnitOfWork["IUnitOfWork.cs"]:::core
    end

    %% Infrastructure/Data Layer
    subgraph "Infrastructure/Data Layer"
        direction TB
        Data_Dir["Tournament.Data"]:::data
        DbContext["TournamentContext.cs"]:::data
        Mappings["TournamentMappings.cs"]:::data
        SeedData["SeedData.cs"]:::data
        Migrations["Migrations"]:::data
        GameRepoImpl["GameRepository.cs"]:::data
        TourRepoImpl["TournamentRepository.cs"]:::data
        UnitOfWorkImpl["UnitOfWork.cs"]:::data
    end

    %% Database
    SQLDB["SQL Server LocalDB"]:::db

    %% Connections
    RESTClient -->|HTTP Request| Swagger
    Browser -->|HTTP Request| Swagger
    Swagger -->|Routes Requests| GamesCtrl
    Swagger -->|Routes Requests| DetailsCtrl

    Program -->|Calls ConfigureServices| AppExtensions
    AppExtensions -->|Registers Controllers & Middleware| Swagger
    AppExtensions -->|Registers DbContext & Repos| DbContext

    GamesCtrl -->|Injects IUnitOfWork & AutoMapper| IUnitOfWork
    DetailsCtrl -->|Injects IUnitOfWork & AutoMapper| IUnitOfWork

    IUnitOfWork -->|Obtains Repositories| IGameRepo
    IUnitOfWork -->|Obtains Repositories| ITourRepo

    IGameRepo -->|Implemented By| GameRepoImpl
    ITourRepo -->|Implemented By| TourRepoImpl

    GameRepoImpl -->|Uses DbContext| DbContext
    TourRepoImpl -->|Uses DbContext| DbContext

    DbContext -->|Applies Migrations & Seeding| Migrations
    DbContext -->|Applies Migrations & Seeding| SeedData

    DbContext -->|Reads/Writes| SQLDB

    GamesCtrl -->|Maps Entities ↔ DTOs| GameDto
    DetailsCtrl -->|Maps Entities ↔ DTOs| TourDto
    GameEntity -- Domain Entities --> GameDto
    TourEntity -- Domain Entities --> TourDto

    %% Click Events
    click API_Dir "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/tree/main/Tournament.Api/"
    click Program "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/Program.cs"
    click AppExtensions "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/Extensions/ApplicationBuilderExtensions.cs"
    click GamesCtrl "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/Controllers/GamesController.cs"
    click DetailsCtrl "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/Controllers/TournamentDetailsController.cs"
    click ConfigFiles "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/appsettings.json"
    click ConfigFiles "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/appsettings.Development.json"
    click ConfigFiles "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Api/Properties/launchSettings.json"

    click Core_Dir "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/tree/main/Tournament.Core/"
    click GameEntity "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/Entities/Game.cs"
    click TourEntity "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/Entities/TournamentDetails.cs"
    click GameDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/GameDto.cs"
    click GameDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/GameCreateDto.cs"
    click GameDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/GameUpdateDto.cs"
    click TourDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/TournamentDetailsDto.cs"
    click TourDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/TournamentDetailsCreateDto.cs"
    click TourDto "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/DTOs/TournamentDetailsUpdateDto.cs"
    click IGameRepo "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/Repositories/IGameRepository.cs"
    click ITourRepo "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/Repositories/ITournamentRepository.cs"
    click IUnitOfWork "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Core/Repositories/IUnitOfWork.cs"

    click Data_Dir "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/tree/main/Tournament.Data/"
    click DbContext "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Data/TournamentContext.cs"
    click Mappings "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Data/TournamentMappings.cs"
    click SeedData "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Data/SeedData.cs"
    click Migrations "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/tree/main/Tournament.Data/Migrations/"
    click GameRepoImpl "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Repositories/GameRepository.cs"
    click TourRepoImpl "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Repositories/TournamentRepository.cs"
    click UnitOfWorkImpl "https://github.com/nowaxial/tournamentsandgamesindividualprojectapilexicon/blob/main/Tournament.Data/Repositories/UnitOfWork.cs"

    %% Styles
    classDef api fill:#d0e7ff,stroke:#0366d6,color:#0366d6;
    classDef core fill:#e6ffdd,stroke:#28a745,color:#28a745;
    classDef data fill:#ffe4cc,stroke:#d8691b,color:#d8691b;
    classDef db fill:#ccccff,stroke:#6666ff,color:#3333ff,shape:cylinder;
    classDef ext fill:#f0f0f0,stroke:#999999,color:#999999;
```
