# antopilo/nuake architecture

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

- Interactive diagram: https://gitdiagram.com/antopilo/nuake
- Repository: https://github.com/antopilo/nuake

## Overview

##### Project Type & Purpose
- This is a boutique Quake-style game engine (“Nuake”) plus an integrated level editor.
- Core written in C++ (directory “Nuake”), an ImGui-based Editor in C++ (“Editor”) with a managed .NET bridge (“EditorNet”), and C#/.NET bindings for runtime scripting (“NuakeNet”).
- It embeds Wren and .NET runtimes for high-level scripting, uses an ECS, Jolt physics, PBR rendering, post-processing, navigation meshes, Quake map loading, audio, and asset conversion.

##### Key Components
a. Editor Layer
- Editor UI (ImGui) – “Editor/src” (Actions, Commands, Panels, Windows).
- EditorNet – .NET/C# bridge to talk to the engine via CORAL.
- Resource & FileSystem browser, Scene hierarchy, Inspector panels, Prefab editor, Settings windows.
b. Engine Core (“Nuake/src”)
- Application & LayerStack
- Core Subsystems – Rendering, Physics, Audio, UI, Scripting, FileSystem, Input, Logging, Threading.
- ECS – Scene manager, Entities, Components, Systems.
- Resource Manager – Model loading, Textures, Shaders, Materials, Prefabs, Assets serialization.
- Scripting – Wren & C# modules, NetRPC APIs, context management.
- Subsystems – EngineSubsystem, SceneSubsystem, JobSystem.
- External libs – GLFW/GLAD/GLEW, Jolt, Assimp, Recast & Detour, SoLoud, Freetype, ImGui, Tracy profiler, glm, pugixml, stb, nanosvg.
c. Managed Layers
- NuakeNet – C# runtime bindings for ECS, rendering, input, physics, scene – lives in “NuakeNet/src”.
- EditorNet – C# Editor actions, project creation, map import scripts.
d. Runtime & Asset Pipeline
- Runtime executable (“Runtime/Runtime.cpp”) for headless or build demos.
- Asset build scripts – build.sh, BuildAssets.lua, generate.bat, premake5.lua
- Resources – Scripts (Wren), Shaders, Images, Fonts, Gizmos.

##### Interactions & Data Flow
- Editor ↔ Engine Core
- UI events & commands → Engine API (via Coral/.NET or direct C++ callbacks)
- Scene changes, asset reimports → ResourceManager, ECS updates
- Live preview frames rendered by RenderingSubsystem
- Engine Core
- Application → initializes LayerStack → EngineSubsystems
- LayerStack updates: Input → Physics → Scripting → SceneSystems → Rendering → UI
- ResourceManager & FileSystem feed assets into Rendering, Physics, Scripting
- ScriptingEngine drives game logic, entity scripts, editor scripts
- Managed Scripting
- Wren VM & C# CLR embedded in process
- Scripts invoke Engine APIs through NetModules & native Wren modules
- External Services
- Uses Jolt for physics collision/rigid bodies
- Uses Recast & Detour for navmesh generation and AI pathfinding
- Uses Assimp for import of 3D model formats
- Uses SoLoud for spatialized audio

