# kucharze-kodu/gamegatherapi architecture

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

- Interactive diagram: https://gitdiagram.com/kucharze-kodu/gamegatherapi
- Repository: https://github.com/kucharze-kodu/gamegatherapi

## Overview

##### Project type and purpose
- This is a backend‐only web application (GameGather) exposing a RESTful API to support a board‐game management frontend (not included in the repo).
- Purpose: allow users to register/login, manage collections, create/join gaming sessions, track stats, and send email notifications.

##### File structure
- Four logical layers under src/:
- GameGather.Api – the HTTP entry point, minimal API modules (Authentication, PlayerManager, SessionGame).
- GameGather.Application – CQRS command/query definitions, handlers, validators, domain events, dependency‐injection setup.
- GameGather.Domain – Aggregate roots, value objects, domain events and errors.
- GameGather.Infrastructure – EF Core DbContext & migrations, repository implementations, unit‐of‐work, authentication (JWT provider), outbox pattern & background job, email service, configuration.
- Deployment artifacts: Dockerfile in Api, docker-compose.yml, Terraform scripts to provision PostgreSQL and other infrastructure.

##### README for additional insights
- Core technologies: ASP.NET Core 8; EF Core 8; PostgreSQL; Docker; REST API; Swagger.
- Patterns: CQRS, Repository, Unit of Work, Dependency Injection, MediatR.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Browser/Mobile/Swagger UI"]:::external
    Terraform["Terraform Scripts"]:::infra
    DockerCompose["Docker & Compose"]:::infra

    subgraph "API Layer"
        AuthModule["AuthenticationModule"]:::api
        click AuthModule "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Api/Modules/AuthenticationModule.cs"
        PlayerManagerModule["PlayerManagerModule"]:::api
        click PlayerManagerModule "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Api/Modules/PlayerManagerModule.cs"
        SessionGameModule["SessionGameModule"]:::api
        click SessionGameModule "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Api/Modules/SessionGameModule.cs"
        ApiProgram["Program.cs"]:::api
        click ApiProgram "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Api/Program.cs"
        ApiCsproj["GameGather.Api.csproj"]:::api
        click ApiCsproj "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Api/GameGather.Api.csproj"
    end

    subgraph "Application Layer"
        ValidationBehavior["ValidationBehavior"]:::app
        click ValidationBehavior "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Common/Behavior/ValidationBehavior.cs"
        CommandsQueries["Commands & Queries"]:::app
        PlayerFeature["PlayerManagers Feature"]:::app
        click PlayerFeature "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Features/PlayerManagers/Commands/..."
        SessionFeature["SessionGames Feature"]:::app
        click SessionFeature "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Features/SessionGames/Commands/..."
        UserFeature["Users Feature"]:::app
        click UserFeature "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Features/Users/Commands/..."
        DIApp["DependencyInjection.cs"]:::app
        click DIApp "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/DependencyInjection.cs"
        MessagingAbstractions["ICommand/IQuery Abstractions"]:::app
        click MessagingAbstractions "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Common/Messaging/ICommand.cs"
        Contracts["Contracts"]:::app
        click Contracts "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Application/Contracts"
    end

    subgraph "Domain Layer"
        Aggregates["Aggregates & Entities"]:::domain
        click Aggregates "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Domain/Aggregates"
        CommonDomain["Common & Errors"]:::domain
        click CommonDomain "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Domain/Common"
        DomainEvents["Domain Events"]:::domain
        click DomainEvents "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Domain/DomainEvents"
    end

    subgraph "Infrastructure Layer"
        DbContext["GameGatherDbContext"]:::infra
        click DbContext "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Database/GameGatherDbContext.cs"
        Migrations["Migrations"]:::infra
        click Migrations "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Infrastructure/Migrations"
        Repos["Repositories"]:::infra
        click Repos "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Repositories/CommentRepository.cs"
        UoW["UnitOfWork"]:::infra
        click UoW "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Utils/UnitOfWork.cs"
        IUnitOfWork["IUnitOfWork"]:::infra
        click IUnitOfWork "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Persistance/IUnitOfWork.cs"
        JwtInfra["JwtProvider & Auth"]:::infra
        click JwtInfra "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Authentication/JwtProvider.cs"
        IJwtProvider["IJwtProvider"]:::infra
        click IJwtProvider "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Utils/IJwtProvider.cs"
        OutboxMsg["OutboxMessage"]:::infra
        click OutboxMsg "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Utils/Outbox/OutboxMessage.cs"
        OutboxJob["ProcessOutboxMessagesJob"]:::infra
        click OutboxJob "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/BackgroundJobs/ProcessOutboxMessagesJob.cs"
        IEmailService["IEmailService"]:::infra
        click IEmailService "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Application/Utils/Email/IEmailService.cs"
        EmailService["EmailService"]:::infra
        click EmailService "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/Utils/Email/EmailService.cs"
        DIInfra["Infrastructure DI"]:::infra
        click DIInfra "https://github.com/kucharze-kodu/gamegatherapi/blob/main/src/GameGather.Infrastructure/DependencyInjection.cs"
        ConfigApp["App Configurations"]:::infra
        click ConfigApp "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Application/Configurations"
        ConfigInfra["Infra Configuration"]:::infra
        click ConfigInfra "https://github.com/kucharze-kodu/gamegatherapi/tree/main/src/GameGather.Infrastructure/Configuration"
    end

    Postgres[(PostgreSQL)]:::db
    SMTP["Email Service (SMTP)"]:::external

    Client -->|"HTTP call"| AuthModule
    Client -->|"HTTP call"| PlayerManagerModule
    Client -->|"HTTP call"| SessionGameModule

    AuthModule -->|"MediatR.Send"| ValidationBehavior
    PlayerManagerModule -->|"MediatR.Send"| ValidationBehavior
    SessionGameModule -->|"MediatR.Send"| ValidationBehavior

    ValidationBehavior -->|"Pipeline Behavior"| CommandsQueries
    CommandsQueries -->|"Handler invokes"| Aggregates
    Aggregates -->|"Emit events"| DomainEvents

    CommandsQueries -->|"Repo call"| Repos
    Repos -->|"EF Core SaveChanges"| DbContext
    DbContext -->|"Connect"| Postgres
    CommandsQueries -->|"IUnitOfWork.Commit"| UoW
    UoW -->|"Transaction"| DbContext

    Repos -->|"Write Outbox"| OutboxMsg
    OutboxJob -->|"Read Outbox"| OutboxMsg
    OutboxJob -->|"Send Email"| EmailService

    JwtInfra -.->|"Validates token"| AuthModule

    Terraform -->|"Provision DB"| Postgres
    DockerCompose -->|"Deploy API Container"| ApiProgram

    classDef api fill:#cce5ff,stroke:#004085,color:#004085
    classDef app fill:#d4edda,stroke:#155724,color:#155724
    classDef domain fill:#fff3cd,stroke:#856404,color:#856404
    classDef infra fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef db fill:#d1ecf1,stroke:#0c5460,color:#0c5460
```
