# stickyfingies/gengine architecture

> Architecture diagram of the GitHub repository stickyfingies/gengine, 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/stickyfingies/gengine
- Repository: https://github.com/stickyfingies/gengine

## Overview

##### Main Components Structure

a) Application Layer
- Examples/native.cpp and examples/javascript.js as entry points
- To the Core Engine layer

b) Core Engine Layer (Middle)
- Following major components:
- Asset Management (core/assets.h)
- Physics System (core/physics.h)
- Scene Management (core/scene.h)
- Camera System (core/camera.hpp)
- FPS Controller (core/fps_controller.h)
- Kernel (core/kernel.h)

c) Platform Abstraction Layer (Bottom)
- GPU Backends:
- Vulkan Implementation (gpu/gpu.vulkan.cpp)
- OpenGL Implementation (gpu/gpu.opengl.cpp)
- WebGL (through Emscripten)
- Window Management (core/window.h)

##### Dependencies Integration
- GLFW3 (Window Management)
- Bullet3 (Physics)
- Assimp (Asset Loading)
- GLM (Mathematics)
- STB (Image Loading)
- ImGui (UI System)

##### Data Flow Representation
- Asset Pipeline: Asset Files → Assimp → Asset Manager → Scene Graph
- Rendering Pipeline: Scene Graph → GPU Interface → Platform-specific Backend
- Physics Pipeline: Collision Data → Bullet3 → Physics System → Scene Graph

- Runtime Architecture
- Build System Flow
- Asset Pipeline
- Platform Abstraction Layer

Key Elements to Emphasize:
##### Build system configuration

- Adaptive GPU backend
- Cross-platform support (Linux and Web)
- Physics integration
- Asset management system
- Platform-specific optimizations

This structure will provide a clear understanding of how Gengine works across different platforms while maintaining its core functionality.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef platform fill:#2f855a,stroke:#1f5c3d,color:white
    classDef external fill:#c05621,stroke:#9c4221,color:white
    classDef asset fill:#6b46c1,stroke:#553c9a,color:white
    classDef entry fill:#805ad5,stroke:#6b46c1,color:white

    %% Legend
    subgraph Legend
        C1[Core Components]:::core
        P1[Platform Layer]:::platform
        E1[External Dependencies]:::external
        A1[Assets]:::asset
        EN1[Entry Points]:::entry
    end

    %% Application Layer
    subgraph ApplicationLayer[Application Layer]
        Native["Native Application"]:::entry
        JavaScript["JavaScript Application"]:::entry
    end
    click Native "https://github.com/stickyfingies/gengine/blob/master/examples/native.cpp"
    click JavaScript "https://github.com/stickyfingies/gengine/blob/master/examples/javascript.js"

    %% Core Engine Layer
    subgraph CoreEngine[Core Engine Layer]
        Kernel["Kernel"]:::core
        AssetMgr["Asset Management"]:::core
        Physics["Physics System"]:::core
        Scene["Scene Management"]:::core
        Camera["Camera System"]:::core
        FPSCtrl["FPS Controller"]:::core
    end
    click Kernel "https://github.com/stickyfingies/gengine/blob/master/core/kernel.h"
    click AssetMgr "https://github.com/stickyfingies/gengine/blob/master/core/assets.h"
    click Physics "https://github.com/stickyfingies/gengine/blob/master/core/physics.h"
    click Scene "https://github.com/stickyfingies/gengine/blob/master/core/scene.h"
    click Camera "https://github.com/stickyfingies/gengine/blob/master/core/camera.hpp"
    click FPSCtrl "https://github.com/stickyfingies/gengine/blob/master/core/fps_controller.h"

    %% Platform Abstraction Layer
    subgraph PlatformLayer[Platform Abstraction Layer]
        Window["Window Management"]:::platform
        GPUInterface["GPU Interface"]:::platform
        VulkanBackend["Vulkan Backend"]:::platform
        OpenGLBackend["OpenGL Backend"]:::platform
        WebGLBackend["WebGL Backend"]:::platform
    end
    click Window "https://github.com/stickyfingies/gengine/blob/master/core/window.h"
    click GPUInterface "https://github.com/stickyfingies/gengine/blob/master/gpu/gpu.h"
    click VulkanBackend "https://github.com/stickyfingies/gengine/blob/master/gpu/gpu.vulkan.cpp"
    click OpenGLBackend "https://github.com/stickyfingies/gengine/blob/master/gpu/gpu.opengl.cpp"

    %% FFI Layer
    subgraph FFILayer[FFI Layer]
        DesktopFFI["Desktop FFI"]:::platform
        WebFFI["Web FFI"]:::platform
    end
    click DesktopFFI "https://github.com/stickyfingies/gengine/blob/master/core/ffi/js.desktop.cpp"
    click WebFFI "https://github.com/stickyfingies/gengine/blob/master/core/ffi/js.web.cpp"

    %% External Dependencies
    subgraph Dependencies[External Dependencies]
        GLFW["GLFW3"]:::external
        Bullet["Bullet3"]:::external
        Assimp["Assimp"]:::external
        GLM["GLM"]:::external
        STB["STB"]:::external
        ImGui["ImGui"]:::external
    end

    %% Asset Pipeline
    subgraph Assets[Asset Pipeline]
        Shaders["Shader Files"]:::asset
        Models["3D Models"]:::asset
    end
    click Shaders "https://github.com/stickyfingies/gengine/tree/master/data"
    click Models "https://github.com/stickyfingies/gengine/tree/master/data"

    %% Connections
    Native & JavaScript --> Kernel
    Kernel --> AssetMgr & Physics & Scene & Camera & FPSCtrl
    Scene --> GPUInterface
    GPUInterface --> VulkanBackend & OpenGLBackend & WebGLBackend
    JavaScript --> DesktopFFI & WebFFI
    DesktopFFI & WebFFI --> Kernel
    AssetMgr --> Assets
    Physics --> Bullet
    Window --> GLFW
    AssetMgr --> Assimp & STB
    Scene --> GLM & ImGui
```
