# g3n/engine architecture

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

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

## Overview

##### Main Components Organization

- Application Layer                                      |

- Window      |  |        GUI       |  |      Scene       |  |     Renderer     | |

- Core Engine Layer                                      |

- Graphics     |  |      Audio       |  |     Physics      |  |     Camera       | |

- Foundation Layer                                       |

- Math32      |  |       GLS        |  |    Geometry     |  |    Material      | |

##### Component Details and Relationships

Key relationships to highlight:

**a. Core Components:**
- Scene Graph → Node Management
- Renderer → OpenGL Abstraction (GLS)
- Audio System → OpenAL Integration
- Physics Engine → Collision Detection

**b. Resource Management:**
- Texture Loading
- Model Loading (GLTF, OBJ, COLLADA)
- Shader Management
- Audio Resource Handling

**c. Cross-cutting Concerns:**
- Event System
- Resource Management
- Memory Management

##### Platform-specific Components

- Platform Layer      |

- Desktop (GLFW)       |
- Browser (WebAssembly)|
- Audio Backends       |

##### Detailed Component Breakdown

For each major component, show internal structure:

**Graphics Pipeline:**

- Geometry Data | --> | Shader System | --> | Frame Buffer  |

**Scene Graph:**

- Scene Nodes | --> | Transformations | --> | Rendering |

##### Important Subsystems

**GUI System:**
- Widgets
- Layouts
- Event Handling

**Audio System:**
- Spatial Audio
- Format Support
- Audio Playback

**Physics:**
- Collision Detection
- Rigid Body Dynamics
- Constraints

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef application fill:#a8d1ff,stroke:#333
    classDef core fill:#ffb366,stroke:#333
    classDef foundation fill:#90EE90,stroke:#333
    classDef platform fill:#d4d4d4,stroke:#333
    classDef resource fill:#ffff99,stroke:#333

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        Window["Window Management"]
        GUI["GUI System"]
        Scene["Scene Management"]
        Renderer["Renderer"]
    end

    %% Core Engine Layer
    subgraph CoreLayer["Core Engine Layer"]
        Graphics["Graphics Pipeline"]
        Audio["Audio System"]
        Physics["Physics Engine"]
        Camera["Camera System"]
    end

    %% Foundation Layer
    subgraph FoundationLayer["Foundation Layer"]
        Math["Math32"]
        GLS["GLS (OpenGL)"]
        Geometry["Geometry"]
        Material["Material System"]
    end

    %% Platform Layer
    subgraph PlatformLayer["Platform Layer"]
        Desktop["Desktop (GLFW)"]
        Browser["Browser (WebAssembly)"]
        AudioBackends["Audio Backends"]
    end

    %% Resource Management
    subgraph ResourceMgmt["Resource Management"]
        TextureLoader["Texture Loading"]
        ModelLoader["Model Loading"]
        ShaderMgmt["Shader Management"]
        EventSystem["Event System"]
    end

    %% Relationships
    Scene --> Graphics
    Scene --> EventSystem
    Renderer --> GLS
    Renderer --> ShaderMgmt
    Graphics --> GLS
    Audio --> AudioBackends
    Physics --> Math
    Camera --> Math
    GUI --> EventSystem
    Window --> Desktop
    Window --> Browser
    Material --> ShaderMgmt
    Geometry --> Math

    %% Click events for component mapping
    click Window "https://github.com/g3n/engine/blob/master/window/window.go"
    click GUI "https://github.com/g3n/engine/blob/master/gui/manager.go"
    click Scene "https://github.com/g3n/engine/blob/master/core/node.go"
    click Renderer "https://github.com/g3n/engine/blob/master/renderer/renderer.go"
    click Graphics "https://github.com/g3n/engine/blob/master/gls/gls.go"
    click Audio "https://github.com/g3n/engine/blob/master/audio/player.go"
    click Physics "https://github.com/g3n/engine/blob/master/experimental/physics/simulation.go"
    click Camera "https://github.com/g3n/engine/blob/master/camera/camera.go"
    click Math "https://github.com/g3n/engine/blob/master/math32/matrix4.go"
    click Geometry "https://github.com/g3n/engine/blob/master/geometry/geometry.go"
    click Material "https://github.com/g3n/engine/blob/master/material/material.go"
    click ModelLoader "https://github.com/g3n/engine/blob/master/loader/gltf/loader.go"
    click EventSystem "https://github.com/g3n/engine/blob/master/core/dispatcher.go"
    click Desktop "https://github.com/g3n/engine/blob/master/app/app-desktop.go"
    click Browser "https://github.com/g3n/engine/blob/master/app/app-browser.go"

    %% Legend
    subgraph Legend
        L1["Application Components"]:::application
        L2["Core Components"]:::core
        L3["Foundation Components"]:::foundation
        L4["Platform Components"]:::platform
        L5["Resource Management"]:::resource
    end
```
