# tixolan/varyn architecture

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

- Interactive diagram: https://gitdiagram.com/tixolan/varyn
- Repository: https://github.com/tixolan/varyn

## Overview

Varyn is a Vulkan live-shader playground. A user supplies a TOML scene; the app loads configuration and assets, evaluates time-dependent expressions, compiles modular shaders, and renders the scene to a window. The renderer also supports model instances, extra shader passes, textures, and per-instance environment reflections. File watching reloads changed inputs, with shader-only recompilation distinct from full config and asset reloads. Edges reflect documented behavior and visible module references; some internal call details are unsampled, so those links are omitted.

Main entry points: [`src/Config.cpp`](https://github.com/tixolan/varyn/blob/main/src/Config.cpp) (TOML config), [`src/render/Renderer.cpp`](https://github.com/tixolan/varyn/blob/main/src/render/Renderer.cpp) (Scene renderer), [`src/App.hpp`](https://github.com/tixolan/varyn/blob/main/src/App.hpp) (App loop), [`src/vulkan/Swapchain.hpp`](https://github.com/tixolan/varyn/blob/main/src/vulkan/Swapchain.hpp) (Swapchain)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_cli["Command line<br/>[main.cpp]"]
  node_app_loop["App loop<br/>[App.hpp]"]
  node_watcher["File watching<br/>[FileWatcher.hpp]"]
end

subgraph group_inputs["Scene Inputs"]
  node_config["TOML config<br/>[Config.cpp]"]
  node_expressions["Expressions<br/>[Expression.cpp]"]
  node_shader_sources["Shader modules"]
  node_models["Model loading<br/>[Mesh.cpp]"]
end

subgraph group_render["Rendering"]
  node_scene["GPU scene assets<br/>[Scene.cpp]"]
  node_shader_compile["Shader compilation<br/>[ShaderCompiler.cpp]"]
  node_uniforms["Shader interface<br/>[UniformLayout.hpp]"]
  node_evaluation["Frame evaluation<br/>[Evaluate.hpp]"]
  node_renderer["Scene renderer<br/>[Renderer.cpp]"]
end

subgraph group_vulkan["Vulkan Runtime"]
  node_vk_context["Vulkan context<br/>[VulkanContext.hpp]"]
  node_resources["GPU resources<br/>[Resources.hpp]"]
  node_swapchain["Swapchain<br/>[Swapchain.hpp]"]
end

node_user(("Shader author"))
node_window_gpu(("Window and GPU"))

node_user -->|"runs"| node_cli
node_user -->|"configures"| node_config
node_user -->|"authors"| node_shader_sources
node_cli -->|"starts"| node_app_loop
node_cli -->|"loads for header"| node_config
node_app_loop -->|"reloads"| node_config
node_app_loop -->|"watches inputs"| node_watcher
node_app_loop -->|"owns renderer"| node_renderer
node_config -->|"stores expressions"| node_expressions
node_config -->|"describes models"| node_models
node_config -->|"describes assets"| node_scene
node_shader_sources -->|"included and compiled"| node_shader_compile
node_config -->|"selects shaders"| node_shader_compile
node_config -->|"defines uniforms"| node_uniforms
node_expressions -->|"evaluated per frame"| node_evaluation
node_renderer -->|"evaluates values"| node_evaluation
node_renderer -->|"compiles shaders"| node_shader_compile
node_renderer -->|"draws scene"| node_scene
node_renderer -->|"writes uniforms"| node_uniforms
node_renderer -->|"uses GPU resources"| node_resources
node_renderer -->|"renders and presents"| node_swapchain
node_app_loop -->|"owns context"| node_vk_context
node_app_loop -->|"owns swapchain"| node_swapchain
node_vk_context -->|"creates surface and device"| node_window_gpu
node_swapchain -->|"uses context"| node_vk_context
node_resources -->|"allocates through"| node_vk_context
node_swapchain -->|"presents frames"| node_window_gpu

click node_cli "https://github.com/tixolan/varyn/blob/main/src/main.cpp"
click node_app_loop "https://github.com/tixolan/varyn/blob/main/src/App.hpp"
click node_watcher "https://github.com/tixolan/varyn/blob/main/src/FileWatcher.hpp"
click node_config "https://github.com/tixolan/varyn/blob/main/src/Config.cpp"
click node_expressions "https://github.com/tixolan/varyn/blob/main/src/Expression.cpp"
click node_shader_sources "https://github.com/tixolan/varyn/tree/main/examples/modules"
click node_models "https://github.com/tixolan/varyn/blob/main/src/Mesh.cpp"
click node_scene "https://github.com/tixolan/varyn/blob/main/src/render/Scene.cpp"
click node_shader_compile "https://github.com/tixolan/varyn/blob/main/src/ShaderCompiler.cpp"
click node_uniforms "https://github.com/tixolan/varyn/blob/main/src/UniformLayout.hpp"
click node_evaluation "https://github.com/tixolan/varyn/blob/main/src/render/Evaluate.hpp"
click node_renderer "https://github.com/tixolan/varyn/blob/main/src/render/Renderer.cpp"
click node_vk_context "https://github.com/tixolan/varyn/blob/main/src/vulkan/VulkanContext.hpp"
click node_resources "https://github.com/tixolan/varyn/blob/main/src/vulkan/Resources.hpp"
click node_swapchain "https://github.com/tixolan/varyn/blob/main/src/vulkan/Swapchain.hpp"

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_cli,node_app_loop,node_watcher toneBlue
class node_config,node_expressions,node_shader_sources,node_models toneAmber
class node_scene,node_shader_compile,node_uniforms,node_evaluation,node_renderer toneMint
class node_vk_context,node_resources,node_swapchain toneRose
class node_user,node_window_gpu toneIndigo
```

## Components

### Application

- [Command line](https://github.com/tixolan/varyn/blob/main/src/main.cpp): `src/main.cpp`
- [App loop](https://github.com/tixolan/varyn/blob/main/src/App.hpp): `src/App.hpp`
- [File watching](https://github.com/tixolan/varyn/blob/main/src/FileWatcher.hpp): `src/FileWatcher.hpp`

### Scene Inputs

- [TOML config](https://github.com/tixolan/varyn/blob/main/src/Config.cpp): `src/Config.cpp`
- [Expressions](https://github.com/tixolan/varyn/blob/main/src/Expression.cpp): `src/Expression.cpp`
- [Shader modules](https://github.com/tixolan/varyn/tree/main/examples/modules): `examples/modules`
- [Model loading](https://github.com/tixolan/varyn/blob/main/src/Mesh.cpp): `src/Mesh.cpp`

### Rendering

- [GPU scene assets](https://github.com/tixolan/varyn/blob/main/src/render/Scene.cpp): `src/render/Scene.cpp`
- [Shader compilation](https://github.com/tixolan/varyn/blob/main/src/ShaderCompiler.cpp): `src/ShaderCompiler.cpp`
- [Shader interface](https://github.com/tixolan/varyn/blob/main/src/UniformLayout.hpp): `src/UniformLayout.hpp`
- [Frame evaluation](https://github.com/tixolan/varyn/blob/main/src/render/Evaluate.hpp): `src/render/Evaluate.hpp`
- [Scene renderer](https://github.com/tixolan/varyn/blob/main/src/render/Renderer.cpp): `src/render/Renderer.cpp`

### Vulkan Runtime

- [Vulkan context](https://github.com/tixolan/varyn/blob/main/src/vulkan/VulkanContext.hpp): `src/vulkan/VulkanContext.hpp`
- [GPU resources](https://github.com/tixolan/varyn/blob/main/src/vulkan/Resources.hpp): `src/vulkan/Resources.hpp`
- [Swapchain](https://github.com/tixolan/varyn/blob/main/src/vulkan/Swapchain.hpp): `src/vulkan/Swapchain.hpp`

### Other components

- **Shader author**
- **Window and GPU**

## Connections

- Shader author → Command line: runs (evidence: `README.md`)
- Shader author → TOML config: configures (evidence: `README.md`)
- Shader author → Shader modules: authors (evidence: `README.md`)
- Command line → App loop: starts (evidence: `src/main.cpp`)
- Command line → TOML config: loads for header (evidence: `src/main.cpp`)
- App loop → TOML config: reloads (evidence: `src/App.hpp`)
- App loop → File watching: watches inputs (evidence: `src/App.hpp`)
- App loop → Scene renderer: owns renderer (evidence: `src/App.hpp`)
- TOML config → Expressions: stores expressions
- TOML config → Model loading: describes models (evidence: `README.md`)
- TOML config → GPU scene assets: describes assets
- Shader modules → Shader compilation: included and compiled (evidence: `README.md`)
- TOML config → Shader compilation: selects shaders
- TOML config → Shader interface: defines uniforms (evidence: `src/UniformLayout.hpp`)
- Expressions → Frame evaluation: evaluated per frame (evidence: `src/render/Evaluate.hpp`)
- Scene renderer → Frame evaluation: evaluates values (evidence: `src/render/Renderer.cpp`)
- Scene renderer → Shader compilation: compiles shaders
- Scene renderer → GPU scene assets: draws scene
- Scene renderer → Shader interface: writes uniforms
- Scene renderer → GPU resources: uses GPU resources
- Scene renderer → Swapchain: renders and presents
- App loop → Vulkan context: owns context (evidence: `src/App.hpp`)
- App loop → Swapchain: owns swapchain (evidence: `src/App.hpp`)
- Vulkan context → Window and GPU: creates surface and device (evidence: `src/vulkan/VulkanContext.hpp`)
- Swapchain → Vulkan context: uses context (evidence: `src/vulkan/Swapchain.hpp`)
- GPU resources → Vulkan context: allocates through (evidence: `src/vulkan/Resources.hpp`)
- Swapchain → Window and GPU: presents frames (evidence: `src/vulkan/Swapchain.hpp`)
