# arm-role/rushhour architecture

> Architecture diagram of the GitHub repository arm-role/rushhour, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arm-role/rushhour
- Repository: https://github.com/arm-role/rushhour

## Overview

##### Project type and purpose
- This is a Unity‐based multiplayer game (“RushHour”) that uses Photon Fusion for networking, ParrelSync for local multi‐instance testing, and a custom UI/menu layer (PhotonFusionMenu).
- Its purpose: present a start scene, handle login & lobby, allow players to create/join a session, then run a game scene with drag‐and‐drop cooking gameplay.

##### File structure
- Top‐level Unity folders:
- Assets/Editor – custom build & layout utilities
- Assets/ParrelSync – tooling to spin up multiple editor instances
- Assets/Photon/Fusion – Fusion’s SDK (core, runtime, codegen, editor, plugins)
- Assets/Photon/FusionMenu – FusionMenu UI layer (menus, code, prefabs)
- Assets/Resources – game scenes, scripts, prefabs, scriptable objects
- Scenes under Resources/SceneStart, Resources/Scene (lobby/login/etc.), Resources/SceneGame
- Under SceneGame/Script you see clear sub‐folders representing architecture: Dependency Inject, Event, GameManager, Item, UI, SceneManager, Spawner, etc.
- ProjectSettings and Packages indicate use of Universal Render Pipeline, WebGL target, and multiplayer settings.

##### Important architectural patterns & design principles
- Dependency Injection container (SceneGame/Script/Dependency Inject)
- Event messaging (SceneGame/Script/Event) for decoupling game systems
- Singleton & MonoSingleton for global managers (SoundManager, ScoreManager, etc.)
- ScriptableObjects for data (items, menu definitions)
- Modular “feature folders” under SceneGame/Script following separation of concerns
- Photon Fusion as the authoritative network layer; FusionMenu as the UI abstraction over Fusion’s lobby/connection APIs

##### Relationships & interactions
- Unity Client’s Game Logic sends/receives network RPCs & state updates via the Photon Fusion module.
- FusionMenu UI calls Fusion API to create/join sessions, then triggers scene transitions.
- Events emitted by network callbacks (OnPlayerJoined, OnInputReceived) propagate via the Event Bus to GameManager / Item System.
- ScriptableObjects feed data into Game Logic and UI.
- ParrelSync sits outside runtime – only for development to spawn clones of the editor.

##### Essential elements
- Labels for each component and sub‐component

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Client Layer
    subgraph "Unity Client"
        subgraph "Engine & Core"
            Engine["Unity Core & Game Loop"]:::blue
        end
        subgraph "Input & Interaction"
            InputHandler["Input Handler & Drag-and-Drop Module"]:::blue
        end
        subgraph "UI Layer"
            FusionMenuUI["FusionMenu UI + Custom Controllers"]:::yellow
        end
        subgraph "Game Logic"
            DI["Dependency Injection Container"]:::blue
            EventBus["Event Bus (Game Events Messaging)"]:::blue
            GM["GameManager (Level, Timers, Score)"]:::blue
            ItemSys["Item System (Counters, Tools, Ware)"]:::blue
            Spawner["Spawner (ItemCreator, InputSpawner)"]:::blue
            SceneMgr["SceneManager (SceneLoader, Changer)"]:::blue
            Singleton["Singleton Base Classes"]:::blue
        end
        subgraph "Data Layer"
            SO["ScriptableObjects Data Layer"]:::gray
            Prefabs["Prefabs & Resources"]:::gray
        end
        subgraph "Tools & Editor"
            ParrelSync["ParrelSync Local Multi-instance Tool"]:::gray
            EditorTools["Custom Editor Build & Layout Utilities"]:::gray
        end
    end

    %% Network Module
    subgraph "Network Module"
        FusionRuntime["Photon Fusion Client API & Runtime"]:::green
        CodeGen["Photon Fusion CodeGen & Hooks"]:::green
        FusionMenuNet["Photon FusionMenu Abstraction Layer"]:::yellow
        WS["WebGL Transport (WebSocket)"]:::green
        NS["NanoSockets Transport Plugins"]:::green
    end

    %% External Services
    PhotonCloud["Photon Cloud Service"]:::green

    %% Build Targets
    subgraph "Build Targets"
        WebGL["WebGL Build Templates"]:::gray
        Standalone["Standalone/Mobile (NanoSockets)"]:::gray
    end

    %% Connections
    InputHandler -->|sends input| EventBus
    EventBus -->|triggers| GM
    GM -->|updates state via RPCs| FusionRuntime
    FusionMenuUI -->|calls| FusionMenuNet
    FusionMenuNet -->|uses API| FusionRuntime
    FusionRuntime -->|syncs| PhotonCloud
    PhotonCloud -->|relays| FusionRuntime
    FusionRuntime -->|callbacks| EventBus
    SO -->|provides data| GM
    SO -->|provides data| FusionMenuUI
    Prefabs -->|used by| ItemSys
    Prefabs -->|used by| GM
    ParrelSync -.->|dev tool| Engine
    EditorTools -.->|extends| Engine
    WebGL -->|build target| FusionRuntime
    Standalone -->|build target| FusionRuntime

    %% Click Events
    click DI "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Dependency Inject"
    click EventBus "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Event"
    click GM "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/GameManager"
    click InputHandler "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Drag"
    click ItemSys "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Item"
    click Spawner "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Spawner"
    click SceneMgr "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/SceneManager"
    click FusionMenuUI "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/UI"
    click Singleton "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/Script/Singleton"
    click SO "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/SceneGame/ScriptableObject"
    click Prefabs "https://github.com/arm-role/rushhour/tree/main/Assets/Resources/Prefab"
    click ParrelSync "https://github.com/arm-role/rushhour/tree/main/Assets/ParrelSync"
    click EditorTools "https://github.com/arm-role/rushhour/tree/main/Assets/Editor"
    click FusionRuntime "https://github.com/arm-role/rushhour/tree/main/Assets/Photon/Fusion/Runtime"
    click CodeGen "https://github.com/arm-role/rushhour/tree/main/Assets/Photon/Fusion/CodeGen"
    click FusionMenuNet "https://github.com/arm-role/rushhour/tree/main/Assets/Photon/FusionMenu/Runtime"
    click WS "https://github.com/arm-role/rushhour/tree/main/Assets/Photon/PhotonLibs/WebSocket"
    click NS "https://github.com/arm-role/rushhour/tree/main/Assets/Photon/Fusion/Plugins/NanoSockets"
    click WebGL "https://github.com/arm-role/rushhour/tree/main/Assets/WebGLTemplates"

    %% Styles
    classDef blue fill:#cce5ff,stroke:#3399ff,stroke-width:2px
    classDef green fill:#ccffcc,stroke:#33cc33,stroke-width:2px
    classDef yellow fill:#fff2cc,stroke:#ffcc00,stroke-width:2px
    classDef gray fill:#e6e6e6,stroke:#999999,stroke-width:2px
```
