# drewlickman/code-runner architecture

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

- Interactive diagram: https://gitdiagram.com/drewlickman/code-runner
- Repository: https://github.com/drewlickman/code-runner

## Overview

##### Main Components
- Game Engine/Core: Represent the Unity Engine itself with its built-in subsystems (rendering, physics, input handling, etc.). This is the underlying runtime that connects all other parts.
- Scenes: These are the individual game levels and menus. The file tree shows several Unity scene files (e.g., MainMenu.unity, Level 1.unity, Boss Arena.unity, GameOver.unity, Victory Screen.unity). They represent different game states and environment layouts.
– Animations: Contains controllers and animation files for both player and multiple enemy types.
– Audio: Background music, sound effects for player actions and enemy interactions.
– Sprites & UI: Visual assets for enemies, players, UI elements, and menus.
– Terrain & Prefabs: Environmental components, level geometry, obstacles, traps, and reusable prefabs (for player, enemies, and interactive objects).
– Scripts: Organized into areas like “Enemies” and “Player,” these govern the logic and behavior of game elements (player movement, enemy behavior, game timers, and trap logic).

##### Relationships & Interactions
- Scenes load and instantiate Prefabs (players, enemies, traps, UI, etc.) dynamically, so illustrate connections between Scenes and Prefabs.
- The UI system (under Assets/UI and Prefabs/Player) sends and receives events (like player input and game state changes) to/from Game Manager scripts and other controllers.
- Also denote how Physics (triggering collision detections, movements, and interactions) is encapsulated within the Unity Engine, affecting both player and enemy components.

##### Architectural Patterns & Design Principles
- Prefab Reuse: Demonstrate the use of prefabs to build game objects (obstacles, enemies, UI elements) which are instantiated across various Scenes.
- Separation of Concerns: Scripts are grouped by functionality (Enemies, Player, Timer, etc.) which aligns with MVC/MVVM style separation even though Unity’s architecture is less formal.
- Asset-Driven Design: The organizational structure of assets (Images, Terrains, Audio, etc.) directly influences visual and interactive components of the game.

##### Technologies and Frameworks
- Unity Engine as the core framework.
- Unity’s built-in physics, input, and rendering systems.
- Use of Unity’s UI Toolkit for menus and in-game UI.
- Potential integration of Text Mesh Pro for enhanced text rendering (as seen in the Assets/TextMesh Pro subfolder).

## Diagram (Mermaid)

```mermaid
graph TD
    U("Unity Engine"):::engine

    subgraph "Scenes"
        S("Game Scenes\n(MainMenu.unity, Level 1.unity, Boss Arena.unity, GameOver.unity, Victory Screen.unity)"):::scenes
    end

    subgraph "Assets & Resources"
        A1("Animations"):::assets
        A2("Audio"):::assets
        A3("Sprites"):::assets
        A4("UI Assets"):::assets
        A5("Terrain"):::assets
        A6("Prefabs"):::assets
    end

    subgraph "Scripts"
        SP("Player Components"):::scripts
        SE("Enemy Components"):::scripts
        GM("Game Manager / UI Controller"):::scripts
    end

    US("UI System"):::ui

    U -->|"loads"| S
    U -->|"loads"| A1
    U -->|"loads"| A2
    U -->|"loads"| A3
    U -->|"loads"| A4
    U -->|"loads"| A5
    U -->|"loads"| A6
    U -->|"integrates"| SP
    U -->|"integrates"| SE
    U -->|"integrates"| GM
    U -->|"handlesInput"| US

    S -->|"instantiates"| A6

    SP -->|"controls"| A1
    SP -->|"triggers"| A2
    SP -->|"updates"| A3

    SE -->|"controls"| A1
    SE -->|"triggers"| A2
    SE -->|"updates"| A3

    GM -->|"stateTransitions"| S

    US -->|"sendsEvents"| GM
    GM -->|"updatesState"| US

    click S "https://github.com/drewlickman/code-runner/tree/main/Assets/Scenes"
    click A1 "https://github.com/drewlickman/code-runner/tree/main/Assets/Animations"
    click A2 "https://github.com/drewlickman/code-runner/tree/main/Assets/Audio"
    click A3 "https://github.com/drewlickman/code-runner/tree/main/Assets/Sprites"
    click A4 "https://github.com/drewlickman/code-runner/tree/main/Assets/UI"
    click A5 "https://github.com/drewlickman/code-runner/tree/main/Assets/Terrain"
    click A6 "https://github.com/drewlickman/code-runner/tree/main/Assets/Prefabs"
    click SP "https://github.com/drewlickman/code-runner/tree/main/Assets/Scripts/Player"
    click SE "https://github.com/drewlickman/code-runner/tree/main/Assets/Scripts/Enemies"
    click GM "https://github.com/drewlickman/code-runner/blob/main/Assets/Scripts/MainMenuStart.cs"
    click GM "https://github.com/drewlickman/code-runner/blob/main/Assets/Scripts/Timer.cs"
    click US "https://github.com/drewlickman/code-runner/tree/main/Assets/UI Toolkit"

    classDef engine fill:#F4A460,stroke:#000,stroke-width:2px
    classDef scenes fill:#ADD8E6,stroke:#000,stroke-width:2px
    classDef assets fill:#90EE90,stroke:#000,stroke-width:2px
    classDef scripts fill:#D8BFD8,stroke:#000,stroke-width:2px
    classDef ui fill:#FFD700,stroke:#000,stroke-width:2px
```
