# seekrs/macrolibx architecture

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

- Interactive diagram: https://gitdiagram.com/seekrs/macrolibx
- Repository: https://github.com/seekrs/macrolibx

## Overview

##### Main Components

- Core/Runtime Module:
- This includes the “runtime” folder which contains major submodules such as Core, Graphics, Renderer, and Platform.
- Components like Application, EventBus, and EventListener under the Core area.
- Mention submodules like Scene, Mesh, Font, and Sprite inside the Graphics module.

- Renderer Subsystem:
- “runtime/Includes/Renderer” and particularly its pipelines and render passes.
- That this subsystem handles swapchains, pipelines (including shader and graphics pipelines) as well as dynamic render passes (2DPass, FinalPass, etc).

- Platform and Integration Layer:
- “runtime/Includes/Platform” for windowing and input management.
- That SDL2 is used as the window/notification handling layer across platforms.

- Third-Party Libraries:
- That these play supporting roles for graphics and multimedia functionality.

- Build and Deployment:
- Build tooling (Makefile, xmake.lua, and various build scripts) as an important component that handles compiling the library and example applications.
- CI/CD workflows from the “.github” folder, indicating the support for multiple operating systems (Linux, macOS, Windows).

- Example and In-Depth Features:
- “example” and “in_depth_features” directories to show sample usage and specialized functionalities (e.g., GetProcAddr and RTT implementations).

##### Relationships and Interactions

- Data Flow Between Components:
- How the Core module initializes and coordinates events, while the Renderer module interacts with SDL2 and Vulkan for drawing operations.

- Dependencies:
- That the Core interacts with external libraries (SDL2 for windowing, Vulkan for rendering) and the third-party modules that extend its functionality.

- Integration Points:

##### Architectural Patterns and Principles

- Modular Design:

- Abstraction Layers:
- Demonstrate an abstraction from low-level rendering (Vulkan integration) to higher-level user-friendly APIs (functions exposed through “includes”).

- Cross-Platform Support:
- Make a note that configurations and different build scripts support multiple operating systems (as defined in the README and GitHub workflows).

##### Putting It All Together

- “Graphics” to “Renderer” (which further connects to Vulkan and SDL2) to show the pipeline and rendering flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client Applications"]:::client
    MLX["MacroLibX Library"]:::library
    Client -->|"links against"| MLX

    %% Runtime Modules Subgraph
    subgraph "Runtime Modules"
        subgraph "Core Module"
            CH["Core Headers"]:::core
            CS["Core Sources"]:::core
        end
        subgraph "Graphics Engine"
            GH["Graphics Headers"]:::graphics
            GS["Graphics Sources"]:::graphics
        end
        subgraph "Renderer Subsystem"
            RH["Renderer Headers"]:::renderer
            RS["Renderer Sources"]:::renderer
        end
        subgraph "Platform Interface"
            PH["Platform Headers"]:::platform
            PS["Platform Sources"]:::platform
        end
    end

    %% Third-Party Libraries Subgraph
    subgraph "Third-Party Libraries"
        subgraph "Vulkan"
            V["Vulkan Integration"]:::thirdparty
        end
        subgraph "Other Libraries"
            SI["stb_image"]:::thirdparty
            SRP["stb_rect_pack"]:::thirdparty
            STT["stb_truetype"]:::thirdparty
            VK["vk_video Codecs"]:::thirdparty
        end
    end

    %% Build and Deployment Subgraph
    subgraph "Build & Deployment"
        BT["Build Tools"]:::build
        CD["CI/CD Workflows"]:::build
    end

    %% Examples and In-Depth Features Subgraph
    subgraph "Examples & In-Depth Features"
        EA["Example Applications"]:::example
        IDF["In-Depth Features"]:::example
    end

    %% Main connections from MacroLibX Library to Runtime Modules
    MLX --> CH
    MLX --> GH
    MLX --> RH
    MLX --> PH

    %% Internal Runtime Modules interactions
    CH -->|"init"| GH
    CH -->|"handles_events"| PH
    GH -->|"processes_rendering"| RH
    RH -->|"executes_with"| V
    RH -->|"uses_SDL2_for_windowing"| PH

    %% Connections from MacroLibX Library to other components
    MLX --> BT
    MLX --> EA

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,color:#1B4F72;
    classDef graphics fill:#A9DFBF,stroke:#1D8348,color:#1D8348;
    classDef renderer fill:#D7BDE2,stroke:#6C3483,color:#6C3483;
    classDef platform fill:#F9E79F,stroke:#B7950B,color:#B7950B;
    classDef thirdparty fill:#F5B7B1,stroke:#922B21,color:#922B21;
    classDef build fill:#FAD7A0,stroke:#D68910,color:#D68910;
    classDef example fill:#D0ECE7,stroke:#117864,color:#117864;
    classDef client fill:#D6EAF8,stroke:#21618C,color:#21618C;
    classDef library fill:#FCF3CF,stroke:#B7950B,color:#7D6608;

    %% Click Events for Core Module
    click CH "https://github.com/seekrs/macrolibx/tree/master/runtime/Includes/Core"
    click CS "https://github.com/seekrs/macrolibx/tree/master/runtime/Sources/Core"

    %% Click Events for Graphics Module
    click GH "https://github.com/seekrs/macrolibx/tree/master/runtime/Includes/Graphics"
    click GS "https://github.com/seekrs/macrolibx/tree/master/runtime/Sources/Graphics"

    %% Click Events for Renderer Subsystem
    click RH "https://github.com/seekrs/macrolibx/tree/master/runtime/Includes/Renderer"
    click RS "https://github.com/seekrs/macrolibx/tree/master/runtime/Sources/Renderer"

    %% Click Events for Platform Interface
    click PH "https://github.com/seekrs/macrolibx/tree/master/runtime/Includes/Platform"
    click PS "https://github.com/seekrs/macrolibx/tree/master/runtime/Sources/Platform"

    %% Click Events for Third-Party Libraries
    click V "https://github.com/seekrs/macrolibx/tree/master/third_party/vulkan"
    click SI "https://github.com/seekrs/macrolibx/blob/master/third_party/stb_image.h"
    click SRP "https://github.com/seekrs/macrolibx/blob/master/third_party/stb_rect_pack.h"
    click STT "https://github.com/seekrs/macrolibx/blob/master/third_party/stb_truetype.h"
    click VK "https://github.com/seekrs/macrolibx/tree/master/third_party/vk_video"

    %% Click Events for Build and Deployment
    click BT "https://github.com/seekrs/macrolibx/tree/master/Makefile"
    click CD "https://github.com/seekrs/macrolibx/tree/master/.github/workflows"

    %% Click Events for Examples & In-Depth Features
    click EA "https://github.com/seekrs/macrolibx/tree/master/example"
    click IDF "https://github.com/seekrs/macrolibx/tree/master/in_depth_features"
```
