# webosbrew/retroarch architecture

> Architecture diagram of the GitHub repository webosbrew/retroarch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/webosbrew/retroarch
- Repository: https://github.com/webosbrew/retroarch

## Overview

RetroArch is the reference frontend for the libretro API. Its main workflow is to launch a libretro core, manage its lifecycle, and route the core’s audio, video, and input callbacks to platform-facing drivers. The README also documents shaders, rewind, recording, run-ahead, playlists, and achievements, so these appear as supporting capabilities. The tree and excerpts establish component locations, but provide little direct wiring evidence for the main runtime; those links are marked unverified rather than presented as inspected calls.

Main entry points: [`retroarch.h`](https://github.com/webosbrew/retroarch/blob/webos/retroarch.h) (RetroArch Frontend), [`core.h`](https://github.com/webosbrew/retroarch/blob/webos/core.h) (Libretro Core), [`menu/menu_driver.h`](https://github.com/webosbrew/retroarch/blob/webos/menu/menu_driver.h) (Menu UI), [`content.h`](https://github.com/webosbrew/retroarch/blob/webos/content.h) (Content Loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Frontend Lifecycle"]
  node_frontend["RetroArch Frontend<br/>[retroarch.h]"]
  node_config["Configuration<br/>[configuration.c]"]
  node_menu["Menu UI<br/>[menu_driver.h]"]
  node_core["Libretro Core<br/>[core.h]"]
end

subgraph group_io["Platform I/O"]
  node_video["Video Output"]
  node_audio["Audio Output<br/>[audio_driver.c]"]
  node_input["Input Drivers<br/>[input_driver.h]"]
  node_shader["Shader Pipeline"]
end

subgraph group_library["Core and Library Management"]
  node_content["Content Loading<br/>[content.h]"]
  node_coreinfo["Core Metadata<br/>[core_info.h]"]
  node_playlist["Playlists"]
end

subgraph group_runtime["Runtime Features"]
  node_rewind["Rewind and States<br/>[state_manager.c]"]
  node_recording["Video Recording"]
  node_run_ahead["Run-Ahead<br/>[runloop.h]"]
  node_cheats["Cheat Manager<br/>[cheat_manager.c]"]
end

subgraph group_metadata["Metadata and Services"]
  node_achievements["Achievements<br/>[cheevos.c]"]
  node_database[("Game Database<br/>[query.c]")]
end

node_user(("Player"))
node_achievement_service{{"Achievement Service"}}

node_user -->|"uses"| node_frontend
node_frontend -.->|"loads core"| node_core
node_frontend -.->|"reads settings"| node_config
node_frontend -.->|"presents UI"| node_menu
node_menu -.->|"selects content"| node_content
node_content -.->|"provides content"| node_core
node_core -->|"sends callbacks"| node_frontend
node_frontend -->|"routes video"| node_video
node_frontend -->|"routes audio"| node_audio
node_frontend -->|"routes input"| node_input
node_frontend -.->|"queries metadata"| node_coreinfo
node_frontend -.->|"manages playlists"| node_playlist
node_frontend -->|"applies shaders"| node_shader
node_frontend -->|"supports rewind"| node_rewind
node_frontend -->|"supports recording"| node_recording
node_frontend -->|"supports run-ahead"| node_run_ahead
node_frontend -.->|"manages cheats"| node_cheats
node_frontend -.->|"tracks achievements"| node_achievements
node_achievements -.->|"uses service"| node_achievement_service
node_frontend -.->|"queries metadata"| node_database

click node_frontend "https://github.com/webosbrew/retroarch/blob/webos/retroarch.h"
click node_config "https://github.com/webosbrew/retroarch/blob/webos/configuration.c"
click node_menu "https://github.com/webosbrew/retroarch/blob/webos/menu/menu_driver.h"
click node_core "https://github.com/webosbrew/retroarch/blob/webos/core.h"
click node_content "https://github.com/webosbrew/retroarch/blob/webos/content.h"
click node_coreinfo "https://github.com/webosbrew/retroarch/blob/webos/core_info.h"
click node_playlist "https://github.com/webosbrew/retroarch/blob/webos/tasks/task_playlist_manager.c"
click node_video "https://github.com/webosbrew/retroarch/tree/webos/gfx"
click node_audio "https://github.com/webosbrew/retroarch/blob/webos/audio/audio_driver.c"
click node_input "https://github.com/webosbrew/retroarch/blob/webos/input/input_driver.h"
click node_shader "https://github.com/webosbrew/retroarch/tree/webos/gfx/drivers/gl_shaders"
click node_rewind "https://github.com/webosbrew/retroarch/blob/webos/state_manager.c"
click node_recording "https://github.com/webosbrew/retroarch/tree/webos/tasks"
click node_run_ahead "https://github.com/webosbrew/retroarch/blob/webos/runloop.h"
click node_cheats "https://github.com/webosbrew/retroarch/blob/webos/cheat_manager.c"
click node_achievements "https://github.com/webosbrew/retroarch/blob/webos/cheevos/cheevos.c"
click node_database "https://github.com/webosbrew/retroarch/blob/webos/libretro-db/query.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend,node_config,node_menu,node_core toneBlue
class node_video,node_audio,node_input,node_shader toneAmber
class node_content,node_coreinfo,node_playlist toneMint
class node_rewind,node_recording,node_run_ahead,node_cheats toneRose
class node_achievements,node_database,node_user,node_achievement_service toneIndigo
```

## Components

### Frontend Lifecycle

- [RetroArch Frontend](https://github.com/webosbrew/retroarch/blob/webos/retroarch.h): `retroarch.h`
- [Configuration](https://github.com/webosbrew/retroarch/blob/webos/configuration.c): `configuration.c`
- [Menu UI](https://github.com/webosbrew/retroarch/blob/webos/menu/menu_driver.h): `menu/menu_driver.h`
- [Libretro Core](https://github.com/webosbrew/retroarch/blob/webos/core.h): `core.h`

### Platform I/O

- [Video Output](https://github.com/webosbrew/retroarch/tree/webos/gfx): `gfx`
- [Audio Output](https://github.com/webosbrew/retroarch/blob/webos/audio/audio_driver.c): `audio/audio_driver.c`
- [Input Drivers](https://github.com/webosbrew/retroarch/blob/webos/input/input_driver.h): `input/input_driver.h`
- [Shader Pipeline](https://github.com/webosbrew/retroarch/tree/webos/gfx/drivers/gl_shaders): `gfx/drivers/gl_shaders`

### Core and Library Management

- [Content Loading](https://github.com/webosbrew/retroarch/blob/webos/content.h): `content.h`
- [Core Metadata](https://github.com/webosbrew/retroarch/blob/webos/core_info.h): `core_info.h`
- [Playlists](https://github.com/webosbrew/retroarch/blob/webos/tasks/task_playlist_manager.c): `tasks/task_playlist_manager.c`

### Runtime Features

- [Rewind and States](https://github.com/webosbrew/retroarch/blob/webos/state_manager.c): `state_manager.c`
- [Video Recording](https://github.com/webosbrew/retroarch/tree/webos/tasks): `tasks`
- [Run-Ahead](https://github.com/webosbrew/retroarch/blob/webos/runloop.h): `runloop.h`
- [Cheat Manager](https://github.com/webosbrew/retroarch/blob/webos/cheat_manager.c): `cheat_manager.c`

### Metadata and Services

- [Achievements](https://github.com/webosbrew/retroarch/blob/webos/cheevos/cheevos.c): `cheevos/cheevos.c`
- [Game Database](https://github.com/webosbrew/retroarch/blob/webos/libretro-db/query.c): `libretro-db/query.c`

### Other components

- **Player**
- **Achievement Service**

## Connections

- Player → RetroArch Frontend: uses
- RetroArch Frontend → Libretro Core: loads core
- RetroArch Frontend → Configuration: reads settings
- RetroArch Frontend → Menu UI: presents UI
- Menu UI → Content Loading: selects content
- Content Loading → Libretro Core: provides content
- Libretro Core → RetroArch Frontend: sends callbacks
- RetroArch Frontend → Video Output: routes video
- RetroArch Frontend → Audio Output: routes audio
- RetroArch Frontend → Input Drivers: routes input
- RetroArch Frontend → Core Metadata: queries metadata
- RetroArch Frontend → Playlists: manages playlists
- RetroArch Frontend → Shader Pipeline: applies shaders
- RetroArch Frontend → Rewind and States: supports rewind
- RetroArch Frontend → Video Recording: supports recording
- RetroArch Frontend → Run-Ahead: supports run-ahead
- RetroArch Frontend → Cheat Manager: manages cheats (evidence: `cheat_manager.c`)
- RetroArch Frontend → Achievements: tracks achievements
- Achievements → Achievement Service: uses service
- RetroArch Frontend → Game Database: queries metadata
