# xearty/xtb architecture

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

- Interactive diagram: https://gitdiagram.com/xearty/xtb
- Repository: https://github.com/xearty/xtb

## Overview

The available tree is an archived C++ utility and graphics toolkit, not the D subpackages described by the README; this map therefore follows the C++ files and excerpts. Its clearest user-facing workflow is loading a BMP, applying selection-based filters, and displaying pixels. A second example initializes a window and OpenGL context before rendering. The source index supports several internal module references, but unsampled implementations are not treated as inspected; uncertain connections are omitted.

Main entry points: [`archive/cpp/apps/bmp_test/main.cpp`](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/main.cpp) (BMP viewer), [`archive/cpp/apps/window_test/main.cpp`](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/window_test/main.cpp) (Window render demo), [`archive/cpp/libs/xtb_os/libc_file.cpp`](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_os/libc_file.cpp) (File I/O), [`archive/cpp/libs/xtb_json/json.cpp`](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_json/json.cpp) (JSON parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core utilities"]
  node_allocator["Allocators<br/>[allocator.h]"]
  node_string["Strings<br/>[string.h]"]
  node_coreapi["Core utilities<br/>[core.h]"]
  node_diagnostics["Stack traces<br/>[stacktrace.cpp]"]
  node_math["Math and noise<br/>[xtbm.cpp]"]
end

subgraph group_platform["Platform I/O"]
  node_fileio["File I/O<br/>[libc_file.cpp]"]
  node_osapi["OS interface<br/>[os.h]"]
end

subgraph group_media["Media formats"]
  node_viewer["BMP viewer<br/>[main.cpp]"]
  node_bmp["BMP codec<br/>[bmp.cpp]"]
  node_filters["Image filters<br/>[filters.cpp]"]
  node_selection["Rectangle selection<br/>[rect_selection.cpp]"]
  node_json["JSON parser<br/>[json.cpp]"]
  node_jsonapp["JSON console<br/>[main.cpp]"]
end

subgraph group_graphics["Window and graphics"]
  node_window["Window and input<br/>[window.cpp]"]
  node_glapi["OpenGL loader API<br/>[ogl.cpp]"]
  node_glad["GL function loader<br/>[glad.c]"]
  node_renderer["Renderer<br/>[renderer.cpp]"]
  node_geometry["Geometry<br/>[geometry.h]"]
  node_materials["Materials<br/>[material.cpp]"]
  node_windowdemo["Window render demo<br/>[main.cpp]"]
end

node_viewer -->|"loads bitmap"| node_bmp
node_viewer -->|"reads file"| node_fileio
node_viewer -->|"applies filters"| node_filters
node_viewer -->|"checks selection"| node_selection
node_fileio -->|"implements interface"| node_osapi
node_fileio -->|"uses strings"| node_string
node_fileio -->|"uses core"| node_coreapi
node_bmp -.->|"allocates buffers"| node_allocator
node_jsonapp -->|"parses and queries"| node_json
node_json -->|"uses OS interface"| node_osapi
node_json -->|"uses allocator"| node_allocator
node_json -->|"uses contracts"| node_coreapi
node_windowdemo -->|"creates window"| node_window
node_windowdemo -->|"loads OpenGL"| node_glapi
node_windowdemo -->|"renders scene"| node_renderer
node_windowdemo -->|"uses math"| node_math
node_glapi -->|"loads functions"| node_glad
node_renderer -->|"uploads geometry"| node_geometry
node_renderer -->|"applies materials"| node_materials
node_renderer -->|"allocates resources"| node_allocator

click node_viewer "https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/main.cpp"
click node_bmp "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_bmp/bmp.cpp"
click node_filters "https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/filters.cpp"
click node_selection "https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/rect_selection.cpp"
click node_fileio "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_os/libc_file.cpp"
click node_osapi "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_os/os.h"
click node_allocator "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/allocator.h"
click node_string "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/string.h"
click node_coreapi "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/core.h"
click node_diagnostics "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/src/stacktrace/stacktrace.cpp"
click node_json "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_json/json.cpp"
click node_jsonapp "https://github.com/xearty/xtb/blob/main/archive/cpp/apps/json_test/main.cpp"
click node_window "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_window/window.cpp"
click node_glapi "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_ogl/ogl.cpp"
click node_glad "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_ogl/glad/src/glad.c"
click node_renderer "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/renderer.cpp"
click node_geometry "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/geometry.h"
click node_materials "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/material.cpp"
click node_windowdemo "https://github.com/xearty/xtb/blob/main/archive/cpp/apps/window_test/main.cpp"
click node_math "https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtbm/xtbm.cpp"

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_allocator,node_string,node_coreapi,node_diagnostics,node_math toneBlue
class node_fileio,node_osapi toneAmber
class node_viewer,node_bmp,node_filters,node_selection,node_json,node_jsonapp toneMint
class node_window,node_glapi,node_glad,node_renderer,node_geometry,node_materials,node_windowdemo toneRose
```

## Components

### Core utilities

- [Allocators](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/allocator.h): `archive/cpp/libs/xtb_core/include/xtb_core/allocator.h`
- [Strings](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/string.h): `archive/cpp/libs/xtb_core/include/xtb_core/string.h`
- [Core utilities](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/include/xtb_core/core.h): `archive/cpp/libs/xtb_core/include/xtb_core/core.h`
- [Stack traces](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_core/src/stacktrace/stacktrace.cpp): `archive/cpp/libs/xtb_core/src/stacktrace/stacktrace.cpp`
- [Math and noise](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtbm/xtbm.cpp): `archive/cpp/libs/xtbm/xtbm.cpp`

### Platform I/O

- [File I/O](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_os/libc_file.cpp): `archive/cpp/libs/xtb_os/libc_file.cpp`
- [OS interface](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_os/os.h): `archive/cpp/libs/xtb_os/os.h`

### Media formats

- [BMP viewer](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/main.cpp): `archive/cpp/apps/bmp_test/main.cpp`
- [BMP codec](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_bmp/bmp.cpp): `archive/cpp/libs/xtb_bmp/bmp.cpp`
- [Image filters](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/filters.cpp): `archive/cpp/apps/bmp_test/filters.cpp`
- [Rectangle selection](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/bmp_test/rect_selection.cpp): `archive/cpp/apps/bmp_test/rect_selection.cpp`
- [JSON parser](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_json/json.cpp): `archive/cpp/libs/xtb_json/json.cpp`
- [JSON console](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/json_test/main.cpp): `archive/cpp/apps/json_test/main.cpp`

### Window and graphics

- [Window and input](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_window/window.cpp): `archive/cpp/libs/xtb_window/window.cpp`
- [OpenGL loader API](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_ogl/ogl.cpp): `archive/cpp/libs/xtb_ogl/ogl.cpp`
- [GL function loader](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_ogl/glad/src/glad.c): `archive/cpp/libs/xtb_ogl/glad/src/glad.c`
- [Renderer](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/renderer.cpp): `archive/cpp/libs/xtb_renderer/renderer.cpp`
- [Geometry](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/geometry.h): `archive/cpp/libs/xtb_renderer/geometry.h`
- [Materials](https://github.com/xearty/xtb/blob/main/archive/cpp/libs/xtb_renderer/material.cpp): `archive/cpp/libs/xtb_renderer/material.cpp`
- [Window render demo](https://github.com/xearty/xtb/blob/main/archive/cpp/apps/window_test/main.cpp): `archive/cpp/apps/window_test/main.cpp`

## Connections

- BMP viewer → BMP codec: loads bitmap (evidence: `archive/cpp/apps/bmp_test/main.cpp`)
- BMP viewer → File I/O: reads file (evidence: `archive/cpp/apps/bmp_test/main.cpp`)
- BMP viewer → Image filters: applies filters (evidence: `archive/cpp/apps/bmp_test/main.cpp`)
- BMP viewer → Rectangle selection: checks selection (evidence: `archive/cpp/apps/bmp_test/main.cpp`)
- File I/O → OS interface: implements interface (evidence: `archive/cpp/libs/xtb_os/libc_file.cpp`)
- File I/O → Strings: uses strings (evidence: `archive/cpp/libs/xtb_os/libc_file.cpp`)
- File I/O → Core utilities: uses core (evidence: `archive/cpp/libs/xtb_os/libc_file.cpp`)
- BMP codec → Allocators: allocates buffers
- JSON console → JSON parser: parses and queries (evidence: `archive/cpp/apps/json_test/main.cpp`)
- JSON parser → OS interface: uses OS interface (evidence: `archive/cpp/libs/xtb_json/json.cpp`)
- JSON parser → Allocators: uses allocator (evidence: `archive/cpp/libs/xtb_json/json.cpp`)
- JSON parser → Core utilities: uses contracts (evidence: `archive/cpp/libs/xtb_json/json.cpp`)
- Window render demo → Window and input: creates window (evidence: `archive/cpp/apps/window_test/main.cpp`)
- Window render demo → OpenGL loader API: loads OpenGL (evidence: `archive/cpp/apps/window_test/main.cpp`)
- Window render demo → Renderer: renders scene (evidence: `archive/cpp/apps/window_test/main.cpp`)
- Window render demo → Math and noise: uses math (evidence: `archive/cpp/apps/window_test/main.cpp`)
- OpenGL loader API → GL function loader: loads functions (evidence: `archive/cpp/libs/xtb_ogl/ogl.cpp`)
- Renderer → Geometry: uploads geometry (evidence: `archive/cpp/libs/xtb_renderer/renderer.cpp`)
- Renderer → Materials: applies materials (evidence: `archive/cpp/libs/xtb_renderer/renderer.cpp`)
- Renderer → Allocators: allocates resources
