# inbestigator/flappy-bird architecture

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

- Interactive diagram: https://gitdiagram.com/inbestigator/flappy-bird
- Repository: https://github.com/inbestigator/flappy-bird

## Overview

##### Main Components
- Build & Development Environment:
– Deno: Acts as the runtime and build tool (deno.json, deno tasks for “build” and “dev”).
– Build Scripts: builds.ts which may define the build sequence.
- Game Engine:
– Godot: The “game” directory contains the Godot project file (project.godot) along with assets (sprites). This is where the game runs.
- Application/Code Layer:
– React/TypeScript Components: The core game logic and UI elements are modularized into several TSX files:
▪ main.tsx – Likely the entry point tying together the game’s React components.
▪ bg.tsx – Handles the background rendering.
▪ player.tsx – Manages the player’s functionality (e.g., physics, input handling).
▪ pipe.tsx & spawnPipes.ts – Deal with the generation and logic of game obstacles.

##### Relationships and Interactions
- Build Pipeline:
– Link this build process to the output that integrates with the Godot project.
- Integration Between Layers:
– Once built, the compiled React components are integrated into the Godot project (run from the Godot editor).
▪ From game logic (React components) to rendering within the Godot game engine.
- Modular Component Interaction:
– Show the functional flow, for example:
▪ The “main” component (main.tsx) serves as the orchestrator.
▪ The background (bg.tsx), player (player.tsx), and pipes (pipe.tsx, spawnPipes.ts) work together to produce the game’s visual and interactive elements.
▪ Dependencies between spawning obstacles (spawnPipes.ts) and their individual representations (pipe.tsx).

##### Architectural Patterns & Design Principles
- Component-based Design:
– The use of React/TypeScript encourages a modular approach, making clear separation among game elements.
- Build and Hot Reload (Dev Mode):
– The “dev” task (which recompiles on saving changes) indicates a focus on rapid feedback and iterative development.
- Integration of a Scripting/Runtime Build (Deno) and a Game Engine (Godot):
– This separation highlights a multi-layer design where the business/game logic is written in React while the game engine handles rendering and asset management.

##### Technologies, Frameworks, and Libraries
- Deno as the runtime and build system.
- TypeScript as the primary language.
- React for building modular game components.
- Godot (via Godact integration) as the game engine.
- Possibly Godact as the glue that allows React-type components to communicate with Godot’s engine.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build/Dev Layer
    subgraph "Build/Dev Layer"
        DBE["Deno Build Environment"]:::build
    end

    %% Game Logic Layer
    subgraph "Game Logic Layer"
        UI["User Input (Space/Up arrow)"]:::input
        MAIN["Main React Component (main.tsx)"]:::logic
        BG["Background Component (bg.tsx)"]:::logic
        PLAYER["Player Component (player.tsx)"]:::logic
        subgraph "Obstacle Components"
            SPAWN["Pipe Spawning Logic (spawnPipes.ts)"]:::logic
            PIPE["Pipe Component (pipe.tsx)"]:::logic
        end
    end

    %% Game Engine Layer
    subgraph "Game Engine Layer"
        GODOT["Godot Game Engine"]:::engine
    end

    %% Connections between Layers and Components
    DBE -->|"builds"| MAIN
    MAIN -->|"orchestrates"| BG
    MAIN -->|"orchestrates"| PLAYER
    MAIN -->|"orchestrates"| SPAWN
    SPAWN -->|"generates"| PIPE
    UI -->|"controls"| PLAYER

    %% Integration to Godot
    BG -->|"renders_in"| GODOT
    PLAYER -->|"renders_in"| GODOT
    PIPE -->|"renders_in"| GODOT
    MAIN -->|"integrates_to"| GODOT

    %% Styles
    classDef build fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef logic fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef engine fill:#99ff99,stroke:#333,stroke-width:2px;
    classDef input fill:#ff9999,stroke:#333,stroke-width:2px;

    %% Click Events
    click DBE "https://github.com/inbestigator/flappy-bird/blob/main/deno.json"
    click DBE "https://github.com/inbestigator/flappy-bird/blob/main/builds.ts"
    click GODOT "https://github.com/inbestigator/flappy-bird/blob/main/game/project.godot"
    click GODOT "https://github.com/inbestigator/flappy-bird/tree/main/game/sprites"
    click MAIN "https://github.com/inbestigator/flappy-bird/blob/main/main.tsx"
    click BG "https://github.com/inbestigator/flappy-bird/blob/main/bg.tsx"
    click PLAYER "https://github.com/inbestigator/flappy-bird/blob/main/player.tsx"
    click PIPE "https://github.com/inbestigator/flappy-bird/blob/main/pipe.tsx"
    click SPAWN "https://github.com/inbestigator/flappy-bird/blob/main/spawnPipes.ts"
```
