# jatzuk/game-talk-playground architecture

> Architecture diagram of the GitHub repository jatzuk/game-talk-playground, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jatzuk/game-talk-playground
- Repository: https://github.com/jatzuk/game-talk-playground

## Overview

##### Project type and purpose
- This is an Android “playground” app that embeds a small 2D game engine. It’s meant as demo code for a talk, showcasing core ideas: different game-loop implementations, an Entity-Component-System (ECS) architecture, a processing pipeline, and multiple rendering strategies (Canvas vs Compose).

##### File structure
- Top level: standard Android module (`app/`) with Gradle scripts, resources, manifest.
- `app/src/main/java/dev/jatzuk/gametalk/engine`: the engine library subdivided into:
- `ecs` (components, entities, systems)
- `gameloop` (ComposeGameLoop, SurfaceGameLoop, ViewGameLoop)
- `pipeline` (EngineProcessingPipeline)
- `renderer` (CanvasPipelineRenderer, ComposeDrawScopePipelineRenderer)
- `scene` (Scene, AbstractScene, SceneConfigRepository)
- `scripting` (game-object factories like CarGameObject)
- `telemetry` (Telemetry, TelemetryRepository)
- `util` (Clock, Safe, CanvasUtil)
- `app/src/main/java/dev/jatzuk/gametalk/playground`: demo entrypoints and UI
- `entrypoint` packages for Compose / SurfaceView / Android View game loops
- `scene` packages for sample scenes (StressTest, Showcase)
- `ui` for Activity, ViewModel, routing and UI components (DropDownList, Theme, etc.)

##### README for additional insights
- Confirms this is demo code for a talk, highlights where to find core theory (`GameLoops101.kt`), engine architecture, and sample scenes.

