# lapamanstudio/kengine architecture

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

- Interactive diagram: https://gitdiagram.com/lapamanstudio/kengine
- Repository: https://github.com/lapamanstudio/kengine

## Overview

##### Project Type and Purpose
- KEngine is an open-source 2D game engine that offers both a game development runtime (engine) and an editor interface for developers.
- A supporting C# SDK component (located in KEngine.NET.SDK) provides integration, custom behavior scripting via MonoBehaviour, and other C# conveniences to tie into the underlying engine.

##### File Structure to Define Major Components
- The project is split into several areas:
- KEngine.NET.SDK: A C# component with classes like Transform.cs and Vector2.cs used for scripting behaviors and providing accessible game object components.
- core: This is the central C/C++ codebase for the engine and editor.
- The “core/include/…” and “core/src/…” directories provide headers and implementations for both the “engine” and “editor” subsystems.
- Editor components: These include directories for editor GUI (panels, window management, docking, work scene controls, etc.), graphics utilities, and scene management.
- Engine components: These include the game object management, core objects, renderer implementations and platform-specific rendering (OpenGL and DirectX).

a. Editor Module:
- Editor GUI and Window: Contains panels such as ConsolePanel, ObjectInspectorPanel, ProjectFilesPanel, and workscene specific panels.
- Editor Core: Manages project configurations, plugin integration, scene and object management.
- Graphics and Utilities in the editor: Implements drivers, font management (FontAwesome, IconsFontAwesome5), and GUI utilities.
b. Engine (Runtime) Module:
- Core Engine: Handles game objects (GameObject, components like Transform, Camera, Renderer, Script).
- Rendering and Platform Abstraction: Supports both OpenGL and DirectX rendering through specialized helper classes (e.g., GLGraphicHelper, DXGraphicHelper) and window management (GLWindow, DXWindow).
- Script Management: Links functionality to scripted behavior (using classes like MonoBehaviour and Script from the engine).
c. SDK / Integration Module:
- KEngine.NET.SDK: Provides .NET (C#) components that likely wrap or simplify interactions with the engine for simpler game development.
d. Installer and Packaging Module:
- Installer Scripts and Configuration: Contains scripts (Makefile, installer directory contents) used for building and packaging the engine into an installer.

##### Relationships and Interactions
- The Engine module’s platform abstraction (OpenGL/DirectX) abstracts graphics and window creation, enabling both the editor and runtime portions to access rendering functionalities in a unified manner.
- The SDK serves as a bridge between high-level C# game logic and the underlying engine, enabling scripting and custom extensions.
- External libraries such as GLFW, GLM, FreeType, ImGui, and JSON are used by both the engine and editor components for windowing, math utilities, font rendering, GUI, and configuration/data parsing respectively.

##### Architectural Patterns and Design Principles
- Modular design: The clear separation between the editor and engine components helps isolate concerns (rendering, scene management, editor UI).
- Platform abstraction: The engine supports multiple rendering APIs (OpenGL vs. DirectX) through a unified design using helper/factory classes.
- Extensibility: The use of a C# SDK along with plugin integration in the engine ensures that the architecture can be extended as new features like a sprite editor or 3D components are added.

## Diagram (Mermaid)

```mermaid
flowchart TD

    ExtLib["External Libraries (GLFW,GLM,FreeType,ImGui,JSON)"]:::external

    subgraph "Editor Module"
        Editor_Inc["Editor (Include)"]:::editor
        Editor_Src["Editor (Source)"]:::editor
    end

    subgraph "Engine Module"
        Engine_Inc["Engine (Include)"]:::engine
        Engine_Src["Engine (Source)"]:::engine
        Rendering["Rendering API (OpenGL/DirectX)"]:::engine
        ScriptMgr["Script Manager"]:::engine
    end

    SDK["C# SDK Module"]:::sdk

    subgraph "Installer and Packaging Module"
        Installer["Installer & Packaging"]:::installer
        MakefileNode["Makefile"]:::installer
    end

    ExtLib -->|"uses"| Editor_Inc
    ExtLib -->|"uses"| Engine_Inc

    Editor_Inc -->|"calls"| Engine_Inc
    Editor_Src -->|"calls"| Engine_Src

    SDK -->|"wraps"| Engine_Inc
    SDK -->|"extends"| Editor_Inc

    Installer -->|"packages"| Editor_Inc
    Installer -->|"packages"| Engine_Inc
    Installer --> MakefileNode

    click Editor_Inc "https://github.com/lapamanstudio/kengine/tree/develop/core/include/editor"
    click Editor_Src "https://github.com/lapamanstudio/kengine/tree/develop/core/src/editor"
    click Engine_Inc "https://github.com/lapamanstudio/kengine/tree/develop/core/include/engine"
    click Engine_Src "https://github.com/lapamanstudio/kengine/tree/develop/core/src/engine"
    click SDK "https://github.com/lapamanstudio/kengine/blob/develop/KEngine.NET.SDK"
    click Installer "https://github.com/lapamanstudio/kengine/tree/develop/installer"
    click MakefileNode "https://github.com/lapamanstudio/kengine/tree/develop/Makefile"

    classDef editor fill:#F8BF1C,stroke:#000,stroke-width:2px;
    classDef engine fill:#33A02C,stroke:#000,stroke-width:2px;
    classDef sdk fill:#1F78B4,stroke:#000,stroke-width:2px;
    classDef installer fill:#E31A1C,stroke:#000,stroke-width:2px;
    classDef external fill:#6A3D9A,stroke:#000,stroke-width:2px;
```
