# oliveriver/5d-diplomacy-with-multiverse-time-travel architecture

> Architecture diagram of the GitHub repository oliveriver/5d-diplomacy-with-multiverse-time-travel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oliveriver/5d-diplomacy-with-multiverse-time-travel
- Repository: https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel

## Overview

##### Main Components
- Frontend Client: Located in the “client” directory, this is written using React (with TypeScript) and uses Vite for development. It consists of many UI components (e.g., pages, user-interface elements, and game context providers) that allow users to interact with the game.
- Backend Server: Found in the “server” directory, this .NET (C#) project handles game logic, order adjudication (through many subcomponents like Evaluation, Execution, and Validation), API endpoints (GameController), database operations (via Repositories, Migrations, and Context providers), and overall game orchestration.
- Database: The project supports multiple database engines – by default, it uses SQLite (with migration scripts in the “Migrations/Sqlite” folder), and there is optional support for SQL Server as indicated by the presence of SQL Server specific contexts and migrations.
- DevOps and Deployment: Configuration files for Docker (Dockerfile in both client and server directories, plus the docker-compose.yml file at the root) and CI/CD workflows under the “.github/workflows” directory indicate how the services are containerized and deployed.
- Legacy Prototype: The “prototype” directory holds legacy Java code for graphics and core game processing from early development; it is now only kept as a reference and does not form part of the current running system.

##### Relationships and Interactions
- User Interaction Flow: Users access the game via a browser that loads the client application. The client communicates with the backend server through a well-defined API (the React hooks and API files under “client/src/api”).
- API Interaction: The server’s controllers (for example, GameController.cs) receive requests from the client and trigger the necessary game processing logic and database operations.
- Game Processing and Adjudication: Within the server, multiple detailed components (grouped under Adjudication, Context, Factories, Mappers, etc.) work together. For example, the Adjudication folder contains evaluators, execution routines, and validators – all of which ensure that the complex "multiverse time travel" game logic is correctly applied.
- Database and Data Persistence: The server uses Entity Framework Core to manage schema changes and persist game state. Models and Entities are clearly separated and mapped, ensuring clean access and updates to the database.
- Deployment: Docker is used to containerize both the client and server. The docker-compose file coordinates their startup, making local deployment straightforward. This also indicates clear separation between environments for consistency and testing.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns: The clear division between the frontend and backend allows independent development and testing. The client handles presentation and interaction, while the server manages business logic and data persistence.
- Layered Architecture: The backend follows a layered approach:
- Presentation/API layer (Controllers)
- Business Logic layer (Adjudication, Factories, Validators)
- Data Access layer (Repositories, Context Providers)
- Use of Modern Frameworks/Technologies: On the client side, use of React with TypeScript and Vite; on the server side, .NET (leveraging EF Core for ORM); plus Docker for container orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Browser"]:::external

    subgraph "Frontend"
        FE["Client Application (React/TypeScript)"]:::frontend
        FEAPI["Frontend API Module"]:::frontend
    end

    subgraph "Backend Server (.NET)"
        BS["Backend Server (.NET Application)"]:::backend
        subgraph "Backend Components"
            BSController["API Controllers (GameController)"]:::backend
            subgraph "Adjudication Module"
                BSAdj_Eval["Evaluation Submodule"]:::backend
                BSAdj_Exec["Execution Submodule"]:::backend
                BSAdj_Valid["Validation Submodule"]:::backend
            end
            BSData["Data & Entity Management"]:::backend
        end
    end

    DB["Database (SQLite / SQL Server)"]:::database

    subgraph "DevOps & Deployment"
        DO1["Client Dockerfile"]:::devops
        DO2["Server Dockerfile"]:::devops
        DO3["docker-compose.yml"]:::devops
        DO4["CI/CD Workflow"]:::devops
    end

    LP["Legacy Prototype (Java POC)"]:::legacy

    %% Data Flow Arrows
    U -->|"loads"| FE
    FE -->|"initializes"| FEAPI
    FEAPI -->|"calls API"| BS
    BS --> BSController
    BSController -->|"triggers"| BSAdj_Eval
    BSAdj_Eval -->|"processes into"| BSAdj_Exec
    BSAdj_Exec -->|"validates via"| BSAdj_Valid
    BSController -->|"updates"| BSData
    BSData -->|"persists to"| DB
    BSController -->|"reads/writes"| DB
    
    %% DevOps orchestration arrows
    DO1 --- FE
    DO2 --- BS
    DO3 --- FE
    DO3 --- BS
    DO4 --- FE
    DO4 --- BS

    %% Click Events
    click FE "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/client/"
    click FEAPI "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/client/src/api"
    click BS "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/"
    click BSController "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/blob/main/server/Controllers/GameController.cs"
    click BSAdj_Eval "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/Adjudication/Evaluation"
    click BSAdj_Exec "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/Adjudication/Execution"
    click BSAdj_Valid "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/Adjudication/Validation"
    click BSData "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/Models"
    click DB "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/blob/main/server/Context/Providers/SqliteGameContext.cs"
    click DO1 "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/client/Dockerfile"
    click DO2 "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/server/Dockerfile"
    click DO3 "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/blob/main/docker-compose.yml"
    click DO4 "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/blob/main/.github/workflows/main.yml"
    click LP "https://github.com/oliveriver/5d-diplomacy-with-multiverse-time-travel/tree/main/prototype/"

    %% Legend (for student clarity)
    subgraph "Legend"
        L1["Blue: Frontend Components"]:::frontend
        L2["Green: Backend Components"]:::backend
        L3["Yellow: Database"]:::database
        L4["Grey (Dashed): DevOps & Deployment"]:::devops
        L5["Salmon (Dashed): Legacy Prototype"]:::legacy
        L6["Lavender: External (e.g., User)"]:::external
    end

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef database fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef devops fill:#D3D3D3,stroke:#333,stroke-width:2px,dasharray: 5,5;
    classDef legacy fill:#FFA07A,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5;
    classDef external fill:#E6E6FA,stroke:#333,stroke-width:2px;
```
