# srslykail/turn-the-tides architecture

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

- Interactive diagram: https://gitdiagram.com/srslykail/turn-the-tides
- Repository: https://github.com/srslykail/turn-the-tides

## Overview

##### Main Components
- Assets & Scenes: Visual and audio assets, scenes (e.g., LowerMainland, TestingGrounds) that form the visual game world.
- Code Modules: Organized into functional areas via subdirectories under Assets/Code/Scripts. Notable modules include:
– Camera: Contains the CameraController and its assembly definition.
– ElevationAndLandCover: Includes components for API polling (both Python and C#), JSON parsing, and handling external data.
– Terrain: Contains definitions of various terrain types as well as tiles (e.g., UrbanTile, Lake, Forest, etc.).
– Managers: Contains GridManager and WorldManager used to control game state, grid creation, etc.
– UI: Contains UI scripts and prefabs (GameUI, NextTurnButton, PollutionMeter, WaterLevelIndicator) to drive user interactions.
– Helper: Utility scripts supporting common functionality.
- Resources & Data: JSON map data (lowerMainland.json, test maps, land use and elevation data) and prefabs that combine assets with logic.
- External Assets & Plugins: KenneyHexKit for models/textures and Newtonsoft.Json as an external dependency.
- Tests: Organized into EditMode and PlayMode tests to ensure the integrity of core functionalities in various modules.
- Project Settings: Unity project settings (audio, graphics, input, URP, etc.) which affect the overall runtime behavior.

##### Relationships & Interactions
- Game World Layer:
– Scenes in Assets/Level/Scenes serve as the high-level containers that bring together environments, managers, and UI.
- Domain/Logic Layer:
– Managers (GridManager and WorldManager) largely coordinate the state of the game world. They interact with Terrain components to create and update the grid and tiles.
– Terrain scripts define the different types of landforms; these are used by managers to assemble the game map.
– The ElevationAndLandCover components interact with external APIs (see APIPinger scripts in both Python and C#) to fetch and process environmental data, feeding into the terrain and landscape simulation.
- Presentation/Interaction Layer:
– The UI modules and camera scripts manage how the player sees and interacts with the world, often by communicating with the managers.
- Data Access & Resource Layer:
– JSON files in Assets/Resources/Maps and land use data provide initial configuration and state which are loaded by game managers or during scene initialization.
- Testing & Quality Assurance:
– PlayMode and EditMode tests help validate interactions among these components.

##### Architectural Patterns
- Modularity: The use of assembly definitions (.asmdef) in different subdirectories suggests a modular architecture, enabling encapsulation and separation of concerns.
- MVC-ish Flow: Though not strictly MVC, you have distinct layers where:
– “Model” is represented by map data, scriptable objects (like MapData.cs), and terrain definitions.
– “View” is essentially the scenes, UI, and the camera rendering.
– “Controller” are the managers that tie everything together.
- Data Flow: External API calls in ElevationAndLandCover fetch and parse JSON data (using Newtonsoft.Json) that is then transmitted to managers and terrain modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data & External Layer"
        RD["Resources & Data<br>JSON Maps & Prefabs"]:::data
        EA["External Assets & Plugins<br>KenneyHexKit/Newtonsoft.Json"]:::data
    end

    subgraph "Game World Layer"
        LMS["LowerMainland Scene"]:::asset
        TGS["TestingGrounds Scene"]:::asset
    end

    subgraph "Domain & Logic Layer"
        EAL["ElevationAndLandCover<br>API & Data Parsing"]:::domain
        MAN["Managers<br>GridManager & WorldManager"]:::domain
        TER["Terrain<br>Terrain Definitions"]:::domain
        HEL["Helper<br>Utility Scripts"]:::domain
    end

    subgraph "Presentation Layer"
        CAM["Camera<br>CameraController"]:::presentation
        UI["UI Components<br>GameUI & Controls"]:::presentation
    end

    TESTS["Tests<br>EditMode & PlayMode"]:::tests
    PS["Project Settings<br>Unity Configurations"]:::settings

    RD -->|"loads"| MAN
    EA -->|"provides"| EAL
    LMS -->|"initializes"| MAN
    TGS -->|"initializes"| MAN
    EAL -->|"feeds"| MAN
    MAN -->|"updates"| TER
    HEL -->|"supports"| MAN
    MAN -->|"updatesState"| UI
    MAN -->|"focus"| CAM
    PS -->|"configures"| MAN
    PS -->|"configures"| UI
    MAN ---|"testedBy"| TESTS

    click LMS "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Level/Scenes"
    click TGS "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Level/Scenes"
    click CAM "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Scripts/Camera"
    click EAL "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Scripts/ElevationAndLandCover"
    click TER "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Terrain"
    click MAN "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Scripts/Managers"
    click UI "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Scripts/UI"
    click HEL "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Code/Scripts/Helper"
    click RD "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Resources"
    click EA "https://github.com/srslykail/turn-the-tides/tree/main/Assets/KenneyHexKit"
    click TESTS "https://github.com/srslykail/turn-the-tides/tree/main/Assets/Tests"
    click PS "https://github.com/srslykail/turn-the-tides/tree/main/ProjectSettings"

    classDef asset fill:#333333,stroke:#ffffff,stroke-width:2px,color:#ffffff;
    classDef domain fill:#444444,stroke:#ff9900,stroke-width:2px,color:#ffffff;
    classDef presentation fill:#555555,stroke:#00ffff,stroke-width:2px,color:#ffffff;
    classDef data fill:#666666,stroke:#ff00ff,stroke-width:2px,color:#ffffff;
    classDef tests fill:#222222,stroke:#00ff00,stroke-width:2px,color:#ffffff;
    classDef settings fill:#111111,stroke:#ff0000,stroke-width:2px,color:#ffffff;
```
