# webgpu/webgpu-samples architecture

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

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

## Overview

WebGPU Samples is a browser-based catalog and runner for demonstrations of the WebGPU API. A visitor browses or filters categorized samples, selects one, and the site displays it in an iframe alongside source tabs; local demos exercise WebGPU and web-platform integrations. The repository also contains reusable mesh construction and model data. The README documents the sample collection and its purpose; the graph uses the sampled site code for catalog, UI, and iframe relationships, and treats unsampled demo internals as subsystem-level components.

Main entry points: [`src/main.ts`](https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts) (Site Interface), [`meshes/mesh.ts`](https://github.com/webgpu/webgpu-samples/blob/main/meshes/mesh.ts) (Mesh Runtime), [`sample`](https://github.com/webgpu/webgpu-samples/tree/main/sample) (Basic Graphics), [`meshes/primitives.ts`](https://github.com/webgpu/webgpu-samples/blob/main/meshes/primitives.ts) (Mesh Generators)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_site["Sample Website"]
  node_site_app["Site Interface<br/>[main.ts]"]
  node_sample_registry["Sample Registry<br/>[samples.ts]"]
  node_dom_builder["DOM Builder<br/>[elem.ts]"]
  node_source_viewer["Source Viewer<br/>[main.ts]"]
  node_demo_frame["Demo Frame<br/>[main.ts]"]
  node_iframe_helper["Frame Resizer<br/>[iframe-helper.js]"]
end

subgraph group_demos["Demo Catalog"]
  node_basic_graphics["Basic Graphics"]
  node_webgpu_features["WebGPU Features"]
  node_gpgpu_demos["GPGPU Demos"]
  node_graphics_techniques["Graphics Techniques"]
  node_platform_demos["Platform Integration"]
  node_benchmarks["Benchmarks"]
end

subgraph group_geometry["Mesh Support"]
  node_mesh_runtime["Mesh Runtime<br/>[mesh.ts]"]
  node_mesh_generators["Mesh Generators<br/>[primitives.ts]"]
  node_dragon_mesh["Dragon Mesh Data"]
end

node_visitor(("Visitor"))
node_webgpu{{"WebGPU API"}}

node_visitor -->|"browses"| node_site_app
node_site_app -->|"loads catalog"| node_sample_registry
node_site_app -->|"builds UI"| node_dom_builder
node_site_app -->|"shows source"| node_source_viewer
node_site_app -->|"runs sample"| node_demo_frame
node_demo_frame -.->|"reports size"| node_iframe_helper
node_basic_graphics -->|"demonstrates"| node_webgpu
node_webgpu_features -->|"demonstrates"| node_webgpu
node_gpgpu_demos -->|"demonstrates"| node_webgpu
node_graphics_techniques -->|"demonstrates"| node_webgpu
node_platform_demos -->|"integrates"| node_webgpu
node_benchmarks -->|"benchmarks"| node_webgpu
node_mesh_generators -.->|"creates mesh data"| node_mesh_runtime
node_dragon_mesh -.->|"supplies geometry"| node_mesh_runtime

click node_site_app "https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts"
click node_sample_registry "https://github.com/webgpu/webgpu-samples/blob/main/src/samples.ts"
click node_dom_builder "https://github.com/webgpu/webgpu-samples/blob/main/src/utils/elem.ts"
click node_source_viewer "https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts"
click node_demo_frame "https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts"
click node_iframe_helper "https://github.com/webgpu/webgpu-samples/blob/main/public/js/iframe-helper.js"
click node_basic_graphics "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_webgpu_features "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_gpgpu_demos "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_graphics_techniques "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_platform_demos "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_benchmarks "https://github.com/webgpu/webgpu-samples/tree/main/sample"
click node_mesh_runtime "https://github.com/webgpu/webgpu-samples/blob/main/meshes/mesh.ts"
click node_mesh_generators "https://github.com/webgpu/webgpu-samples/blob/main/meshes/primitives.ts"
click node_dragon_mesh "https://github.com/webgpu/webgpu-samples/blob/main/meshes/stanfordDragonData.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_site_app,node_sample_registry,node_dom_builder,node_source_viewer,node_demo_frame,node_iframe_helper toneBlue
class node_basic_graphics,node_webgpu_features,node_gpgpu_demos,node_graphics_techniques,node_platform_demos,node_benchmarks toneAmber
class node_mesh_runtime,node_mesh_generators,node_dragon_mesh,node_webgpu toneMint
class node_visitor toneIndigo
```

## Components

### Sample Website

- [Site Interface](https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts): `src/main.ts`
- [Sample Registry](https://github.com/webgpu/webgpu-samples/blob/main/src/samples.ts): `src/samples.ts`
- [DOM Builder](https://github.com/webgpu/webgpu-samples/blob/main/src/utils/elem.ts): `src/utils/elem.ts`
- [Source Viewer](https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts): `src/main.ts`
- [Demo Frame](https://github.com/webgpu/webgpu-samples/blob/main/src/main.ts): `src/main.ts`
- [Frame Resizer](https://github.com/webgpu/webgpu-samples/blob/main/public/js/iframe-helper.js): `public/js/iframe-helper.js`

### Demo Catalog

- [Basic Graphics](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`
- [WebGPU Features](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`
- [GPGPU Demos](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`
- [Graphics Techniques](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`
- [Platform Integration](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`
- [Benchmarks](https://github.com/webgpu/webgpu-samples/tree/main/sample): `sample`

### Mesh Support

- [Mesh Runtime](https://github.com/webgpu/webgpu-samples/blob/main/meshes/mesh.ts): `meshes/mesh.ts`
- [Mesh Generators](https://github.com/webgpu/webgpu-samples/blob/main/meshes/primitives.ts): `meshes/primitives.ts`
- [Dragon Mesh Data](https://github.com/webgpu/webgpu-samples/blob/main/meshes/stanfordDragonData.ts): `meshes/stanfordDragonData.ts`

### Other components

- **Visitor**
- **WebGPU API**

## Connections

- Visitor → Site Interface: browses (evidence: `README.md`)
- Site Interface → Sample Registry: loads catalog (evidence: `src/main.ts`)
- Site Interface → DOM Builder: builds UI (evidence: `src/main.ts`)
- Site Interface → Source Viewer: shows source (evidence: `src/main.ts`)
- Site Interface → Demo Frame: runs sample (evidence: `src/main.ts`)
- Demo Frame → Frame Resizer: reports size
- Basic Graphics → WebGPU API: demonstrates (evidence: `README.md`)
- WebGPU Features → WebGPU API: demonstrates (evidence: `README.md`)
- GPGPU Demos → WebGPU API: demonstrates (evidence: `README.md`)
- Graphics Techniques → WebGPU API: demonstrates (evidence: `README.md`)
- Platform Integration → WebGPU API: integrates (evidence: `README.md`)
- Benchmarks → WebGPU API: benchmarks (evidence: `README.md`)
- Mesh Generators → Mesh Runtime: creates mesh data
- Dragon Mesh Data → Mesh Runtime: supplies geometry
