# ewaldhorn/bouncies architecture

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

- Interactive diagram: https://gitdiagram.com/ewaldhorn/bouncies
- Repository: https://github.com/ewaldhorn/bouncies

## Overview

##### Component Relationships

- Data flow between game components
- Event handling paths
- State management flow
- Rendering pipeline

##### Platform-Specific Elements

a) Browser Environment:
- WASM Runtime
- HTML Interface (docs/game.html)
- JavaScript Bridge (wasm_exec.js)

b) Desktop Environment:
- Native Runtime
- Direct OS Interface

##### Development Tools Integration
A supporting tools section showing:
- Task Runner (Taskfile.yml)
- Testing Framework (connecting to *_test.go files)
- Linting Tools (golangci-lint)

- Core Engine Components: Dark Blue
- Game Logic Components: Green
- Platform-Specific Code: Orange
- Build Tools: Gray
- Testing Components: Purple

Important Architectural Considerations:

##### WASM Architecture
- How the Go code compiles to WASM
- Browser integration path
- JavaScript bridge

##### Game State Flow
- State updates between components
- User input handling

##### Component Isolation
- Demonstrate how game elements (bouncer, home base, obstacles) are separated
- Their interactions through the main game loop

##### Build Pipeline
- Both development and production paths
- How Task runner orchestrates different builds

Specific elements:

##### Entry Points
- main.go as the primary entry point
- game.html for web deployment
- Desktop launch path

##### Testing Coverage
- Test files to their respective components
- Coverage reporting flow

##### Development Tools
- Task runner workflows
- Build process paths
- Development server (port 9000)

Keep the abstraction level focused on the game architecture while maintaining enough detail to show the WASM compilation and deployment strategy. This will help developers understand both the game's structure and its deployment model.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Game Engine Layer"]
        Ebitengine["Ebitengine Game Engine"]:::core
        GameLoop["Game Loop"]:::core
        click GameLoop "https://github.com/ewaldhorn/bouncies/blob/main/src/game.go"
        MainEntry["Main Entry Point"]:::core
        click MainEntry "https://github.com/ewaldhorn/bouncies/blob/main/src/main.go"
    end

    subgraph GameComponents["Game Components Layer"]
        Bouncer["Bouncer System"]:::gamecomp
        click Bouncer "https://github.com/ewaldhorn/bouncies/blob/main/src/bouncer.go"
        HomeBase["Home Base System"]:::gamecomp
        click HomeBase "https://github.com/ewaldhorn/bouncies/blob/main/src/home_base.go"
        Obstacle["Obstacle System"]:::gamecomp
        click Obstacle "https://github.com/ewaldhorn/bouncies/blob/main/src/obstacle.go"
        Helpers["Helper Utilities"]:::gamecomp
        click Helpers "https://github.com/ewaldhorn/bouncies/blob/main/src/helpers.go"
        Constants["Constants & Config"]:::gamecomp
        click Constants "https://github.com/ewaldhorn/bouncies/blob/main/src/constants.go"
        Colors["Color Management"]:::gamecomp
        click Colors "https://github.com/ewaldhorn/bouncies/blob/main/src/colours.go"
    end

    subgraph Testing["Testing Layer"]
        BouncerTest["Bouncer Tests"]:::testing
        click BouncerTest "https://github.com/ewaldhorn/bouncies/blob/main/src/bouncer_test.go"
        HomeBaseTest["Home Base Tests"]:::testing
        click HomeBaseTest "https://github.com/ewaldhorn/bouncies/blob/main/src/home_base_test.go"
        ObstacleTest["Obstacle Tests"]:::testing
        click ObstacleTest "https://github.com/ewaldhorn/bouncies/blob/main/src/obstacle_test.go"
    end

    subgraph BuildDist["Build & Distribution"]
        TaskRunner["Task Runner"]:::build
        click TaskRunner "https://github.com/ewaldhorn/bouncies/blob/main/Taskfile.yml"
        
        subgraph WASM["WASM Pipeline"]
            WASMBuild["WASM Build"]:::platform
            WASMOutput["WASM Output"]:::platform
            click WASMOutput "https://github.com/ewaldhorn/bouncies/blob/main/docs/bouncies.wasm"
            JSBridge["JavaScript Bridge"]:::platform
            click JSBridge "https://github.com/ewaldhorn/bouncies/blob/main/docs/wasm_exec.js"
            HTMLInterface["HTML Interface"]:::platform
            click HTMLInterface "https://github.com/ewaldhorn/bouncies/blob/main/docs/game.html"
        end

        subgraph Desktop["Desktop Pipeline"]
            NativeBuild["Native Build"]:::platform
            OSInterface["OS Interface"]:::platform
        end
    end

    %% Core Relationships
    MainEntry --> GameLoop
    GameLoop --> Ebitengine
    
    %% Game Component Relationships
    GameLoop --> Bouncer
    GameLoop --> HomeBase
    GameLoop --> Obstacle
    Bouncer & HomeBase & Obstacle --> Helpers
    Bouncer & HomeBase & Obstacle --> Constants
    Bouncer & HomeBase & Obstacle --> Colors

    %% Testing Relationships
    Bouncer --> BouncerTest
    HomeBase --> HomeBaseTest
    Obstacle --> ObstacleTest

    %% Build Relationships
    TaskRunner --> WASMBuild
    TaskRunner --> NativeBuild
    WASMBuild --> WASMOutput
    WASMOutput --> JSBridge
    JSBridge --> HTMLInterface
    NativeBuild --> OSInterface

    %% Styling
    classDef core fill:#2b4b6b,stroke:#1a3d5c,color:#fff
    classDef gamecomp fill:#2d8659,stroke:#1e5c3c,color:#fff
    classDef testing fill:#8b4db0,stroke:#5c3474,color:#fff
    classDef build fill:#666666,stroke:#404040,color:#fff
    classDef platform fill:#d67d3e,stroke:#a65f2f,color:#fff

    %% Legend
    subgraph Legend
        CoreLegend["Core Engine"]:::core
        GameCompLegend["Game Components"]:::gamecomp
        TestingLegend["Testing"]:::testing
        BuildLegend["Build Tools"]:::build
        PlatformLegend["Platform-Specific"]:::platform
    end
```
