# rageking8/planar-engine architecture

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

- Interactive diagram: https://gitdiagram.com/rageking8/planar-engine
- Repository: https://github.com/rageking8/planar-engine

## Overview

##### Main Components Identification
The system should be divided into these major components:

a) Engine Core (Runtime)
- Graphics System (OpenGL-based)
- Audio System (SoLoud-based)
- Input System (GLFW-based)
- Asset Management
- Scene Management
- Component System
- Math/Physics

b) Editor
- UI System (ImGui-based)
- Project Management
- Build System
- Script Management
- Asset Import/Export
- Scene Editor

c) Scripting Interface
- C# Runtime (.NET 8)
- Component Scripting
- Native Bindings

**[Editor Layer]**
- ↑↓
**[Engine Core Layer]**
- ↑↓
**[Platform Layer (Windows)]**

##### Component Relationships

Key relationships:

a) Editor → Engine Core
- Scene manipulation
- Asset management
- Component editing
- Runtime preview

b) Engine Core → Platform
- Graphics (OpenGL)
- Input (GLFW)
- File system
- Audio (SoLoud)

c) Scripting System → Engine Core
- Component behavior
- Game logic
- Event handling

##### Detailed Component Breakdown

For each major system, show:

a) Graphics Pipeline
- GLFW Window Management
- OpenGL Rendering
- Sprite Management
- Camera System
- UI Rendering (ImGui)

b) Asset System
- Asset Database
- Resource Loading
- Asset References
- Import/Export

c) Component Architecture
- Transform2D
- SpriteRenderer
- AudioSource
- Camera2D
- Script Components
- Custom Components

d) Editor Windows
- Scene View
- Game View
- Inspector
- Hierarchy
- Project Browser
- Console

##### Data Flow

Critical paths:

a) Asset Pipeline:
**[Asset Files] → [Asset Import] → [Asset Database] → [Runtime Components]**

b) Script Compilation:
**[C# Scripts] → [.NET Compiler] → [Script Assembly] → [Runtime Binding]**

c) Scene Management:
**[Scene Editor] → [Scene Serialization] → [Runtime Scene] → [GameObject Hierarchy]**

##### Integration Points

Integration with:
- OpenGL (via GLAD)
- GLFW
- ImGui
- SoLoud
- .NET Runtime
- YAML (for serialization)
- Native File Dialog

Remember to emphasize the modular nature of the engine, showing how components can be extended or replaced while maintaining the core architecture.

This structure reflects the engine's focus on 2D game development with a robust editor toolset and scripting capabilities, while maintaining clear separation between editor and runtime components.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef editor fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef platform fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef scripting fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef thirdparty fill:#FFD700,stroke:#333,stroke-width:2px

    %% Editor Layer
    subgraph EditorLayer
        EditorUI["Editor UI System"]:::editor
        ProjectMgmt["Project Management"]:::editor
        BuildSys["Build System"]:::editor
        ScriptMgmt["Script Management"]:::editor
        SceneEdit["Scene Editor"]:::editor
        AssetImport["Asset Import/Export"]:::editor
    end

    %% Engine Core Layer
    subgraph EngineCore
        Graphics["Graphics System"]:::core
        Audio["Audio System"]:::core
        Input["Input System"]:::core
        AssetMgmt["Asset Management"]:::core
        SceneMgmt["Scene Management"]:::core
        CompSys["Component System"]:::core
        MathPhys["Math/Physics"]:::core
    end

    %% Scripting Layer
    subgraph ScriptingLayer
        CSharpRuntime["C# Runtime (.NET 8)"]:::scripting
        CompScript["Component Scripting"]:::scripting
        NativeBindings["Native Bindings"]:::scripting
    end

    %% Platform Layer
    subgraph PlatformLayer
        GLFW["GLFW"]:::thirdparty
        OpenGL["OpenGL"]:::thirdparty
        SoLoud["SoLoud"]:::thirdparty
        ImGui["ImGui"]:::thirdparty
        DotNet[".NET SDK"]:::thirdparty
    end

    %% Relationships
    EditorUI --> Graphics
    EditorUI --> SceneMgmt
    ProjectMgmt --> AssetMgmt
    SceneEdit --> SceneMgmt
    ScriptMgmt --> CompScript
    
    Graphics --> OpenGL
    Graphics --> GLFW
    Audio --> SoLoud
    EditorUI --> ImGui
    
    CompScript --> CSharpRuntime
    CSharpRuntime --> DotNet
    CompScript --> CompSys
    
    %% Click events for component mapping
    click Graphics "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Graphics/OpenGL/"
    click Audio "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Audio/"
    click Input "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Core/Input/"
    click AssetMgmt "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Asset/"
    click SceneMgmt "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Scene/"
    click CompSys "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Component/"
    click MathPhys "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Math/"
    click EditorUI "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Editor/UI/"
    click ProjectMgmt "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Editor/Project/"
    click BuildSys "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Editor/Build/"
    click ScriptMgmt "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Editor/Script/"
    click SceneEdit "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Editor/Scene/"
    click CSharpRuntime "https://github.com/Rageking8/Planar-Engine/tree/main/Script/Planar/Engine/"
    click CompScript "https://github.com/Rageking8/Planar-Engine/blob/main/Include/Planar/Engine/Component/Script.hpp"
    click NativeBindings "https://github.com/Rageking8/Planar-Engine/tree/main/Include/Planar/Engine/Export/"
    click GLFW "https://github.com/Rageking8/Planar-Engine/tree/main/ThirdParty/GLFW/"
    click ImGui "https://github.com/Rageking8/Planar-Engine/tree/main/ThirdParty/ImGui/"
    click SoLoud "https://github.com/Rageking8/Planar-Engine/tree/main/ThirdParty/SoLoud/"
    click DotNet "https://github.com/Rageking8/Planar-Engine/tree/main/ThirdParty/dotnet-sdk/"
```
