# thatalloguy/catos architecture

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

- Interactive diagram: https://gitdiagram.com/thatalloguy/catos
- Repository: https://github.com/thatalloguy/catos

## Overview

##### Project Type and Purpose
- Catos Engine is a **cross-platform game engine** written in C++ with Python scripting support.
- It comprises three main deliverables:
– **Editor** (GUI tool to assemble worlds)
– **Player** (runtime application to run games)
– **Runtime** (core engine library used by both Editor and Player)

##### Top-Level Components
a. **Editor Application**
– Source: `Editor/src/catos/Editor`
– Uses ImGui and GLFW/SDL for UI, loads world data via Runtime serialization & scripting.
b. **Player Application**
– Source: `Player/src/catos`
– A lightweight runtime to run a built game using the Runtime library.
c. **Runtime Library**
– Source: `Runtime/src` subdivided into:
- **core** (application, window, reflection: registry, typeinfo, property, method)
- **io** (reader, writer, YAML backend)
- **math** (vectors/matrices)
- **objects** (scene graph, Node3D, Camera3D)
- **renderer** (shader, mesh loaders, texture, renderPass, passes: MainPass, ShadowPass)
- **scripting** (ScriptingEngine binding via Python/pocketpy)
- **stl** (custom string, vector, hashmap)
d. **Assets & Shaders**
– Shaders (GLSL) in `Assets/Shaders` and top-level `Shaders/`
– Sample Python scripts in `Resources/Catos`
e. **Third-Party Dependencies** (doctest, fastgltf, SDL3, rapidyml, imgui, stb_image, spdlog, pocketpy)

##### Relationships & Data Flows
- **Editor** → links against → **Runtime** (core + io + renderer + scripting)
- **Player** → links against → **Runtime**
- **Runtime** → invokes → **External libraries** (GLFW/SDL, OpenGL, Python interpreter, YAML parser)
- **Runtime/io** ↔ loads/saves ↔ **Assets** (YAML scenes, binary assets)
- **Renderer** ↔ loads ↔ **Shaders** (+potential future HLSL via SDL_GPU)
- **Scripting** ↔ executes ↔ **Python scripts** in Resources

##### Architectural Patterns & Design Principles
- **Modular layered architecture**
– Core abstractions (reflection, application, window) at the bottom
– IO and serialization layer on top of core
– Renderer and scene graph layer using core + math + io
– Scripting layer binds C++ reflection to Python
- **Plugin-style render pipeline** with customizable RenderPasses (framegraph concept)
- **Entity-Component-System** flavor via scene graph (`Node`, `World`)
- **Custom STL** demonstrates self-contained dependencies

##### Essential Elements
– **Annotations** for key frameworks (GLFW, SDL3, rapidyml, pocketpy, spdlog)
– **Note** the reflection system driving serialization & Python binding

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Applications"
        EditorApp["Editor Application"]:::app
        EditorEntry["Editor Entry Point"]:::app
        PlayerApp["Player Application"]:::app
        PlayerEntry["Player Entry Point"]:::app
    end

    subgraph "Runtime Library"
        subgraph "Core Subsystem"
            coreBox["core"]:::module
        end
        subgraph "IO Subsystem"
            ioBox["io"]:::module
        end
        subgraph "Math Subsystem"
            mathBox["math"]:::module
        end
        subgraph "Objects Subsystem"
            objectsBox["objects"]:::module
        end
        subgraph "Renderer Subsystem"
            rendererBox["renderer"]:::module
        end
        subgraph "Scripting Subsystem"
            scriptingBox["scripting"]:::module
        end
        subgraph "Custom STL"
            stlBox["stl"]:::module
        end
    end

    subgraph "Assets"
        InTreeShaders["In-Tree Shaders"]:::assets
        TopShaders["Top-Level Shaders"]:::assets
        PythonScripts["Python Scripts"]:::assets
    end

    subgraph "External Libraries"
        ExternalLibs["External Libraries"]:::ext
    end

    subgraph "Third-Party"
        ThirdParty["Third-Party Dependencies"]:::third
    end

    EditorApp -->|"uses Runtime"| coreBox
    EditorApp --> coreBox
    EditorApp --> ioBox
    EditorApp --> rendererBox
    EditorApp --> scriptingBox
    PlayerApp -->|"uses Runtime"| coreBox
    PlayerApp --> ioBox
    PlayerApp --> rendererBox
    PlayerApp --> scriptingBox

    coreBox -->|"invokes"| ExternalLibs
    ioBox -->|"loads/saves"| InTreeShaders
    rendererBox -->|"loads shaders"| InTreeShaders
    rendererBox -->|"loads shaders"| TopShaders
    scriptingBox -->|"executes"| PythonScripts
    scriptingBox -->|"invokes interpreter"| ExternalLibs

    ExternalLibs -.-> ThirdParty

    click EditorApp "https://github.com/thatalloguy/catos/tree/main/Editor/src/catos/Editor"
    click EditorEntry "https://github.com/thatalloguy/catos/blob/main/Editor/src/catos/main.cpp"
    click PlayerEntry "https://github.com/thatalloguy/catos/blob/main/Player/src/catos/main.cpp"
    click coreBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/core"
    click ioBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/io"
    click mathBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/math"
    click objectsBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/objects"
    click rendererBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/renderer"
    click scriptingBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/scripting"
    click stlBox "https://github.com/thatalloguy/catos/tree/main/Runtime/src/stl"
    click InTreeShaders "https://github.com/thatalloguy/catos/tree/main/Assets/Shaders"
    click TopShaders "https://github.com/thatalloguy/catos/tree/main/Shaders"
    click PythonScripts "https://github.com/thatalloguy/catos/tree/main/Resources/Catos"
    click ThirdParty "https://github.com/thatalloguy/catos/tree/main/Thirdparty"

    classDef app fill:#8f8,stroke:#080
    classDef module fill:#88f,stroke:#004
    classDef ext fill:#ff8,stroke:#aa0
    classDef assets fill:#f80,stroke:#a50
    classDef third fill:#ff8,stroke:#aa0
```
