# openvideogamedata/gamelist-aggregator architecture

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

- Interactive diagram: https://gitdiagram.com/openvideogamedata/gamelist-aggregator
- Repository: https://github.com/openvideogamedata/gamelist-aggregator

## Overview

##### Main Components
- Frontend (UI): Represented by Blazor pages, Razor components, and shared UI components found in the “Pages” and “Shared” directories. This layer handles user interactions, navigation, and displays data.
- Backend (Server-side logic): This includes various Controllers (if following MVC patterns), or PageModel classes, middleware (e.g., in the Middlewares directory), and the core business logic inside the Services folder (GameListService, GameService, ItemService, etc.). The Program.cs and _Host.cshtml files also form part of the bootstrapping process.
- Data Models & Persistence: The “Data” folder holds the entity classes that represent database tables (e.g., Game, User, Friendship, Badge, etc.), and EF Core migrations (Migrations directory) manage the database schema. The ApplicationDbContext class in the root incorporates the database context.
- Data Transfer Objects (DTOs): Found in the “Dtos” folder, these classes are used to structure data going in and out of API endpoints.
- External Services/Integrations: These include integration with Google OAuth for authentication, IGDB API for video game information, and PostgreSQL as the primary data store. The configuration in appsettings.json confirms these dependencies.
- Infrastructure & Configuration: Dockerfile, Heroku deployment commands, GitHub workflows (under .github/workflows), and utility classes (in the Utils directory) support the project’s build, deployment, and runtime configuration.

##### Out Relationships and Interactions
- Middleware (UserInfoMiddleware) intercepts and processes incoming requests, typically for authentication/enrichment purposes.

##### Architectural Patterns and Design Principles
- Separation of concerns: The clear division between UI (Pages, Shared), business logic (Services), data models (Data and Dtos), and infrastructure (Middlewares, Migrations, Utils).
- Use of Dependency Injection: Likely applied within the .NET Core application to manage services.
- Entity Framework Code-First Migrations: Demonstrated by the numerous migration files that add new fields, tables, and relationships.
- API consumption and integration: The use of external APIs (IGDB) and OAuth for authentication emphasize modular integration patterns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (UI) Layer
    subgraph "Frontend (UI)"
        FL1["GameListPage"]:::frontend
        FL2["GamesPage"]:::frontend
        FL3["UsersPage"]:::frontend
        FL4["NavMenu"]:::frontend
        FL5["MainLayout"]:::frontend
    end

    %% Backend (Server-side Logic) Layer
    subgraph "Backend (Server-side Logic)"
        BE1["GameListService"]:::backend
        BE2["GameService"]:::backend
        BE3["UserInfoMiddleware"]:::backend
        BE4["Program"]:::backend
        BE5["_Host"]:::backend
        BE6["DTOs"]:::backend
    end

    %% Data Models & Persistence Layer
    subgraph "Data Models & Persistence"
        DB1["Data Models"]:::database
        DB2["ApplicationDbContext"]:::database
        DB3["Migrations"]:::database
    end

    %% External Services/Integrations
    subgraph "External Services/Integrations"
        EX1["IGDB API"]:::external
        EX2["Google OAuth"]:::external
    end

    %% Infrastructure & Configuration
    subgraph "Infrastructure & Configuration"
        INF1["Configuration"]:::infra
        INF2["Dockerfile"]:::infra
        INF3["Utils"]:::infra
        INF4[".github Workflows"]:::infra
    end

    %% Connections between layers
    %% Frontend to Backend: UI initiates HTTP requests invoking backend services
    FL1 -->|"HTTP_Request"| BE1
    FL2 -->|"HTTP_Request"| BE2
    FL3 -->|"HTTP_Request"| BE1

    %% Shared UI interacts indirectly with backend via navigation and layout
    FL4 --> BE4
    FL5 --> BE4

    %% Backend interactions
    BE1 -->|"EFCore_Access"| DB2
    BE2 -->|"EFCore_Access"| DB2
    BE1 -->|"Uses_DTOs"| BE6
    BE2 -->|"Uses_DTOs"| BE6
    BE4 -->|"Initializes"| BE3

    %% Middleware intercepts Backend requests
    BE4 --> BE3

    %% Backend uses External APIs for data and authentication
    BE1 -->|"API_Call"| EX1
    BE2 -->|"API_Call"| EX1
    BE4 -->|"Auth_Request"| EX2

    %% Backend utilizes Infrastructure and Configuration
    BE4 -->|"Config_&_Utils"| INF1
    BE4 --> INF3

    %% Data Models & Persistence connections
    DB2 -->|"Manages_Schema"| DB3

    %% Styling
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef external fill:#F08080,stroke:#000,stroke-width:2px;
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events for Frontend Components
    click FL1 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Pages/GameListPage"
    click FL2 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Pages/Games"
    click FL3 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Pages/Users"
    click FL4 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Shared/NavMenu.razor"
    click FL5 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Shared/MainLayout.razor"

    %% Click Events for Backend Components
    click BE1 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Services/GameListService.cs"
    click BE2 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Services/GameService.cs"
    click BE3 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Middlewares/UserInfoMiddleware.cs"
    click BE4 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Program.cs"
    click BE5 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/Pages/_Host.cshtml"

    %% Click Events for Data Models & Persistence
    click DB1 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Data/"
    click DB2 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/ApplicationDbContext.cs"
    click DB3 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Migrations"

    %% Click Events for DTOs
    click BE6 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Dtos/"

    %% Click Events for External Services/Integrations & Configuration
    click INF1 "https://github.com/openvideogamedata/gamelist-aggregator/blob/main/appsettings.json"
    click INF2 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Dockerfile"
    click INF3 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/Utils/"
    click INF4 "https://github.com/openvideogamedata/gamelist-aggregator/tree/main/.github/workflows"
```
