# junxiangzhan/webgpu-test architecture

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

- Interactive diagram: https://gitdiagram.com/junxiangzhan/webgpu-test
- Repository: https://github.com/junxiangzhan/webgpu-test

## Overview

This repository is a TypeScript/WebGPU UI and rendering framework, demonstrated by an example app that initializes a canvas, builds widgets and routes, handles gestures, and renders UI passes. Its broader documented API covers GPU pipelines and resources, WGSL-oriented structured data, dirty-range updates, automatic disposal, and vector/matrix math. Edges are limited to relationships visible in excerpts, the SOURCE INDEX, or README; some documented capabilities have unsampled implementations, so their internal wiring is not inferred.

Main entry points: [`src/core/render/render.ts`](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/render/render.ts) (Render queue), [`src/app/index.ts`](https://github.com/junxiangzhan/webgpu-test/blob/main/src/app/index.ts) (Example app), [`src/utilities/render/bind-group.ts`](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/bind-group.ts) (Bind groups), [`src/utilities/render/pipeline.ts`](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/pipeline.ts) (Render pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Example application"]
  node_main["Application entry<br/>[main.ts]"]
  node_app["Example app<br/>[index.ts]"]
end

subgraph group_ui["UI components"]
  node_component["Component base<br/>[component.ts]"]
  node_widget["Widget container<br/>[widget.ts]"]
  node_layout["Layout managers"]
  node_interactable["Gesture interaction<br/>[interactable.ts]"]
  node_gesture["Gesture target<br/>[gesture.ts]"]
  node_routes["UI routes<br/>[routes.ts]"]
  node_router["Route source<br/>[router-source.ts]"]
end

subgraph group_renderer["Rendering system"]
  node_context["WebGPU context<br/>[context.ts]"]
  node_render["Render queue<br/>[render.ts]"]
end

subgraph group_gpu["GPU resources"]
  node_pipeline["Render pipeline<br/>[pipeline.ts]"]
  node_bindgroup["Bind groups<br/>[bind-group.ts]"]
  node_vertex["Vertex arrays<br/>[vertex-array.ts]"]
  node_verticesview["Vertex buffer view<br/>[vertices-view.ts]"]
  node_buffer["Buffer views<br/>[buffer-view.ts]"]
  node_struct["Structured data<br/>[struct.ts]"]
  node_structuredview["Structured views<br/>[structured-view.ts]"]
  node_texture["Texture resources<br/>[texture.ts]"]
  node_texture2d["2D textures<br/>[texture-2d.ts]"]
  node_shader["Shader modules<br/>[shader-module.ts]"]
end

subgraph group_math["Math utilities"]
  node_vector["Vectors<br/>[vector.ts]"]
  node_matrix["Matrices<br/>[matrix.ts]"]
end

node_user(("App user"))

node_user -->|"opens app"| node_main
node_main -->|"starts"| node_app
node_app -->|"initializes"| node_context
node_app -->|"builds UI"| node_widget
node_app -->|"handles input"| node_gesture
node_app -->|"begins UI pass"| node_render
node_widget -->|"selects layout"| node_layout
node_widget -->|"extends"| node_interactable
node_interactable -->|"uses gestures"| node_gesture
node_routes -->|"uses route source"| node_router
node_component -->|"queues draw"| node_render
node_component -->|"creates bindings"| node_bindgroup
node_render -->|"reads context"| node_context
node_render -->|"uses pipeline"| node_pipeline
node_render -->|"uses vertices"| node_vertex
node_render -->|"uses bindings"| node_bindgroup
node_pipeline -->|"builds layout"| node_bindgroup
node_pipeline -->|"uses shaders"| node_shader
node_pipeline -->|"reads layout"| node_vertex
node_vertex -->|"stores vertices"| node_verticesview
node_verticesview -->|"uses buffer view"| node_buffer
node_struct -->|"writes structured data"| node_structuredview
node_structuredview -->|"extends buffer view"| node_buffer
node_bindgroup -->|"accepts structs"| node_struct
node_bindgroup -->|"binds textures"| node_texture
node_texture2d -.->|"specializes texture"| node_texture
node_matrix -->|"uses vectors"| node_vector
node_matrix -->|"writes matrix data"| node_structuredview
node_vector -->|"supports structured data"| node_structuredview

click node_main "https://github.com/junxiangzhan/webgpu-test/blob/main/src/main.ts"
click node_app "https://github.com/junxiangzhan/webgpu-test/blob/main/src/app/index.ts"
click node_context "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/render/context.ts"
click node_render "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/render/render.ts"
click node_component "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/component.ts"
click node_widget "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/widget.ts"
click node_layout "https://github.com/junxiangzhan/webgpu-test/tree/main/src/core/components/layout"
click node_interactable "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/interactable.ts"
click node_gesture "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/gesture.ts"
click node_routes "https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/routes.ts"
click node_router "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/router-source.ts"
click node_pipeline "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/pipeline.ts"
click node_bindgroup "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/bind-group.ts"
click node_vertex "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/vertex-array.ts"
click node_verticesview "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/vertices-view.ts"
click node_buffer "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/buffer-view.ts"
click node_struct "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/struct.ts"
click node_structuredview "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/structured-view.ts"
click node_texture "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/texture.ts"
click node_texture2d "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/texture-2d.ts"
click node_shader "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/shader-module.ts"
click node_vector "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/math/vector.ts"
click node_matrix "https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/math/matrix.ts"

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_main,node_app,node_user toneBlue
class node_component,node_widget,node_layout,node_interactable,node_gesture,node_routes,node_router toneAmber
class node_context,node_render toneMint
class node_pipeline,node_bindgroup,node_vertex,node_verticesview,node_buffer,node_struct,node_structuredview,node_texture,node_texture2d,node_shader toneRose
class node_vector,node_matrix toneIndigo
```

## Components

### Example application

- [Application entry](https://github.com/junxiangzhan/webgpu-test/blob/main/src/main.ts): `src/main.ts`
- [Example app](https://github.com/junxiangzhan/webgpu-test/blob/main/src/app/index.ts): `src/app/index.ts`

### UI components

- [Component base](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/component.ts): `src/core/components/component.ts`
- [Widget container](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/widget.ts): `src/core/components/widget.ts`
- [Layout managers](https://github.com/junxiangzhan/webgpu-test/tree/main/src/core/components/layout): `src/core/components/layout`
- [Gesture interaction](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/interactable.ts): `src/core/components/interactable.ts`
- [Gesture target](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/gesture.ts): `src/utilities/gesture.ts`
- [UI routes](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/components/routes.ts): `src/core/components/routes.ts`
- [Route source](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/router-source.ts): `src/utilities/router-source.ts`

### Rendering system

- [WebGPU context](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/render/context.ts): `src/core/render/context.ts`
- [Render queue](https://github.com/junxiangzhan/webgpu-test/blob/main/src/core/render/render.ts): `src/core/render/render.ts`

### GPU resources

- [Render pipeline](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/pipeline.ts): `src/utilities/render/pipeline.ts`
- [Bind groups](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/bind-group.ts): `src/utilities/render/bind-group.ts`
- [Vertex arrays](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/vertex-array.ts): `src/utilities/render/vertex-array.ts`
- [Vertex buffer view](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/vertices-view.ts): `src/utilities/render/vertices-view.ts`
- [Buffer views](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/buffer-view.ts): `src/utilities/render/buffer-view.ts`
- [Structured data](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/struct.ts): `src/utilities/render/struct.ts`
- [Structured views](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/structured-view.ts): `src/utilities/render/structured-view.ts`
- [Texture resources](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/texture.ts): `src/utilities/render/texture.ts`
- [2D textures](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/texture-2d.ts): `src/utilities/render/texture-2d.ts`
- [Shader modules](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/render/shader-module.ts): `src/utilities/render/shader-module.ts`

### Math utilities

- [Vectors](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/math/vector.ts): `src/utilities/math/vector.ts`
- [Matrices](https://github.com/junxiangzhan/webgpu-test/blob/main/src/utilities/math/matrix.ts): `src/utilities/math/matrix.ts`

### Other components

- **App user**

## Connections

- App user → Application entry: opens app
- Application entry → Example app: starts (evidence: `src/main.ts`)
- Example app → WebGPU context: initializes (evidence: `src/app/index.ts`)
- Example app → Widget container: builds UI (evidence: `src/app/index.ts`)
- Example app → Gesture target: handles input (evidence: `src/app/index.ts`)
- Example app → Render queue: begins UI pass (evidence: `src/app/index.ts`)
- Widget container → Layout managers: selects layout (evidence: `src/core/components/widget.ts`)
- Widget container → Gesture interaction: extends (evidence: `src/core/components/widget.ts`)
- Gesture interaction → Gesture target: uses gestures (evidence: `src/core/components/interactable.ts`)
- UI routes → Route source: uses route source (evidence: `src/core/components/routes.ts`)
- Component base → Render queue: queues draw (evidence: `src/core/components/component.ts`)
- Component base → Bind groups: creates bindings (evidence: `src/core/components/component.ts`)
- Render queue → WebGPU context: reads context (evidence: `src/core/render/render.ts`)
- Render queue → Render pipeline: uses pipeline (evidence: `src/core/render/render.ts`)
- Render queue → Vertex arrays: uses vertices (evidence: `src/core/render/render.ts`)
- Render queue → Bind groups: uses bindings (evidence: `src/core/render/render.ts`)
- Render pipeline → Bind groups: builds layout (evidence: `src/utilities/render/pipeline.ts`)
- Render pipeline → Shader modules: uses shaders (evidence: `src/utilities/render/pipeline.ts`)
- Render pipeline → Vertex arrays: reads layout (evidence: `src/utilities/render/pipeline.ts`)
- Vertex arrays → Vertex buffer view: stores vertices (evidence: `src/utilities/render/vertex-array.ts`)
- Vertex buffer view → Buffer views: uses buffer view (evidence: `src/utilities/render/vertices-view.ts`)
- Structured data → Structured views: writes structured data (evidence: `src/utilities/render/struct.ts`)
- Structured views → Buffer views: extends buffer view (evidence: `src/utilities/render/structured-view.ts`)
- Bind groups → Structured data: accepts structs (evidence: `src/utilities/render/bind-group.ts`)
- Bind groups → Texture resources: binds textures (evidence: `src/utilities/render/bind-group.ts`)
- 2D textures → Texture resources: specializes texture
- Matrices → Vectors: uses vectors (evidence: `src/utilities/math/matrix.ts`)
- Matrices → Structured views: writes matrix data (evidence: `src/utilities/math/matrix.ts`)
- Vectors → Structured views: supports structured data (evidence: `src/utilities/math/vector.ts`)
