# sudoevolve/eui-neo architecture

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

- Interactive diagram: https://gitdiagram.com/sudoevolve/eui-neo
- Repository: https://github.com/sudoevolve/eui-neo

## Overview

#### Purpose and public entry points
EUI-NEO is a C++17 cross-platform retained UI framework for native desktop-style applications. Consumers include `eui_neo.h` or focused facades under `include/eui/`, define DSL composition, and configure an executable through CMake. Public app/window contracts are in `include/eui/app.h`, `include/eui/dsl_app.h`, and `include/eui/window.h`.

#### Application bootstrap and window loop
`eui_neo_configure_app()` selects and supplies a platform main/loop; applications normally provide `app::dslAppConfig()` and `app::compose()`. The runtime owns window creation, frame pacing, event polling, and lifecycle dispatch through `core/app/app_runner.h`, `core/app/glfw_app_main.cpp`, and `core/app/sdl2_app_main.cpp`. Windowing is isolated behind `core/window/window_backend.h` and `core/window/window_input_backend.cpp`, allowing GLFW or SDL2 integration without exposing either to application composition.

#### Declarative UI and retained runtime
The DSL builds a keyed UI tree with layout, state bindings, event handlers, and primitive-producing components. Its public/internal boundary is `include/eui/dsl.h`, `core/dsl.h`, and `core/dsl_runtime.h`. Runtime stages are factored by concern: lifecycle/instance reconciliation, geometry/layout, hit testing/input, animation/update/dirty tracking, then rendering in `core/runtime/runtime_lifecycle.h`, `core/runtime/runtime_geometry.h`, and `core/runtime/runtime_render.h`. Stable identifiers and retained instances enable incremental updates rather than rebuilding rendering state wholesale.

#### Components and application composition
Reusable widgets are header-level DSL compositions, not a separate widget runtime: `components/components.h`, `components/input.h`, and `components/virtuallist.h`. Larger examples exercise the framework as normal native apps, notably `apps/gallery/app.cpp`, `apps/calgary_gallery/app.cpp`, and `apps/serial_tool/app.cpp`. Optional integrations remain separate modules with their own build boundaries, such as `modules/keyboard/keyboard.h` and `modules/serial/serial.cpp`.

#### Render abstraction and GPU backends
Runtime rendering emits backend-neutral primitives, images, text, and surfaces via `core/render/primitive.h`, `core/render/render_backend.h`, and `core/render/render_surface.h`. OpenGL implements the default path in `core/render/opengl/opengl_backend.cpp`, including text, images, primitives, and Shadertoy. Vulkan is a parallel backend with explicit shaders and cache support in `core/render/vulkan/vulkan_backend.cpp`, `core/render/vulkan/vulkan_cache.cpp`, and `core/render/vulkan/shaders/rounded_rect.frag`. This boundary is the primary portability seam between UI/runtime logic and GPU APIs.

#### Assets, text, images, and shader content
Text/image resources become render-layer objects through `core/render/text.h`, `core/render/image_source.h`, and `core/render/shadertoy.h`. The framework bundles fonts and shader assets under `assets/`; Shadertoy configurations are parsed and represented by `core/render/shadertoy_json.cpp` and `core/render/shadertoy_primitive.h`. Build scripts generate Vulkan SPIR-V/header artifacts and wrap Shadertoy resources: `scripts/generate_vulkan_shaders.py` and `scripts/EuiShaderToy.cmake`.

#### Platform services and dependencies
Platform-facing capabilities—async work, JSON, networking, native/IME bridges, system tray, and performance data—are exposed through public facades and implemented behind `core/platform/`: `include/eui/async.h`, `core/platform/network.cpp`, and `core/platform/native_bridge.c`. Major vendored infrastructure includes GLFW/SDL2-facing window support, OpenGL loading (`3rd/glad`), FreeType text rasterization (`3rd/freetype`), image decoding via stb/libpng, JSON via yyjson, and markdown via md4c. The top-level build is CMake-driven (`CMakeLists.txt`) with an alternative Xmake build (`xmake.lua`); GitHub Actions handles CI, pages, and releases.

