# xwellauss/starlight architecture

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

- Interactive diagram: https://gitdiagram.com/xwellauss/starlight
- Repository: https://github.com/xwellauss/starlight

## Overview

Starlight is a C graphics framework for desktop, web, and Android. Its central runtime workflow initializes platform/window state and optional UI, networking, and audio, then polls input, updates the active scene, renders, and swaps buffers. The framework also exposes ECS, camera, resource-loading, and networking capabilities. The sandbox demonstrates scene registration and selection. Edges follow shown engine calls, scene registration, and UI-backend dependencies; several capability nodes are grounded in the README and file tree, but their internal wiring was not sampled.

Main entry points: [`src/starlight/core/engine.c`](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/engine.c) (Engine loop), [`sandbox/src/main.c`](https://github.com/xwellauss/starlight/blob/main/sandbox/src/main.c) (Sandbox entry), [`src/starlight/network/network.c`](https://github.com/xwellauss/starlight/blob/main/src/starlight/network/network.c) (Network facade), [`src/starlight/core/scene/scene_manager.c`](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/scene/scene_manager.c) (Scene manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and scenes"]
  node_sandbox["Sandbox entry<br/>[main.c]"]
  node_scene_registry["Scene registry<br/>[scenes.h]"]
  node_engine["Engine loop<br/>[engine.c]"]
  node_scene_manager["Scene manager<br/>[scene_manager.c]"]
  node_ecs["Entity components<br/>[ecs.c]"]
  node_camera["Camera<br/>[camera.c]"]
  node_window["Window and platform<br/>[window.c]"]
end

subgraph group_render["Graphics and resources"]
  node_renderer["Renderer<br/>[renderer.c]"]
  node_shader["Shaders<br/>[shader.c]"]
  node_texture["Textures<br/>[texture.c]"]
  node_vertex_buffer["Vertex buffers<br/>[vertex_buffer.c]"]
  node_model_loader["Model loading<br/>[model_loader.c]"]
  node_gltf["glTF parsing<br/>[gltf.c]"]
  node_texture_atlas["Texture atlases<br/>[texture_atlas.c]"]
  node_font_atlas["Font atlas<br/>[font_atlas.c]"]
end

subgraph group_interaction["UI and input"]
  node_input["Input handling<br/>[input.c]"]
  node_ui["UI system<br/>[ui.c]"]
  node_ui_backend["UI renderer<br/>[backend.c]"]
  node_ui_style["UI styling<br/>[style.c]"]
  node_text_input["Text input<br/>[text_input.c]"]
end

subgraph group_services["Audio and networking"]
  node_audio["Audio<br/>[audio.c]"]
  node_network["Network facade<br/>[network.c]"]
  node_net_client["Network client<br/>[client.c]"]
  node_net_server["Network server<br/>[server.c]"]
  node_serialization["Serialization<br/>[serialize.c]"]
end

node_developer(("Application developer"))

node_developer -->|"runs"| node_sandbox
node_sandbox -->|"initializes"| node_engine
node_sandbox -->|"registers scenes"| node_scene_registry
node_scene_registry -->|"registers scenes"| node_scene_manager
node_sandbox -->|"selects scene"| node_scene_manager
node_engine -->|"initializes and polls"| node_window
node_engine -->|"processes UI input"| node_input
node_engine -->|"dispatches scene"| node_scene_manager
node_engine -->|"clears buffer"| node_renderer
node_engine -->|"updates and renders"| node_ui
node_engine -->|"initializes and destroys"| node_ecs
node_engine -->|"optionally initializes"| node_network
node_engine -->|"optionally initializes"| node_audio
node_ui_backend -->|"draws through"| node_renderer
node_ui_backend -->|"uses glyph atlas"| node_font_atlas
node_model_loader -.-> node_gltf
node_network -.-> node_net_client
node_network -.-> node_net_server

click node_sandbox "https://github.com/xwellauss/starlight/blob/main/sandbox/src/main.c"
click node_scene_registry "https://github.com/xwellauss/starlight/blob/main/sandbox/src/scenes.h"
click node_engine "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/engine.c"
click node_scene_manager "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/scene/scene_manager.c"
click node_ecs "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ecs.c"
click node_camera "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/camera.c"
click node_window "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/window/window.c"
click node_input "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/window/input.c"
click node_renderer "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/renderer.c"
click node_shader "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/shader.c"
click node_texture "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/texture.c"
click node_vertex_buffer "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/vertex_buffer.c"
click node_model_loader "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/model_loader.c"
click node_gltf "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/gltf.c"
click node_texture_atlas "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/texture_atlas.c"
click node_ui "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/ui.c"
click node_ui_backend "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/backend.c"
click node_ui_style "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/style.c"
click node_text_input "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/text_input.c"
click node_font_atlas "https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/font_atlas.c"
click node_audio "https://github.com/xwellauss/starlight/blob/main/src/starlight/audio/audio.c"
click node_network "https://github.com/xwellauss/starlight/blob/main/src/starlight/network/network.c"
click node_net_client "https://github.com/xwellauss/starlight/blob/main/src/starlight/network/client.c"
click node_net_server "https://github.com/xwellauss/starlight/blob/main/src/starlight/network/server.c"
click node_serialization "https://github.com/xwellauss/starlight/blob/main/src/starlight/network/serialize.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_sandbox,node_scene_registry,node_engine,node_scene_manager,node_ecs,node_camera,node_window toneBlue
class node_renderer,node_shader,node_texture,node_vertex_buffer,node_model_loader,node_gltf,node_texture_atlas,node_font_atlas toneAmber
class node_input,node_ui,node_ui_backend,node_ui_style,node_text_input toneMint
class node_audio,node_network,node_net_client,node_net_server,node_serialization toneRose
class node_developer toneIndigo
```

## Components

### Runtime and scenes

- [Sandbox entry](https://github.com/xwellauss/starlight/blob/main/sandbox/src/main.c): `sandbox/src/main.c`
- [Scene registry](https://github.com/xwellauss/starlight/blob/main/sandbox/src/scenes.h): `sandbox/src/scenes.h`
- [Engine loop](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/engine.c): `src/starlight/core/engine.c`
- [Scene manager](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/scene/scene_manager.c): `src/starlight/core/scene/scene_manager.c`
- [Entity components](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ecs.c): `src/starlight/core/ecs.c`
- [Camera](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/camera.c): `src/starlight/core/camera.c`
- [Window and platform](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/window/window.c): `src/starlight/core/window/window.c`

### Graphics and resources

- [Renderer](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/renderer.c): `src/starlight/core/renderer/renderer.c`
- [Shaders](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/shader.c): `src/starlight/core/renderer/shader.c`
- [Textures](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/texture.c): `src/starlight/core/renderer/texture.c`
- [Vertex buffers](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/renderer/vertex_buffer.c): `src/starlight/core/renderer/vertex_buffer.c`
- [Model loading](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/model_loader.c): `src/starlight/core/resources/model_loader.c`
- [glTF parsing](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/gltf.c): `src/starlight/core/resources/gltf.c`
- [Texture atlases](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/texture_atlas.c): `src/starlight/core/resources/texture_atlas.c`
- [Font atlas](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/resources/font_atlas.c): `src/starlight/core/resources/font_atlas.c`

### UI and input

- [Input handling](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/window/input.c): `src/starlight/core/window/input.c`
- [UI system](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/ui.c): `src/starlight/core/ui/ui.c`
- [UI renderer](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/backend.c): `src/starlight/core/ui/backend.c`
- [UI styling](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/style.c): `src/starlight/core/ui/style.c`
- [Text input](https://github.com/xwellauss/starlight/blob/main/src/starlight/core/ui/text_input.c): `src/starlight/core/ui/text_input.c`

### Audio and networking

- [Audio](https://github.com/xwellauss/starlight/blob/main/src/starlight/audio/audio.c): `src/starlight/audio/audio.c`
- [Network facade](https://github.com/xwellauss/starlight/blob/main/src/starlight/network/network.c): `src/starlight/network/network.c`
- [Network client](https://github.com/xwellauss/starlight/blob/main/src/starlight/network/client.c): `src/starlight/network/client.c`
- [Network server](https://github.com/xwellauss/starlight/blob/main/src/starlight/network/server.c): `src/starlight/network/server.c`
- [Serialization](https://github.com/xwellauss/starlight/blob/main/src/starlight/network/serialize.c): `src/starlight/network/serialize.c`

### Other components

- **Application developer**

## Connections

- Application developer → Sandbox entry: runs (evidence: `sandbox/src/main.c`)
- Sandbox entry → Engine loop: initializes (evidence: `sandbox/src/main.c`)
- Sandbox entry → Scene registry: registers scenes (evidence: `sandbox/src/main.c`)
- Scene registry → Scene manager: registers scenes (evidence: `sandbox/src/scenes.h`)
- Sandbox entry → Scene manager: selects scene (evidence: `sandbox/src/main.c`)
- Engine loop → Window and platform: initializes and polls (evidence: `src/starlight/core/engine.c`)
- Engine loop → Input handling: processes UI input (evidence: `src/starlight/core/engine.c`)
- Engine loop → Scene manager: dispatches scene (evidence: `src/starlight/core/engine.c`)
- Engine loop → Renderer: clears buffer (evidence: `src/starlight/core/engine.c`)
- Engine loop → UI system: updates and renders (evidence: `src/starlight/core/engine.c`)
- Engine loop → Entity components: initializes and destroys (evidence: `src/starlight/core/engine.c`)
- Engine loop → Network facade: optionally initializes (evidence: `src/starlight/core/engine.c`)
- Engine loop → Audio: optionally initializes (evidence: `src/starlight/core/engine.c`)
- UI renderer → Renderer: draws through (evidence: `src/starlight/core/ui/backend.c`)
- UI renderer → Font atlas: uses glyph atlas (evidence: `src/starlight/core/ui/backend.c`)
- Model loading → glTF parsing
- Network facade → Network client
- Network facade → Network server