- Labels: use clear names matching package or class names.
- Blue for Presentation
- Green for Engine Core
- Yellow for Data/Repositories
- Gray for Utilities
- Rectangles for modules/packages

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Activity["GameTalkActivity"]:::presentation
        ViewModel["GameTalkViewModel"]:::presentation
        RenderMode["RenderMode"]:::presentation
        Routing["Routing"]:::presentation
        SceneFactory["SceneFactory"]:::presentation
        subgraph "EntryPoints"
            direction TB
            ComposeEP["ComposeEntryPoint"]:::presentation
            SurfaceEP["GameSurfaceView"]:::presentation
            ViewEP["GameView"]:::presentation
        end
        subgraph "UI Components"
            direction TB
            DropDown["DropDownList"]:::presentation
            HomeScreen["HomeScreen"]:::presentation
            ViewContainer["ViewContainer"]:::presentation
        end
        subgraph "Theme"
            direction TB
            ColorDef["Color"]:::presentation
            ThemeDef["Theme"]:::presentation
            TypeDef["Type"]:::presentation
        end
    end

    %% Engine Core
    subgraph "Engine Core"
        direction TB
        subgraph "GameLoop Module"
            direction TB
            ComposeLoop["ComposeGameLoop"]:::engine
            SurfaceLoop["SurfaceGameLoop"]:::engine
            ViewLoop["ViewGameLoop"]:::engine
        end
        EnginePipeline["EngineProcessingPipeline"]:::engine
        subgraph "ECS"
            direction TB
            Components["Components"]:::engine
            Entities["Entities"]:::engine
            Systems["Systems"]:::engine
        end
        subgraph "Renderers"
            direction TB
            CanvasR["CanvasPipelineRenderer"]:::engine
            ComposeR["ComposeDrawScopePipelineRenderer"]:::engine
        end
        subgraph "Scene Management"
            direction TB
            SceneInt["Scene"]:::engine
            AbstractScene["AbstractScene"]:::engine
        end
        subgraph "Scripting"
            direction TB
            CarObj["CarGameObject"]:::engine
            RectObj["RectGameObject"]:::engine
        end
    end

    %% Data / Repositories
    subgraph "Data / Repositories"
        direction TB
        SceneConfigRepo["SceneConfigRepository"]:::data
        TelemetryRepo["TelemetryRepository"]:::data
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        Clock["Clock"]:::util
        SafeExec["Safe"]:::util
        CanvasUtil["CanvasUtil"]:::util
        TransformUtil["TransformUtil"]:::util
    end

    %% Connections
    Activity -->|uses| ViewModel
    ViewModel -->|selects| RenderMode
    ViewModel -->|uses| Routing
    Routing -->|creates| SceneFactory

    RenderMode -->|Compose| ComposeEP
    RenderMode -->|Surface| SurfaceEP
    RenderMode -->|View| ViewEP

    ComposeEP -->|starts| ComposeLoop
    SurfaceEP -->|starts| SurfaceLoop
    ViewEP -->|starts| ViewLoop

    ComposeLoop -->|ticks| EnginePipeline
    SurfaceLoop -->|ticks| EnginePipeline
    ViewLoop -->|ticks| EnginePipeline

    EnginePipeline -->|update| Systems
    EnginePipeline -->|render| CanvasR
    EnginePipeline -->|render| ComposeR

    Systems -->|process| Entities
    Systems -->|process| Components

    SceneFactory -->|provides| SceneInt
    SceneInt -->|extends| AbstractScene
    SceneConfigRepo -->|supplies| SceneInt

    Systems -->|records| TelemetryRepo

    ComposeLoop -->|uses| Clock
    SurfaceLoop -->|uses| Clock
    ViewLoop -->|uses| Clock
    EnginePipeline -->|uses| SafeExec
    CanvasR -->|uses| CanvasUtil
    CanvasR -->|uses| TransformUtil

    %% Click Events
    click ComposeEP "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/entrypoint/compose/ComposeEntryPoint.kt"
    click SurfaceEP "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/entrypoint/surface/GameSurfaceView.kt"
    click ViewEP "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/entrypoint/view/GameView.kt"
    click Activity "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/GameTalkActivity.kt"
    click ViewModel "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/GameTalkViewModel.kt"
    click RenderMode "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/RenderMode.kt"
    click Routing "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/Routing.kt"
    click SceneFactory "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/SceneFactory.kt"
    click DropDown "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/component/DropDownList.kt"
    click HomeScreen "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/component/HomeScreen.kt"
    click ViewContainer "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/component/ViewContainer.kt"
    click ColorDef "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/theme/Color.kt"
    click ThemeDef "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/theme/Theme.kt"
    click TypeDef "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/playground/ui/theme/Type.kt"
    click ComposeLoop "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/gameloop/ComposeGameLoop.kt"
    click SurfaceLoop "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/gameloop/SurfaceGameLoop.kt"
    click ViewLoop "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/gameloop/ViewGameLoop.kt"
    click EnginePipeline "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/pipeline/EngineProcessingPipeline.kt"
    click Components "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/ecs/component/Component.kt"
    click Entities "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/ecs/entity/Entity.kt"
    click Systems "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/ecs/system/rect/RectComponent.kt"
    click CanvasR "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/renderer/CanvasPipelineRenderer.kt"
    click ComposeR "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/renderer/ComposeDrawScopePipelineRenderer.kt"
    click SceneInt "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/scene/Scene.kt"
    click AbstractScene "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/scene/AbstractScene.kt"
    click SceneConfigRepo "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/SceneConfigRepository.kt"
    click CarObj "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/scripting/CarGameObject.kt"
    click RectObj "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/scripting/RectGameObject.kt"
    click TelemetryRepo "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/telemetry/TelemetryRepository.kt"
    click Clock "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/util/Clock.kt"
    click SafeExec "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/util/Safe.kt"
    click CanvasUtil "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/util/CanvasUtil.kt"
    click TransformUtil "https://github.com/jatzuk/game-talk-playground/blob/master/app/src/main/java/dev/jatzuk/gametalk/engine/util/TransformUtil.kt"

    %% Styling
    classDef presentation fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef engine fill:#D0F2D0,stroke:#333,stroke-width:1px
    classDef data fill:#F9F1D1,stroke:#333,stroke-width:1px
    classDef util fill:#EEEEEE,stroke:#333,stroke-width:1px
```
