# realitydenied/rural-planning-game architecture

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

- Interactive diagram: https://gitdiagram.com/realitydenied/rural-planning-game
- Repository: https://github.com/realitydenied/rural-planning-game

## Overview

##### Project type and purpose
- This is a full-stack, real-time GIS-based game built in Unity for Android/iOS, supplemented by web services for GIS data processing and a Node.js/MongoDB backend.
- Purpose: Allow players to plan rural infrastructure (roads, buildings, water points) on drone/GIS maps and provide an admin analytics panel for policymakers.

##### File structure
- Top-level directories:
- Assets/ – Unity client code (C# scripts, scenes, prefabs, shaders).
- Packages/ & ProjectSettings/ – Unity config and package manifest.
- .utmp/RelWithDebInfo – Native Android build artifacts (CMake, Ninja, GameActivity plugin).
- buildss/ – Burst-compiled native libs for Android.
- Assets/PlayFabSDK – PlayFab authentication & profile management plugin.
- Assets/Plugins – Firebase native libs for iOS/tvOS and Android Gradle templates.
- No Node.js/MongoDB or Python code present here—those services live in separate repos or the cloud.

##### README for architecture insights
- GIS data fetching & boundary extraction: Python with OSMnx & Overpass API.
- Conversion: Three.js service transforms 2D GIS into glTF/OBJ models stored in cloud.
- Game integration: Unity loads those models at runtime, presents touch-based UI.
- Online services:
- PlayFab for authentication & matchmaking.
- Custom Node.js + MongoDB backend for admin analytics and in-game scoring.
- Deployment targets: Android (Java/Kotlin Gradle), iOS (Xcode), WebGL (optional).

##### Detail
- Major Unity subsystems (Assets, Plugins, Scenes, Scripts) if deep dive is needed.
- Authentication flow (token issuance, attach to subsequent calls).
- Performance-critical paths (model download, real-time scoring).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Unity Client Layer
    subgraph "Unity Mobile Client" 
        direction TB
        UnityClient["Unity Mobile Client"]:::client
        UI["UI Layer (Touch Controls & Placement)"]:::client
        Renderer["3D Renderer (Models & Prefabs)"]:::client
        Scenes["Game Scenes"]:::client
        Auth["Authentication & Persistence (PlayFab)"]:::client
        Network["Networking Layer (HTTP Client)"]:::client
        NativeAndroid["Native Android Integration"]:::client
        BurstLibs["Burst-Compiled Native Libraries"]:::client
        FirebasePlugins["Firebase Native Plugins"]:::client
        Config["Unity Config & Packages"]:::client
    end

    %% Processing Services
    subgraph "Processing Services"
        direction TB
        GISService["GIS Processing Service"]:::processing
        ConversionService["Model Conversion Service"]:::processing
    end

    %% Backend & Admin
    subgraph "Backend & Admin"
        direction TB
        BackendAPI["Backend API (Node.js + MongoDB)"]:::backend
        AdminUI["Admin Panel UI"]:::backend
        MongoDB[(MongoDB)]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OverpassAPI["Overpass API & OSMnx"]:::external
        PlayFabCloud["PlayFab Cloud"]:::external
        CloudStorage["Cloud Storage / CDN"]:::external
    end

    %% Data Flows
    OverpassAPI -->|"HTTPS/REST GeoJSON"| GISService
    GISService -->|"GeoJSON/TopoJSON"| ConversionService
    ConversionService -->|"glTF Models"| CloudStorage
    CloudStorage -->|"Download glTF via UnityWebRequest"| UnityClient

    UnityClient -->|"Auth Token"| PlayFabCloud
    UnityClient -->|"HTTPS/REST JSON"| BackendAPI
    BackendAPI -->|"Persist Scores"| MongoDB
    AdminUI -->|"Query Metrics"| BackendAPI

    %% Internal Flows in Unity Client
    UnityClient --> UI
    UnityClient --> Renderer
    UnityClient --> Scenes
    UnityClient --> Auth
    UnityClient --> Network
    UnityClient --> NativeAndroid
    UnityClient --> BurstLibs
    UnityClient --> FirebasePlugins
    UnityClient --> Config

    %% Click Events
    click UnityClient "https://github.com/realitydenied/rural-planning-game/tree/main/Assets/"
    click UI "https://github.com/realitydenied/rural-planning-game/tree/main/Assets/StarterAssets/Mobile/UI/"
    click Renderer "https://github.com/realitydenied/rural-planning-game/tree/main/Assets/StarterAssets/Environment/Art/Models/"
    click Scenes "https://github.com/realitydenied/rural-planning-game/blob/main/Assets/Scenes/UIScene.unity"
    click Auth "https://github.com/realitydenied/rural-planning-game/tree/main/Assets/PlayFabSDK/Authentication/"
    click Network "https://github.com/realitydenied/rural-planning-game/blob/main/Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs"
    click NativeAndroid "https://github.com/realitydenied/rural-planning-game/tree/main/.utmp/RelWithDebInfo/5q45b1b5/arm64-v8a/GameActivity/"
    click BurstLibs "https://github.com/realitydenied/rural-planning-game/tree/main/buildss/Rural Planning Game_BurstDebugInformation_DoNotShip/tempburstlibs/arm64-v8a/"
    click FirebasePlugins "https://github.com/realitydenied/rural-planning-game/tree/main/Assets/Plugins/Android/"
    click Config "https://github.com/realitydenied/rural-planning-game/blob/main/Packages/manifest.json"

    %% Styles
    classDef client fill:#D0E6FF,stroke:#333,stroke-width:1px
    classDef processing fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef backend fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#DDDDDD,stroke:#333,stroke-width:1px
```
