# jrbashl/flappy-bord architecture

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

- Interactive diagram: https://gitdiagram.com/jrbashl/flappy-bord
- Repository: https://github.com/jrbashl/flappy-bord

## Overview

##### Project type and purpose
- This is a Unity-based 2D “Flappy Bird” clone.
- Purpose: run inside the Unity engine, load a scene, spawn pipes and a player “bird” (Bord), handle input and collisions, manage scores and speed boosts, render visuals.

##### File structure
- Top-level files: README.md, GapColliderManager.cs (misc script), Unity version + ProjectSettings.
- Assets folder (all game assets):
- ColliderVisualizer: editor tooling for debug.
- Events: ScriptableObject assets defining game events.
- Prefabs: Pipe, Bird, environment prefabs.
- Scriptable Objects: pipeline speed configs.
- Scripts: game logic (BoostColliderManager, Bord*, PipeLogic, GameEvent, listeners, etc.).
- Scenes: SampleScene contains the game objects.
- Settings, TextMesh Pro, Thirdparty, TutorialInfo: supporting assets and demos.

##### README
- Single line “Making a copy of flappy bird” confirms it’s a clone, no extra microservices or external back ends.

##### Components
a. Main components:
- Unity Engine Core
- Scene Manager
- Input System (Player_Actions_for_Bord)
- Game Loop & Update Cycle
- Physics & Collision System
- Game Logic Scripts:
– BordController (jump, collision, scoring state machine)
– PipeSpawner & PipeLogic (spawn, move, recycle pipes)
– BoostColliderManager (trigger speed boosts)
– GameEvent / GameEventListener (decoupled event bus)
- Scriptable Objects (PipeSpeedScriptableObject, event assets)
- Prefabs & Assets (Bird, Pipes, Materials, Shaders)
- UI (Score display via TextMesh Pro)
b. Relationships and interactions:
- Input System → BordController.Jump
- Physics Engine → collision callbacks → BordCollision / GapCollider → GameEvent.Trigger
- GameEvent → listeners (e.g. BordScore, BoostColliderManager)
- BordStateMachine → state transitions (Alive, Dead)
- PipeSpawner uses PipeSpeedScriptableObject to set velocity
- Update loop drives PipeLogic.Move and BoostColliderManager.Check
- Scene Manager loads SampleScene and instantiates Prefabs
- Renderer subsystem draws Meshes, Shaders, Materials
c. Architectural patterns:
- Component-based (Unity’s ECS/MonoBehaviour)
- Event bus via ScriptableObject assets (GameEvent pattern)
- State machine pattern for player state
d. Key technologies:
- Unity 2021+ engine (Universal Render Pipeline)
- C# MonoBehaviours
- ScriptableObjects for data/config
- Input System package
- TextMesh Pro for UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Engine Container
    subgraph "Unity Engine" 
        direction TB
        IM["Input System\n(Player Actions)"]:::engine
        SM["Scene Manager"]:::engine
        GL["Game Loop & Update Cycle"]:::engine
        PH["Physics & Collision System"]:::engine
        RD["Rendering Subsystem"]:::engine
    end

    %% Game Logic
    subgraph "Game Logic Scripts"
        direction TB
        JC["Jump Logic\n(BordController)"]:::logic
        SMachine["State Machine\n(BordStateMachine)"]:::logic
        BC["Collision Handling\n(BordCollision)"]:::logic
        BS["Score Handling\n(BordScore)"]:::logic
        PS["PipeLogic & Spawner"]:::logic
        BCM["BoostColliderManager"]:::logic
        BCmp["BoostCollider"]:::logic
    end

    %% Event Bus
    subgraph "Event Bus"
        direction TB
        GE["GameEvent (Core)"]:::data
        GLR["GameEventListener"]:::data
        EA["Event Assets"]:::data
    end

    %% Data Config
    subgraph "ScriptableObjects"
        direction TB
        PSO["PipeSpeedScriptableObject\n(Config)"]:::data
        PSOAsset["PipeSpeedScriptableObject.asset"]:::data
    end

    %% Prefabs & UI
    subgraph "Assets & Prefabs"
        direction TB
        PF["Prefabs\n(Bird, Pipes, Environment)"]:::asset
        UI["UI/TextMesh Pro"]:::asset
    end

    %% Connections
    IM -->|"Jump Input"| JC
    GL -->|"Update() calls"| PS
    GL -->|"Update() checks"| BCM
    SM -->|"Loads Scene"| PF
    SM -->|"Loads Scene"| UI
    PH -->|"Collision Callback"| BC
    PH -->|"Gap Collider Trigger"| BCmp
    BC -->|"Trigger Event"| GE
    BCmp -->|"Trigger Event"| GE
    GE -->|"Notifies"| GLR
    GLR -->|"Handles Score"| BS
    BCM -->|"Listens to"| GE
    PS -->|"Reads Speed Config"| PSO
    PSO -->|"Configured by"| PSOAsset
    PS -->|"Spawns/Recycle"| PF
    RD -->|"Renders"| PF
    RD -->|"Renders"| UI
    SMachine -->|"Controls State"| JC
    SMachine -->|"Controls State"| BC

    %% Click Events
    click SM "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scenes/SampleScene.unity"
    click IM "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Player_Actions_for_Bord.inputactions"
    click JC "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Bord/Jump_Script.cs"
    click SMachine "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Bord/BordStateMachine.cs"
    click BC "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Bord/BordCollision.cs"
    click BS "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Bord/BordScore.cs"
    click PS "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Pipe/PipeLogic.cs"
    click PS "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Pipe/PipePrefabScript.cs"
    click PSO "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/Pipe/PipeSpeedLogic.cs"
    click BCM "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/BoostColliderManager.cs"
    click BCmp "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/BoostCollider.cs"
    click GE "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/GameEvent.cs"
    click GLR "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/GameEventListener.cs"
    click EA "https://github.com/jrbashl/flappy-bord/tree/main/Assets/Events/"
    click PSOAsset "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scriptable Objects/PipeSpeedScriptableObject.asset"
    click PF "https://github.com/jrbashl/flappy-bord/tree/main/Assets/Prefabs/"
    click BCmp "https://github.com/jrbashl/flappy-bord/blob/main/GapColliderManager.cs"
    click PH "https://github.com/jrbashl/flappy-bord/blob/main/Assets/Scripts/GapCollider.cs"
    click UI "https://github.com/jrbashl/flappy-bord/tree/main/Assets/TextMesh Pro/"

    %% Styles
    classDef engine fill:#cce5ff,stroke:#4d89ff,color:#003366
    classDef logic fill:#d5f5d5,stroke:#28a745,color:#1b4d3e
    classDef data fill:#fcf3cf,stroke:#f1c40f,color:#7d6608
    classDef asset fill:#f8d7da,stroke:#dc3545,color:#5f2126
```