##### Architectural Patterns & Principles
- Layered architecture: Application → LayerStack → Subsystems
- Entity-Component-System (ECS) pattern for game objects
- Modular plugin style for scripting (Wren modules, C# modules)
- Dependency inversion for rendering API (RendererAPI abstraction allows different backends)
- Job system for multi-threaded tasks

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Editor Layer
    subgraph "Editor Layer"
        direction TB
        EditorUI["Editor UI (ImGui)"]:::cpp
        EditorActions["Commands & Actions"]:::cpp
        ComponentsPanel["Inspector & Components Panel"]:::cpp
        EditorWindows["Editor Windows"]:::cpp
        EditorNetBridge["Editor .NET Bridge"]:::managed
    end

    %% Engine Core
    subgraph "Engine Core"
        direction TB
        Application["Application & LayerStack"]:::cpp
        subgraph "Core Subsystems"
            direction TB
            InputLogging["Input & Logging"]:::cpp
            OSMaths["OS & Maths"]:::cpp
        end
        subgraph "Subsystem Framework"
            direction TB
            EngineSubsystems["EngineSubsystem, SceneSubsystem"]:::cpp
            JobSystem["Job System (Multithreaded)"]:::cpp
        end
        subgraph "ECS"
            direction TB
            Entities["Entities"]:::cpp
            Components["Components"]:::cpp
            Systems["Systems"]:::cpp
        end
        subgraph "Resource & FileSystem"
            direction TB
            FileSystem["FileSystem"]:::cpp
            ResourceManager["Resource Manager"]:::cpp
        end
        subgraph "Scripting Engine"
            direction TB
            WrenVM["Wren VM"]:::scripting
            NetModules[".NET Modules"]:::scripting
        end
        Audio["Audio Subsystem"]:::cpp
        Physics["Physics Subsystem (Jolt)"]:::cpp
        Rendering["Rendering Subsystem"]:::cpp
        UIFramework["UI Framework (ImUI)"]:::cpp
    end

    %% Managed Layers
    subgraph "Managed (.NET/C#)"
        direction TB
        NuakeNet["NuakeNet Bindings"]:::managed
    end

    %% Runtime & Assets
    subgraph "Runtime & Asset Pipeline"
        direction TB
        RuntimeExec["Runtime Executable"]:::cpp
        AssetScripts["Asset Pipeline Scripts"]:::cpp
    end

    %% External Libraries
    subgraph "External Libraries"
        direction TB
        GLFW["GLFW/GLAD/GLEW"]:::external
        Jolt["Jolt Physics"]:::external
        Assimp["Assimp"]:::external
        RecastDetour["Recast & Detour"]:::external
        SoLoud["SoLoud Audio"]:::external
        Others["Freetype, ImGui, Tracy, glm, pugixml, stb, nanosvg"]:::external
    end

    %% Data Flow & Interactions
    EditorUI -->|"UI events/CORAL RPC"| Application
    EditorActions -->|calls| Application
    ComponentsPanel -->|updates| ECS
    EditorWindows -->|scene/asset commands| FileSystem
    EditorNetBridge -->|.NET RPC| NetModules

    Application -->|"init LayerStack"| EngineSubsystems
    EngineSubsystems -->|update sequence| InputLogging
    InputLogging --> Physics
    Physics -->|collision data| ECS
    ECS -->|entity updates| Systems
    Systems --> Rendering
    Rendering --> UIFramework

    FileSystem -.->|feeds assets| ResourceManager
    ResourceManager -.->|provides models/textures| Rendering
    ResourceManager -.->|provides prefabs| ECS

    WrenVM -->|script calls| NetModules
    NetModules -->|native calls| Application

    NuakeNet -->|C# bindings| NetModules
    RuntimeExec -->|headless/demo run| Application

    AssetScripts -.->|convert assets| ResourceManager
    AssetScripts -.->|generate build files| Application

    %% Dependencies
    Physics --> Jolt
    Rendering --> GLFW
    Rendering --> Assimp
    Physics --> RecastDetour
    Audio --> SoLoud
    UIFramework --> Others

    %% Click Events
    click EditorUI "https://github.com/antopilo/nuake/tree/main/Editor/src"
    click EditorActions "https://github.com/antopilo/nuake/tree/main/Editor/src/Actions"
    click ComponentsPanel "https://github.com/antopilo/nuake/tree/main/Editor/src/ComponentsPanel"
    click EditorWindows "https://github.com/antopilo/nuake/tree/main/Editor/src/Windows"
    click EditorNetBridge "https://github.com/antopilo/nuake/tree/main/EditorNet/src"
    click Application "https://github.com/antopilo/nuake/tree/main/Nuake/src/Application"
    click InputLogging "https://github.com/antopilo/nuake/tree/main/Nuake/src/Core"
    click FileSystem "https://github.com/antopilo/nuake/tree/main/Nuake/src/FileSystem"
    click ResourceManager "https://github.com/antopilo/nuake/blob/main/Nuake/src/Resource/ResourceManager.*"
    click Audio "https://github.com/antopilo/nuake/tree/main/Nuake/src/Audio"
    click Physics "https://github.com/antopilo/nuake/tree/main/Nuake/src/Physics"
    click Rendering "https://github.com/antopilo/nuake/tree/main/Nuake/src/Rendering"
    click Entities "https://github.com/antopilo/nuake/tree/main/Nuake/src/Scene/Entities"
    click Components "https://github.com/antopilo/nuake/tree/main/Nuake/src/Scene/Components"
    click Systems "https://github.com/antopilo/nuake/tree/main/Nuake/src/Scene/Systems"
    click WrenVM "https://github.com/antopilo/nuake/tree/main/Nuake/src/Scripting"
    click NetModules "https://github.com/antopilo/nuake/tree/main/Nuake/src/Scripting/NetModules"
    click EngineSubsystems "https://github.com/antopilo/nuake/tree/main/Nuake/src/Subsystems"
    click JobSystem "https://github.com/antopilo/nuake/blob/main/Nuake/src/Threading/JobSystem.*"
    click UIFramework "https://github.com/antopilo/nuake/tree/main/Nuake/src/UI"
    click NuakeNet "https://github.com/antopilo/nuake/tree/main/NuakeNet/src"
    click RuntimeExec "https://github.com/antopilo/nuake/blob/main/Runtime/Runtime.cpp"
    click AssetScripts "https://github.com/antopilo/nuake/blob/main/build.sh"
    click AssetScripts "https://github.com/antopilo/nuake/blob/main/build/BuildAssets.lua"
    click AssetScripts "https://github.com/antopilo/nuake/blob/main/generate.bat"
    click AssetScripts "https://github.com/antopilo/nuake/blob/main/premake5.lua"

    %% Styles
    classDef cpp fill:#D0E6FF,stroke:#1E73BE,color:#1E73BE
    classDef managed fill:#DFFFE0,stroke:#4C9F38,color:#4C9F38
    classDef scripting fill:#FFE6C0,stroke:#E09000,color:#E09000
    classDef external fill:#E0E0E0,stroke:#8A8A8A,color:#666666
```
