# you3o3/robot-lab architecture

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

- Interactive diagram: https://gitdiagram.com/you3o3/robot-lab
- Repository: https://github.com/you3o3/robot-lab

## Overview

##### Main Components
- Unity Engine Environment – as the runtime framework, handling the rendering pipeline, physics engine, animation system, and scene management.
- Assets and Resource Management – include directories for Animations, Prefabs, Scenes, Sprites, Sounds, Text, and Tiles. These represent the “art” and media consumed by the engine.
- Game Logic and Scripts – found in the Assets/Script folder, subdivided by scenes (e.g., CodingScene, GameScene, MenuScene) and general shared functionality. They include game managers, player and enemy controllers, UI management, and level management.
- Scripting Engine Layer – the MoonSharp plugin (which includes Interpreter, Debugger, REPL, and Interop modules) is responsible for enabling coding/gameplay logic inscribed in scripts. This layer serves as an interpreter for or integration point with Lua.
- User Interface – involves UI elements such as Dialogue, Buttons, Text, and overall UI managers that interact with the player.
- External Assets and Dependencies – note that some asset folders are not included because they’re downloaded from the Unity Asset Store; these should be annotated as external resources.

##### Relationships and Data Flows
- The Unity Engine serves as the foundation: it loads Scenes (MenuScene, GameScene, CodingScene, etc.) from the Assets/Scene folder.
- In each scene, game objects use Prefabs (Assets/Prefab) that incorporate animations (Assets/Animation), physics (Assets/Physics), and visual elements (Sprites, Text).
- The game logic scripts (Assets/Script) wire together user input, game state, and manage interaction between gameplay components. For example, the GameManager, CodeManager, and UIManager work together to handle gameplay flow, while Player and Enemy scripts dictate in-game behaviors.
- Data flows from the user (through UI managers) to game logic which in turn may trigger the Lua scripting engine via MoonSharp. MoonSharp’s extensive file structure in Assets/Plugins/MoonSharp (with its Debugger, Interpreter, and Interop submodules) handles script execution, debugging, and even integration with third-party IDEs such as VS Code.
- Asset and resource management is handled by Unity’s importer/pipeline, while scene transitions and asset loading are managed at runtime by game-specific managers.

##### Architectural Patterns and Principles
- Component-Based Architecture: The project leverages Unity’s MonoBehaviour system to attach scripts to game objects.
- Separation of Concerns: Different directories and modules isolate game logic (e.g., GameManager.cs), UI (e.g., UIManager.cs), and core engine functionality (i.e., MoonSharp’s interpreter and debugger).
- Data-Driven Design: The use of prefabs, animations, physics materials, and external asset packs indicates a design that emphasizes data/configuration separate from core code logic.

##### Relevant Technologies, Frameworks, and Libraries
- Unity Engine (handling scenes, physics, animations, asset management).
- MoonSharp Plugin for Lua scripting (including its interpreter, REPL, and debugging support).
- External asset packs from the Unity Asset Store, such as Sci-Fi UI skins, sound effects, and sprite packages.
- C# as the primary scripting language using Unity’s MonoBehaviour architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Engine Core
    A["Unity Engine Core"]:::engine

    %% Asset Management Subgraph
    subgraph "Asset Management"
        B["Animations"]:::asset
        C["Prefabs"]:::asset
        D["Scenes"]:::asset
        E["Sprites"]:::asset
        F["Sounds"]:::asset
        G["Text"]:::asset
        H["Tiles"]:::asset
    end

    %% Gameplay Modules Subgraph
    subgraph "Gameplay Modules"
        I["Game Logic: CodingScene"]:::gameplay
        J["Game Logic: GameScene"]:::gameplay
        K["Game Logic: MenuScene"]:::gameplay
        L["Game Logic: Shared/General"]:::gameplay
        M["Game Logic: LevelSelectScene"]:::gameplay
    end

    %% Scripting Engine (MoonSharp)
    subgraph "Scripting Engine (MoonSharp)"
        N["MoonSharp Engine"]:::scripting
    end

    %% UI Components Subgraph
    subgraph "UI Components"
        O["UI Prefabs"]:::ui
        P["UI Scripts (UIManager, Dialogue)"]:::ui
    end

    %% External Assets
    Q["External Assets (AssetStore)"]:::external

    %% Relationships
    A -->|"loads_scenes"| D
    A -->|"initializes"| O

    %% Asset Management provides resources to Gameplay Modules
    C -->|"provides_prefabs"| I
    D -->|"loads_scene"| I
    B -->|"animations_for"| I
    E -->|"sprites_for"| I
    F -->|"sounds_for"| I
    G -->|"text_assets"| I
    H -->|"tile_data"| I

    %% UI Components interaction with Gameplay Modules
    O -->|"UI_input"| I
    P -->|"manages_UI"| I

    %% Gameplay Modules interaction among themselves (implicit sharing)
    I -->|"orchestrates"| J
    I -->|"orchestrates"| K
    I -->|"orchestrates"| L
    I -->|"orchestrates"| M

    %% Gameplay Modules call Scripting Engine
    I -->|"calls_lua"| N
    N -->|"returns_results"| I

    %% External Assets integration into Asset Management
    Q -->|"supplies"| B
    Q -->|"supplies"| E
    Q -->|"supplies"| G

    %% Styles
    classDef engine fill:#b3cde0,stroke:#333,stroke-width:2px;
    classDef asset fill:#fbb4ae,stroke:#333,stroke-width:2px;
    classDef gameplay fill:#ccebc5,stroke:#333,stroke-width:2px;
    classDef scripting fill:#decbe4,stroke:#333,stroke-width:2px;
    classDef ui fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef external fill:#fddaec,stroke:#333,stroke-width:2px;

    %% Click Events
    click B "https://github.com/you3o3/robot-lab/tree/main/Assets/Animation"
    click C "https://github.com/you3o3/robot-lab/tree/main/Assets/Prefab"
    click D "https://github.com/you3o3/robot-lab/tree/main/Assets/Scene"
    click E "https://github.com/you3o3/robot-lab/tree/main/Assets/Sprite"
    click F "https://github.com/you3o3/robot-lab/tree/main/Assets/Sound"
    click G "https://github.com/you3o3/robot-lab/tree/main/Assets/Text"
    click H "https://github.com/you3o3/robot-lab/tree/main/Assets/Tile"
    click I "https://github.com/you3o3/robot-lab/tree/main/Assets/Script/CodingScene"
    click J "https://github.com/you3o3/robot-lab/tree/main/Assets/Script/GameScene"
    click K "https://github.com/you3o3/robot-lab/tree/main/Assets/Script/MenuScene"
    click L "https://github.com/you3o3/robot-lab/tree/main/Assets/Script/General"
    click M "https://github.com/you3o3/robot-lab/tree/main/Assets/Script/LevelSelectScene"
    click N "https://github.com/you3o3/robot-lab/tree/main/Assets/Plugins/MoonSharp"
    click O "https://github.com/you3o3/robot-lab/tree/main/Assets/Prefab/UI"
    click P "https://github.com/you3o3/robot-lab/blob/main/Assets/Script/GameScene/General/UIManager.cs"
```
