# chickensoft-games/gamedemo architecture

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

- Interactive diagram: https://gitdiagram.com/chickensoft-games/gamedemo
- Repository: https://github.com/chickensoft-games/gamedemo

## Overview

##### Main Components
- Game/Application Core – Represent the general game entry point (the “Main” scenes and the application node defined in src/Main.* and src/app/*). This is where the overall lifecycle (initialization, saving/loading, and two-phase initialization) is managed.
- Domain & Logic Layer – Show the domain repositories, shared logic blocks, and state machines. For example, include separate domain folders for the game, app, and player along with the corresponding state machine definitions (states defined in subdirectories like src/app/state/states, src/game/state/states, src/player/state/states, etc.).
- Presentation/UI – Illustrate the different UI nodes such as the menu (src/menu), pause menu, win menu, and in-game UI. Emphasize that these components are linked to their respective state machines.
- Audio System – Note the in-game audio components (src/in_game_audio) that control music and sound effects through their own scenes and logic.
- Visual & Asset Management – Indicate the multiple scene files (.tscn) and visual assets for the player, coins, map, and other game objects.
- Utility & External Services – Include components for dependency injection (AutoInject), reactive utilities (Collections), node mixins (Introspection), and testing (via the GoDotTest framework, along with the separate “test” folder).

- Demonstrate how domain-driven updates (using observable objects from the Collections package) propagate changes from business logic (domain repositories) to multiple logic blocks (such as those managing game and app states).

##### Architectural Patterns & Technologies
- Dependency Injection – Visually indicate that components receive their dependencies through AutoInject, ensuring that higher-level nodes provide services or objects to their children.

##### Elements
- Clear labels for each component (e.g., “Game Core”, “Player Controller”, “UI Manager”).
- Logic components (state management, domain logic)
- Presentation components (Godot scenes, visual assets)
- Support utilities (AutoInject, Introspection, Collections)
- Components according to modules (for example, group all player-related files under one “Player Module” and similarly for coins, map, audio, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Game/Application Core
    subgraph "Game/Application Core"
        A1("Main Entry"):::core
        A2("App Module"):::core
    end

    %% Domain & Logic Layer
    subgraph "Domain & Logic Layer"
        subgraph "App Domain Module"
            B1("App Repository"):::domain
            B2("App State"):::domain
        end
        subgraph "Game Domain Module"
            C1("Game Repository"):::domain
            C2("Game State"):::domain
        end
        subgraph "Player Domain Module"
            D1("Player Model"):::domain
            D2("Player State"):::domain
        end
        subgraph "Coin Domain Module"
            E1("Coin Model"):::domain
            E2("Coin State"):::domain
        end
        subgraph "Jumpshroom Domain Module"
            F1("Jumpshroom Model"):::domain
            F2("Jumpshroom State"):::domain
        end
        G("Chickensoft Packages"):::package
    end

    %% Presentation/UI
    subgraph "Presentation/UI"
        H1("Main Menu"):::ui
        H2("Pause Menu"):::ui
        H3("Win Menu"):::ui
        H4("In-Game UI"):::ui
    end

    %% Audio System
    subgraph "Audio System"
        I("In-Game Audio"):::audio
    end

    %% Visual & Asset Management
    subgraph "Visual & Asset Management"
        J1("Player Visuals"):::visuals
        J2("Coin Visuals"):::visuals
        J3("Map Assets"):::visuals
    end

    %% Utility & External Services
    subgraph "Utility & External Services"
        K("Utils"):::utils
        L("Testing Suite"):::test
    end

    %% Connections
    A1 -->|"initializes"| A2
    A2 -->|"initiates"| B1
    B1 -->|"executes"| B2
    A2 -->|"triggers"| C1
    C1 -->|"manages"| C2

    C2 -->|"updates"| D1
    C2 -->|"updates"| E1
    C2 -->|"updates"| F1

    D1 -->|"controls"| D2
    E1 -->|"controls"| E2
    F1 -->|"controls"| F2

    G -->|"provides-dependencies"| B2
    G -->|"provides-dependencies"| C2
    G -->|"provides-dependencies"| D2
    G -->|"provides-dependencies"| E2
    G -->|"provides-dependencies"| F2

    D2 -->|"renders"| J1
    E2 -->|"renders"| J2
    C2 -->|"lays-out"| J3

    C2 -->|"activates"| I

    H1 -->|"sends-input"| D2
    H2 -->|"sends-input"| D2
    H3 -->|"sends-input"| D2
    H4 -->|"reflects-state"| C2

    K -->|"assists"| A2

    L -->|"tests"| A2
    L -->|"tests"| B2
    L -->|"tests"| C2
    L -->|"tests"| D2
    L -->|"tests"| I

    %% Styles
    classDef core fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef domain fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef ui fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef audio fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef visuals fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef utils fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef test fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef package fill:#d3d3d3,stroke:#333,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/chickensoft-games/gamedemo/blob/main/src/Main.cs"
    click A2 "https://github.com/chickensoft-games/gamedemo/blob/main/src/app/App.cs"
    click B1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/app/domain"
    click B2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/app/state"
    click C1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/game/domain"
    click C2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/game/state"
    click D1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/player"
    click D2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/player/state"
    click E1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/coin"
    click E2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/coin/state"
    click F1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/jumpshroom"
    click F2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/jumpshroom/state"
    click H1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/menu"
    click H2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/pause_menu"
    click H3 "https://github.com/chickensoft-games/gamedemo/tree/main/src/win_menu"
    click H4 "https://github.com/chickensoft-games/gamedemo/tree/main/src/in_game_ui"
    click I "https://github.com/chickensoft-games/gamedemo/tree/main/src/in_game_audio"
    click J1 "https://github.com/chickensoft-games/gamedemo/tree/main/src/player/visuals"
    click J2 "https://github.com/chickensoft-games/gamedemo/tree/main/src/coin/visuals"
    click J3 "https://github.com/chickensoft-games/gamedemo/tree/main/src/map"
    click K "https://github.com/chickensoft-games/gamedemo/tree/main/src/utils"
    click L "https://github.com/chickensoft-games/gamedemo/tree/main/test"
```