Main entry points: [`core/render/render_backend.h`](https://github.com/sudoevolve/eui-neo/blob/main/core/render/render_backend.h) (Render abstraction), [`core/app/app_runner.h`](https://github.com/sudoevolve/eui-neo/blob/main/core/app/app_runner.h) (App runner), [`include/eui/app.h`](https://github.com/sudoevolve/eui-neo/blob/main/include/eui/app.h) (App and window API), [`include/eui/dsl.h`](https://github.com/sudoevolve/eui-neo/blob/main/include/eui/dsl.h) (DSL facade)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_api["App and window API<br/>public headers<br/>[app.h]"]
  node_dsl_public["DSL facade<br/>public header<br/>[dsl.h]"]
  node_components["Composable widgets<br/>DSL components<br/>[components.h]"]
end

subgraph group_runtime["UI Runtime"]
  node_app_runner["App runner<br/>bootstrap and loop<br/>[app_runner.h]"]
  node_platform_mains["GLFW / SDL2 mains<br/>platform loop<br/>[glfw_app_main.cpp]"]
  node_window_backend["Window input boundary<br/>backend interface<br/>[window_backend.h]"]
  node_dsl_runtime["Retained DSL runtime<br/>tree reconciliation<br/>[dsl_runtime.h]"]
  node_lifecycle["Lifecycle and instances<br/>runtime stage"]
  node_geometry["Layout and input<br/>runtime stage<br/>[runtime_geometry.h]"]
  node_render_runtime["Render and dirty stage<br/>runtime stage<br/>[runtime_render.h]"]
end

subgraph group_render["Rendering"]
  node_render_api["Render abstraction<br/>backend-neutral primitives<br/>[render_backend.h]"]
  node_opengl["OpenGL backend<br/>GPU backend<br/>[opengl_backend.cpp]"]
  node_vulkan["Vulkan backend and cache<br/>GPU backend<br/>[vulkan_backend.cpp]"]
  node_resources["Text, image, Shadertoy<br/>render resources<br/>[shadertoy.h]"]
  node_shader_build["Shader asset generation<br/>build tooling"]
end

subgraph group_platform["Platform &amp; Extensions"]
  node_platform_services["Platform services<br/>service layer<br/>[network.cpp]"]
  node_optional_modules["Optional integrations<br/>separate modules<br/>[serial.cpp]"]
end

node_consumer(("Native application<br/>consumer"))
node_cmake["CMake build<br/>build system<br/>[CMakeLists.txt]"]
node_example_apps["Example applications<br/>framework consumers<br/>[app.cpp]"]

node_consumer -->|"implements app contract"| node_api
node_consumer -->|"composes UI"| node_dsl_public
node_consumer -->|"configures executable"| node_cmake
node_cmake -->|"selects platform entry"| node_platform_mains
node_api -->|"starts"| node_app_runner
node_platform_mains -->|"drives loop"| node_app_runner
node_app_runner -->|"creates windows and polls input"| node_window_backend
node_dsl_public -->|"builds keyed tree"| node_dsl_runtime
node_components -->|"composes with"| node_dsl_public
node_dsl_runtime -->|"reconciles"| node_lifecycle
node_lifecycle -->|"updates instances"| node_geometry
node_window_backend -->|"input events"| node_geometry
node_geometry -->|"geometry and hit state"| node_render_runtime
node_render_runtime -->|"emits primitives"| node_render_api
node_resources -->|"supplies render objects"| node_render_api
node_render_api -->|"default backend"| node_opengl
node_render_api -->|"parallel backend"| node_vulkan
node_shader_build -->|"generates SPIR-V artifacts"| node_vulkan
node_platform_services -->|"supports runtime"| node_app_runner
node_optional_modules -.->|"extend platform capabilities"| node_platform_services
node_example_apps -->|"uses"| node_api
node_example_apps -->|"uses"| node_components

click node_api "https://github.com/sudoevolve/eui-neo/blob/main/include/eui/app.h"
click node_dsl_public "https://github.com/sudoevolve/eui-neo/blob/main/include/eui/dsl.h"
click node_cmake "https://github.com/sudoevolve/eui-neo/blob/main/CMakeLists.txt"
click node_app_runner "https://github.com/sudoevolve/eui-neo/blob/main/core/app/app_runner.h"
click node_platform_mains "https://github.com/sudoevolve/eui-neo/blob/main/core/app/glfw_app_main.cpp"
click node_window_backend "https://github.com/sudoevolve/eui-neo/blob/main/core/window/window_backend.h"
click node_dsl_runtime "https://github.com/sudoevolve/eui-neo/blob/main/core/dsl_runtime.h"
click node_lifecycle "https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_lifecycle.h"
click node_geometry "https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_geometry.h"
click node_render_runtime "https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_render.h"
click node_components "https://github.com/sudoevolve/eui-neo/blob/main/components/components.h"
click node_render_api "https://github.com/sudoevolve/eui-neo/blob/main/core/render/render_backend.h"
click node_opengl "https://github.com/sudoevolve/eui-neo/blob/main/core/render/opengl/opengl_backend.cpp"
click node_vulkan "https://github.com/sudoevolve/eui-neo/blob/main/core/render/vulkan/vulkan_backend.cpp"
click node_resources "https://github.com/sudoevolve/eui-neo/blob/main/core/render/shadertoy.h"
click node_shader_build "https://github.com/sudoevolve/eui-neo/blob/main/scripts/generate_vulkan_shaders.py"
click node_platform_services "https://github.com/sudoevolve/eui-neo/blob/main/core/platform/network.cpp"
click node_optional_modules "https://github.com/sudoevolve/eui-neo/blob/main/modules/serial/serial.cpp"
click node_example_apps "https://github.com/sudoevolve/eui-neo/blob/main/apps/gallery/app.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_api,node_dsl_public,node_components toneBlue
class node_app_runner,node_platform_mains,node_window_backend,node_dsl_runtime,node_lifecycle,node_geometry,node_render_runtime toneAmber
class node_render_api,node_opengl,node_vulkan,node_resources,node_shader_build toneMint
class node_platform_services,node_optional_modules toneRose
class node_consumer,node_cmake,node_example_apps toneNeutral
```

## Components

### Public API

- [App and window API](https://github.com/sudoevolve/eui-neo/blob/main/include/eui/app.h): public headers · `include/eui/app.h`
- [DSL facade](https://github.com/sudoevolve/eui-neo/blob/main/include/eui/dsl.h): public header · `include/eui/dsl.h`
- [Composable widgets](https://github.com/sudoevolve/eui-neo/blob/main/components/components.h): DSL components · Header-level DSL compositions rather than a separate widget runtime. · `components/components.h`

### UI Runtime

- [App runner](https://github.com/sudoevolve/eui-neo/blob/main/core/app/app_runner.h): bootstrap and loop · Owns lifecycle dispatch, polling, pacing, and window creation. · `core/app/app_runner.h`
- [GLFW / SDL2 mains](https://github.com/sudoevolve/eui-neo/blob/main/core/app/glfw_app_main.cpp): platform loop · `core/app/glfw_app_main.cpp`
- [Window input boundary](https://github.com/sudoevolve/eui-neo/blob/main/core/window/window_backend.h): backend interface · `core/window/window_backend.h`
- [Retained DSL runtime](https://github.com/sudoevolve/eui-neo/blob/main/core/dsl_runtime.h): tree reconciliation · Maintains keyed instances, bindings, handlers, and incremental state. · `core/dsl_runtime.h`
- [Lifecycle and instances](https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_lifecycle.h): runtime stage · `core/runtime/runtime_lifecycle.h`
- [Layout and input](https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_geometry.h): runtime stage · Calculates geometry and hit testing. · `core/runtime/runtime_geometry.h`
- [Render and dirty stage](https://github.com/sudoevolve/eui-neo/blob/main/core/runtime/runtime_render.h): runtime stage · `core/runtime/runtime_render.h`

### Rendering

- [Render abstraction](https://github.com/sudoevolve/eui-neo/blob/main/core/render/render_backend.h): backend-neutral primitives · Carries primitives, images, text, and surfaces to GPU backends. · `core/render/render_backend.h`
- [OpenGL backend](https://github.com/sudoevolve/eui-neo/blob/main/core/render/opengl/opengl_backend.cpp): GPU backend · Default renderer for primitives, text, images, and Shadertoy. · `core/render/opengl/opengl_backend.cpp`
- [Vulkan backend and cache](https://github.com/sudoevolve/eui-neo/blob/main/core/render/vulkan/vulkan_backend.cpp): GPU backend · `core/render/vulkan/vulkan_backend.cpp`
- [Text, image, Shadertoy](https://github.com/sudoevolve/eui-neo/blob/main/core/render/shadertoy.h): render resources · `core/render/shadertoy.h`
- [Shader asset generation](https://github.com/sudoevolve/eui-neo/blob/main/scripts/generate_vulkan_shaders.py): build tooling · Generates Vulkan artifacts and wraps Shadertoy resources. · `scripts/generate_vulkan_shaders.py`

### Platform & Extensions

- [Platform services](https://github.com/sudoevolve/eui-neo/blob/main/core/platform/network.cpp): service layer · Async, networking, native bridges, and system capabilities. · `core/platform/network.cpp`
- [Optional integrations](https://github.com/sudoevolve/eui-neo/blob/main/modules/serial/serial.cpp): separate modules · `modules/serial/serial.cpp`

### Other components

- **Native application**: consumer · Defines app composition and links the framework.
- [CMake build](https://github.com/sudoevolve/eui-neo/blob/main/CMakeLists.txt): build system · `CMakeLists.txt`
- [Example applications](https://github.com/sudoevolve/eui-neo/blob/main/apps/gallery/app.cpp): framework consumers · `apps/gallery/app.cpp`

## Connections

- Native application → App and window API: implements app contract
- Native application → DSL facade: composes UI
- Native application → CMake build: configures executable
- CMake build → GLFW / SDL2 mains: selects platform entry
- App and window API → App runner: starts
- GLFW / SDL2 mains → App runner: drives loop
- App runner → Window input boundary: creates windows and polls input
- DSL facade → Retained DSL runtime: builds keyed tree
- Composable widgets → DSL facade: composes with
- Retained DSL runtime → Lifecycle and instances: reconciles
- Lifecycle and instances → Layout and input: updates instances
- Window input boundary → Layout and input: input events
- Layout and input → Render and dirty stage: geometry and hit state
- Render and dirty stage → Render abstraction: emits primitives
- Text, image, Shadertoy → Render abstraction: supplies render objects
- Render abstraction → OpenGL backend: default backend
- Render abstraction → Vulkan backend and cache: parallel backend
- Shader asset generation → Vulkan backend and cache: generates SPIR-V artifacts
- Platform services → App runner: supports runtime
- Optional integrations → Platform services: extend platform capabilities
- Example applications → App and window API: uses
- Example applications → Composable widgets: uses
