# gen2brain/raylib-go architecture

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

## Overview

##### Main Components

a. Core Components:
- Raylib Core (raylib/)
- Physics Engine (physics/)
- GUI System (raygui/)
- Resource Management (rres/)
- Easing Functions (easings/)

b. Platform Support Layer:
- Desktop (Windows/Linux/macOS)
- Android
- DRM (Direct Rendering Manager)
- Multiple Backend Options (GLFW/SDL/RGFW)

##### Architectural Layers

Layer 1 (Top) - Go API Interface:
- Public Go bindings
- Type conversions
- Memory management

Layer 2 - Bridge Layer:
- CGO bindings
- Platform-specific implementations
- Pure Go implementation (Windows)

Layer 3 - Native Implementation:
- Raylib C core
- External dependencies
- Platform-specific code

##### Component Relationships

**[Go Applications]**
- ↓
**[Raylib-Go Bindings]**
- ↓
**[CGO/PureGo Bridge]**
- ↙   ↓   ↘
**[GLFW] [SDL] [RGFW]**
- ↘   ↓   ↙
**[Graphics Backend]**
- ↓
**[Platform Layer]**

##### Implementation Details

- Physics engine integration
- GUI system
- Resource management
- Platform-specific code

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Go Applications"
        APP[Client Applications]
    end

    subgraph "Go API Interface"
        AUDIO[Audio System]:::core
        GRAPHICS[Graphics System]:::core
        SHAPES[Shapes System]:::core
        TEXT[Text System]:::core
        TEXTURES[Textures System]:::core
        MODELS[Models System]:::core
    end

    subgraph "Core Components"
        RAYLIB[Raylib Core]:::core
        PHYSICS[Physics Engine]:::core
        GUI[GUI System]:::core
        RRES[Resource Management]:::core
        EASINGS[Easing Functions]:::core
    end

    subgraph "Bridge Layer"
        CGO[CGO Bindings]:::bridge
        PUREGO[Pure Go Windows]:::bridge
    end

    subgraph "Platform Support"
        GLFW[GLFW Backend]:::platform
        SDL[SDL Backend]:::platform
        RGFW[RGFW Backend]:::platform
        ANDROID[Android Platform]:::platform
        DRM[DRM Platform]:::platform
    end

    subgraph "External Dependencies"
        DEPS[External Libraries]:::external
    end

    %% Connections
    APP --> AUDIO & GRAPHICS & SHAPES & TEXT & TEXTURES & MODELS
    AUDIO & GRAPHICS & SHAPES & TEXT & TEXTURES & MODELS --> RAYLIB
    RAYLIB --> PHYSICS & GUI & RRES & EASINGS
    RAYLIB --> CGO & PUREGO
    CGO & PUREGO --> GLFW & SDL & RGFW
    GLFW & SDL & RGFW --> ANDROID & DRM
    ANDROID & DRM --> DEPS

    %% Click Events
    click RAYLIB "https://github.com/gen2brain/raylib-go/tree/master/raylib/"
    click PHYSICS "https://github.com/gen2brain/raylib-go/tree/master/physics/"
    click GUI "https://github.com/gen2brain/raylib-go/tree/master/raygui/"
    click RRES "https://github.com/gen2brain/raylib-go/tree/master/rres/"
    click EASINGS "https://github.com/gen2brain/raylib-go/tree/master/easings/"
    click ANDROID "https://github.com/gen2brain/raylib-go/blob/master/raylib/platforms/rcore_android.c"
    click GLFW "https://github.com/gen2brain/raylib-go/blob/master/raylib/platforms/rcore_desktop_glfw.c"
    click SDL "https://github.com/gen2brain/raylib-go/blob/master/raylib/platforms/rcore_desktop_sdl.c"
    click RGFW "https://github.com/gen2brain/raylib-go/blob/master/raylib/platforms/rcore_desktop_rgfw.c"
    click DRM "https://github.com/gen2brain/raylib-go/blob/master/raylib/platforms/rcore_drm.c"
    click CGO "https://github.com/gen2brain/raylib-go/blob/master/raylib/cgo.go"
    click PUREGO "https://github.com/gen2brain/raylib-go/blob/master/raylib/purego_windows.go"
    click AUDIO "https://github.com/gen2brain/raylib-go/blob/master/raylib/raudio.go"
    click GRAPHICS "https://github.com/gen2brain/raylib-go/blob/master/raylib/rlgl.go"
    click SHAPES "https://github.com/gen2brain/raylib-go/blob/master/raylib/rshapes.go"
    click TEXT "https://github.com/gen2brain/raylib-go/blob/master/raylib/rtext.go"
    click TEXTURES "https://github.com/gen2brain/raylib-go/blob/master/raylib/rtextures.go"
    click MODELS "https://github.com/gen2brain/raylib-go/blob/master/raylib/rmodels.go"
    click DEPS "https://github.com/gen2brain/raylib-go/tree/master/raylib/external/"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef platform fill:#2ecc71,stroke:#27ae60,color:white
    classDef bridge fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Platform Support]:::platform
        L3[Bridge Layer]:::bridge
        L4[External Dependencies]:::external
    end
```
