# awolven/krma architecture

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

## Overview

##### Main Components

a) Application Layer
- Application interface (application-mixin.lisp)
- Scene management (scene-mixin.lisp)
- Demonstrate CLUI support integration (clui-support.lisp)

b) Graphics Pipeline
- Vulkan Backend (vulkan-pipelines.lisp)
- Shader Components (*.vert and *.frag files)
- Pipeline Combinations (pipeline-combinations.lisp)

c) Rendering Systems
- Materials System (materials.lisp)
- Lighting System (lights.lisp)
- Text Rendering (text.lisp)

d) Resource Management
- Foreign Arrays Handler (foreign-arrays.lisp)
- Texture Management (implied by texture.frag)
- Groups System (groups.lisp)

**[Application Layer]**
- ↓
**[Scene Management]**
- ↓
**[Graphics Pipeline]**
- ↓
**[Rendering Systems]**
- ↓
**[Resource Management]**
- ↓
**[Vulkan Backend]**

##### Key Relationships to Highlight

- Bidirectional flow between Scene Management and Graphics Pipeline
- Demonstrate the relationship between shaders and the pipeline system
- Platform-specific backends (MacOS/Cocoa, Windows/Win32, Linux/X11)

##### Specific Elements

- Immediate Mode vs. Retained Mode rendering paths
- Platform abstraction layer
- Shader management system
- Memory management for graphics resources
- Text rendering pipeline with MSDF support
- External dependencies (show key submodules like cl-vulkan, 3d-math)

##### Data Flow Indicators

- How rendering commands flow from application to GPU
- Resource loading paths
- Demonstrate memory management flow
- How different rendering modes interact

##### Technical Details to Emphasize

- Vulkan integration points
- Platform-specific windowing system interfaces
- Memory management strategies
- Shader compilation and management
- Pipeline state management

- Component groupings
- Platform-specific elements

This will create a comprehensive visualization of KRMA's architecture while maintaining clarity and usefulness for technical discussions and system understanding.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#e1f5fe,stroke:#01579b
    classDef platform fill:#fff3e0,stroke:#ff6f00
    classDef resource fill:#e8f5e9,stroke:#2e7d32
    classDef shader fill:#f3e5f5,stroke:#7b1fa2
    classDef external fill:#fce4ec,stroke:#c2185b

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Platform Components]:::platform
        L3[Resource Management]:::resource
        L4[Shader Components]:::shader
        L5[External Dependencies]:::external
    end

    %% Application Layer
    subgraph ApplicationLayer
        App[Application Interface]:::core
        Scene[Scene Management]:::core
        CLUI[CLUI Support]:::core
    end
    click App "https://github.com/awolven/krma/blob/main/application-mixin.lisp"
    click Scene "https://github.com/awolven/krma/blob/main/scene-mixin.lisp"
    click CLUI "https://github.com/awolven/krma/blob/main/clui-support.lisp"

    %% Graphics Pipeline
    subgraph GraphicsPipeline
        VulkanBackend[Vulkan Backend]:::core
        PipelineMgr[Pipeline Management]:::core
    end
    click VulkanBackend "https://github.com/awolven/krma/blob/main/vulkan-pipelines.lisp"
    click PipelineMgr "https://github.com/awolven/krma/blob/main/pipeline-combinations.lisp"

    %% Rendering Systems
    subgraph RenderingSystems
        DrawList[Draw List System]:::core
        Materials[Materials System]:::core
        Lights[Lighting System]:::core
        TextRender[Text Rendering]:::core
    end
    click DrawList "https://github.com/awolven/krma/blob/main/draw-list.lisp"
    click Materials "https://github.com/awolven/krma/blob/main/materials.lisp"
    click Lights "https://github.com/awolven/krma/blob/main/lights.lisp"
    click TextRender "https://github.com/awolven/krma/blob/main/text.lisp"

    %% Resource Management
    subgraph ResourceMgmt
        ForeignArrays[Foreign Arrays]:::resource
        Groups[Groups System]:::resource
    end
    click ForeignArrays "https://github.com/awolven/krma/blob/main/foreign-arrays.lisp"
    click Groups "https://github.com/awolven/krma/blob/main/groups.lisp"

    %% Shader Components
    subgraph Shaders
        Vert3DN["3D with Normal Vertex"]:::shader
        Vert2D["Standard 2D Vertex"]:::shader
        Vert3D["Standard 3D Vertex"]:::shader
        FragLT["Lighting+Texture Fragment"]:::shader
        FragTex["Texture Fragment"]:::shader
        FragMSDF["MSDF Texture Fragment"]:::shader
    end
    click Vert3DN "https://github.com/awolven/krma/blob/main/3d-with-normal.vert"
    click Vert2D "https://github.com/awolven/krma/blob/main/standard-2d.vert"
    click Vert3D "https://github.com/awolven/krma/blob/main/standard-3d.vert"
    click FragLT "https://github.com/awolven/krma/blob/main/lighting+texture.frag"
    click FragTex "https://github.com/awolven/krma/blob/main/texture.frag"
    click FragMSDF "https://github.com/awolven/krma/blob/main/msdf-texture.frag"

    %% External Dependencies
    subgraph ExternalDeps
        CLVulkan[CL-Vulkan]:::external
        Math3D["3D-Math"]:::external
        CLUILib[CLUI]:::external
        ShaderBin["KRMA Shader Bin"]:::external
    end
    click CLVulkan "https://github.com/awolven/krma/tree/main/submodules/cl-vulkan"
    click Math3D "https://github.com/awolven/krma/tree/main/submodules/3d-math"
    click CLUILib "https://github.com/awolven/krma/tree/main/submodules/clui"
    click ShaderBin "https://github.com/awolven/krma/tree/main/submodules/krma-shader-bin"

    %% Relationships
    App --> Scene
    Scene --> CLUI
    Scene --> DrawList
    DrawList --> VulkanBackend
    VulkanBackend --> PipelineMgr
    PipelineMgr --> Shaders
    Materials --> DrawList
    Lights --> DrawList
    TextRender --> DrawList
    DrawList --> ResourceMgmt
    VulkanBackend --> ResourceMgmt
    VulkanBackend --> CLVulkan
    App --> Math3D
    CLUI --> CLUILib
    Shaders --> ShaderBin
```
