# libretro/ludo architecture

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

- Interactive diagram: https://gitdiagram.com/libretro/ludo
- Repository: https://github.com/libretro/ludo

## Overview

##### Main Components

a. Core Components:
- Libretro Interface Layer (/libretro)
- Core System (/core)
- Video Subsystem (/video)
- Audio Subsystem (/audio)
- Input System (/input)
- Menu System (/menu)

b. Supporting Components:
- State Management (/state)
- Settings Management (/settings)
- Save Systems (/savefiles, /savestates)
- Scanner (/scanner)
- Playlists (/playlists)
- Notifications System (/notifications)

**┌─ User Interface Layer ─────────────────┐**
- Menu System | Notifications | Input UI │
- Application Layer ───────────────────┐│
- Scanner | Playlists | History        ││
- Core Services ─────────────────────┐││
- State | Settings | SaveStates      │││
- Media Layer ───────────────────┐  │││
- Video | Audio | Input          │  │││
- Libretro Layer ─────────────┐ │  │││
- Core Loading | Core Control  │ │  │││
- ┘─┘──┘─┘

##### Component Relationships

- Libretro Layer ↔ Media Layer (core output/input)
- Media Layer ↔ UI Layer (display/sound/controls)
- Core Services → All Layers (state/settings access)
- Application Layer ↔ UI Layer (user interaction)

##### Technical Details

Annotations for:
- Go-specific implementations
- Platform-specific components (video_darwin.go vs video_notdarwin.go)
- Core loading mechanisms
- File system interactions

##### External Dependencies

Connections to:
- OpenGL (>= 2.1)
- OpenAL
- GLFW 3.3
- Libretro cores

##### The central role of the libretro interface

This architecture reflects a modern gaming frontend with clear separation of concerns and modular design, making it maintainable and extensible.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef data fill:#FFD700,stroke:#333,stroke-width:2px
    classDef support fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef media fill:#4169E1,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph UI
        Menu["Menu System"]
        Notif["Notifications"]
        InputUI["Input UI"]
    end

    %% Application Layer
    subgraph APP
        Scanner["Scanner"]
        Playlists["Playlists"]
        History["History"]
    end

    %% Core Services
    subgraph Services
        State["State Management"]
        Settings["Settings"]
        SaveStates["Save States"]
        SaveFiles["Save Files"]
    end

    %% Media Layer
    subgraph Media
        Video["Video System"]
        Audio["Audio System"]
        Input["Input System"]
    end

    %% Libretro Layer
    subgraph Libretro
        CoreLoad["Core Loading"]
        CoreCtrl["Core Control"]
    end

    %% External Dependencies
    subgraph External
        OpenGL["OpenGL >= 2.1"]
        OpenAL["OpenAL"]
        GLFW["GLFW 3.3"]
    end

    %% Relationships
    CoreLoad --> CoreCtrl
    CoreCtrl --> Video
    CoreCtrl --> Audio
    CoreCtrl --> Input
    Video --> Menu
    Audio --> Menu
    Input --> InputUI
    Scanner --> Playlists
    State --> CoreCtrl
    Settings --> CoreCtrl
    SaveStates --> CoreCtrl
    SaveFiles --> CoreCtrl
    Menu --> Notif
    Video --> OpenGL
    Audio --> OpenAL
    Input --> GLFW

    %% Click events for component mapping
    click Menu "https://github.com/libretro/ludo/blob/master/menu/menu.go"
    click Notif "https://github.com/libretro/ludo/blob/master/notifications/notifications.go"
    click Input "https://github.com/libretro/ludo/blob/master/input/input.go"
    click Scanner "https://github.com/libretro/ludo/blob/master/scanner/scanner.go"
    click Playlists "https://github.com/libretro/ludo/blob/master/playlists/playlists.go"
    click State "https://github.com/libretro/ludo/blob/master/state/state.go"
    click Settings "https://github.com/libretro/ludo/blob/master/settings/settings.go"
    click SaveStates "https://github.com/libretro/ludo/blob/master/savestates/savestates.go"
    click SaveFiles "https://github.com/libretro/ludo/blob/master/savefiles/savefiles.go"
    click Video "https://github.com/libretro/ludo/blob/master/video/video.go"
    click Audio "https://github.com/libretro/ludo/blob/master/audio/audio.go"
    click CoreLoad "https://github.com/libretro/ludo/blob/master/libretro/libretro.go"
    click CoreCtrl "https://github.com/libretro/ludo/blob/master/core/core.go"

    %% Style applications
    class Menu,Notif,InputUI ui
    class CoreLoad,CoreCtrl core
    class State,Settings,SaveStates,SaveFiles data
    class Scanner,Playlists,History support
    class Video,Audio,Input media

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Core_L["Core Components"]:::core
        Data_L["Data Management"]:::data
        Support_L["Support Services"]:::support
        Media_L["Media Components"]:::media
    end
```
