# jan-peltner/rlgl-template architecture

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

- Interactive diagram: https://gitdiagram.com/jan-peltner/rlgl-template
- Repository: https://github.com/jan-peltner/rlgl-template

## Overview

##### Main Components
- Application Core: Represented by src/main.c where the core logic resides.
- Window Manager: Represented by src/window.c and its header (window.h) that manage the window setup/configuration.
- Shader System: Comprising two files in the shaders/ directory — main.vert for the vertex shader and main.frag for the fragment shader. These are loaded and used by the Application Core.
- External Dependencies: Include raylib (for graphics handling and windowing) and the OpenGL 3.3+ support. Also note the C compiler and build environment required.
- Build & Run Scripts: The build.sh and run.sh scripts that automate the compilation and execution of the project (leading to a bin/ output folder).

##### Out Component Relationships
- The Application Core (main.c) is the central orchestrator that initializes components.
- It calls functions from the Window Manager to create and configure the application window.
- The Application Core loads and applies the shader files to create the desired shader effects.
- Build process: from build.sh generating output in bin/ and run.sh consuming that output.

##### Architectural Patterns & Design Principles
- Modular Design: Shaders are maintained as external files, making it easy to customize visual effects without touching the core codebase.
- External Library Integration: Emphasize how raylib and OpenGL provide core graphical functionalities without the need for extensive in-house implementations.

##### Final Touch

This detailed, structured approach will provide a comprehensive overview of the system’s architecture, making it easy to understand component interactions and enhancing future maintainability or customization. Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        A["Application Core (main.c)"]:::internal
    end

    subgraph "Window Manager"
        B1["Window Manager (window.c)"]:::internal
        B2["Window Manager (window.h)"]:::internal
    end

    subgraph "Color Palette"
        C1["Color Palette (colors.c)"]:::internal
        C2["Color Palette (colors.h)"]:::internal
    end

    subgraph "Shaders"
        D1["Vertex Shader (main.vert)"]:::internal
        D2["Fragment Shader (main.frag)"]:::internal
    end

    E["External Dependencies (raylib & OpenGL, C Compiler)"]:::external

    subgraph "Build & Run"
        F1["Build Script (build.sh)"]:::script
        F2["Run Script (run.sh)"]:::script
        G["Build Output (bin/)"]:::script
    end

    H["Real-time Performance Metrics (Overlay)"]:::note

    %% Relationships
    A -->|"initWindow"| B1
    A -->|"initWindow"| B2
    A -->|"applyColors"| C1
    A -->|"applyColors"| C2
    A -->|"loadShaders"| D1
    A -->|"loadShaders"| D2
    A -->|"useDeps"| E
    A -->|"displayMetrics"| H

    F1 -->|"produces"| G
    F2 -->|"consumes"| G

    %% Click Events
    click A "https://github.com/jan-peltner/rlgl-template/blob/master/src/main.c"
    click B1 "https://github.com/jan-peltner/rlgl-template/blob/master/src/window.c"
    click B2 "https://github.com/jan-peltner/rlgl-template/blob/master/src/window.h"
    click C1 "https://github.com/jan-peltner/rlgl-template/blob/master/src/colors.c"
    click C2 "https://github.com/jan-peltner/rlgl-template/blob/master/src/colors.h"
    click D1 "https://github.com/jan-peltner/rlgl-template/blob/master/shaders/main.vert"
    click D2 "https://github.com/jan-peltner/rlgl-template/blob/master/shaders/main.frag"
    click F1 "https://github.com/jan-peltner/rlgl-template/blob/master/build.sh"
    click F2 "https://github.com/jan-peltner/rlgl-template/blob/master/run.sh"

    %% Styles
    classDef internal fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px,color:#000000;
    classDef external fill:#C8E6C9,stroke:#43A047,stroke-width:2px,color:#000000;
    classDef script fill:#FFCC80,stroke:#FB8C00,stroke-width:2px,color:#000000;
    classDef note fill:#FFF9C4,stroke:#FDD835,stroke-dasharray: 5, 5,stroke-width:2px,color:#000000;
```
