# asfadmin/archive_heatmaps architecture

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

- Interactive diagram: https://gitdiagram.com/asfadmin/archive_heatmaps
- Repository: https://github.com/asfadmin/archive_heatmaps

## Overview

#### Purpose and Delivery

Archive Heatmap is a browser-hosted, interactive visualization client for Sentinel-1 archive coverage. Users choose date ranges, product types, and platforms; the client retrieves matching archive data and renders a GPU-backed geographic heatmap. The HTML/Wasm entry point is `index.html`, with application bootstrap in `src/main.rs`; Trunk builds and serves the Rust-to-WebAssembly application (`Trunk.toml`).

#### Application Composition

The codebase is organized around three architectural subsystems:
- Canvas/GPU rendering: `src/canvas/mod.rs`, `src/canvas/app.rs`, `src/canvas/pipeline.rs`
- Archive querying and geometry preparation: `src/ingest/mod.rs`, `src/ingest/load.rs`, `src/ingest/mesh.rs`
- Overlay UI and query controls: `src/ui/mod.rs`, `src/ui/user_interface.rs`, `src/ui/legend.rs`

Shared domain/state types live in `src/types.rs`.

#### UI and Interaction Boundary

The UI is overlaid on the rendered heatmap and supplies the archive-selection inputs and user feedback. `src/ui/user_interface.rs` coordinates controls, while `src/ui/popup.rs` and `src/ui/feedback.rs` support transient interaction/status surfaces. UI submission is the primary boundary into ingest: it turns selected filters into a request rather than directly manipulating GPU resources.

#### Ingest and Query Pipeline

The ingest layer queries public archive data through browser DuckDB integration. `src/ingest/request.rs` represents query/request concerns, `src/ingest/sql.rs` defines SQL-facing logic, and `src/ingest/async_duckdb.rs` manages asynchronous DuckDB execution. The browser-side DuckDB asset is `assets/duckdb-browser.mjs`, with supporting glue in `src/ingest/duckdb.js`.

Query results are loaded and transformed into renderable geographic mesh data by `src/ingest/load.rs` and `src/ingest/mesh.rs`. This is the key data boundary: archive/query-oriented records become GPU-friendly geometry.

#### Canvas State, Camera, and Input

`src/canvas/app.rs` orchestrates the visualization lifecycle. Persistent rendering/application state is held in `src/canvas/state.rs`; navigation/view transformation is separated into `src/canvas/camera.rs`; browser interaction is translated by `src/canvas/input.rs`. This keeps user gestures and UI actions distinct from mesh generation and low-level rendering.

#### GPU Rendering and Export

wgpu/Wasm rendering infrastructure is centered on `src/canvas/render_context.rs`, `src/canvas/pipeline.rs`, and `src/canvas/texture.rs`. Geometry enters through `src/canvas/geometry.rs`, then shader pipelines generate and composite heatmap layers. WGSL programs include blending, colormapping, outlines, and export paths under `src/canvas/shaders/`.

The renderer also supports image output via `src/canvas/png.rs` and export shaders such as `src/canvas/shaders/export.wgsl`. Colormap/static visual assets are supplied from `assets`.

#### Runtime and External Dependencies

The production runtime is a static web client compiled from Rust to `wasm32-unknown-unknown`, built/served with Trunk. It requires nightly Rust per `rust-toolchain.toml`. Browser GPU access is provided through wgpu-compatible WebGPU/Wasm execution. DuckDB runs in the browser and accesses archive data from a public S3 bucket; Sentinel-1 data is attributed to the Alaska Satellite Facility. GitHub Pages deployment is defined in `.github/workflows/gh-pages-deploy.yml`.

Main entry points: [`src/main.rs`](https://github.com/asfadmin/archive_heatmaps/blob/main/src/main.rs) (Application bootstrap), [`src/ingest/async_duckdb.rs`](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/async_duckdb.rs) (Browser DuckDB), [`src/canvas/app.rs`](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/app.rs) (Visualization lifecycle), [`src/canvas/pipeline.rs`](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/pipeline.rs) (Heatmap renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Web Delivery"]
  node_entry["Browser entry point<br/>HTML/Wasm entry<br/>[index.html]"]
  node_bootstrap["Application bootstrap<br/>Rust startup<br/>[main.rs]"]
  node_trunk{{"Trunk build and serve<br/>Wasm build tool<br/>[Trunk.toml]"}}
  node_deployment["GitHub Pages deployment<br/>static deployment"]
end

subgraph group_ui["Overlay UI"]
  node_ui_controls["Query controls<br/>UI coordinator<br/>[user_interface.rs]"]
  node_ui_surfaces["Legend and transient UI<br/>UI surfaces<br/>[legend.rs]"]
end

subgraph group_ingest["Archive Ingest"]
  node_request["Archive request<br/>query request<br/>[request.rs]"]
  node_duckdb[("Browser DuckDB<br/>async query engine<br/>[async_duckdb.rs]")]
  node_duckdb_asset["DuckDB browser asset<br/>browser module<br/>[duckdb-browser.mjs]"]
  node_archive[("Public Sentinel-1 archive<br/>external S3 data")]
  node_mesh["Geographic mesh preparation<br/>record-to-mesh transform<br/>[mesh.rs]"]
end

subgraph group_canvas["Canvas and GPU"]
  node_app["Visualization lifecycle<br/>canvas orchestrator<br/>[app.rs]"]
  node_state_camera_input["View state and input<br/>interaction state<br/>[state.rs]"]
  node_geometry["GPU geometry<br/>render geometry<br/>[geometry.rs]"]
  node_renderer["Heatmap renderer<br/>wgpu pipeline<br/>[pipeline.rs]"]
  node_png_export["Image export<br/>PNG output<br/>[png.rs]"]
end

node_webgpu{{"WebGPU/Wasm runtime<br/>browser GPU runtime"}}

node_trunk -->|"builds and serves"| node_entry
node_trunk -->|"compiles to Wasm"| node_bootstrap
node_entry -->|"loads"| node_bootstrap
node_bootstrap -->|"starts"| node_app
node_bootstrap -->|"mounts"| node_ui_controls
node_ui_controls -->|"updates"| node_ui_surfaces
node_ui_controls -->|"submits filters"| node_request
node_request -->|"drives query"| node_duckdb
node_duckdb_asset -->|"provides browser engine"| node_duckdb
node_duckdb -->|"queries"| node_archive
node_duckdb -->|"returns records"| node_mesh
node_mesh -->|"produces"| node_geometry
node_app -->|"coordinates"| node_state_camera_input
node_state_camera_input -->|"navigation and gestures"| node_app
node_geometry -->|"uploads"| node_renderer
node_app -->|"renders with state"| node_renderer
node_renderer -->|"uses"| node_webgpu
node_renderer -->|"exports image"| node_png_export
node_deployment -->|"publishes static client"| node_entry

click node_entry "https://github.com/asfadmin/archive_heatmaps/blob/main/index.html"
click node_bootstrap "https://github.com/asfadmin/archive_heatmaps/blob/main/src/main.rs"
click node_trunk "https://github.com/asfadmin/archive_heatmaps/blob/main/Trunk.toml"
click node_ui_controls "https://github.com/asfadmin/archive_heatmaps/blob/main/src/ui/user_interface.rs"
click node_ui_surfaces "https://github.com/asfadmin/archive_heatmaps/blob/main/src/ui/legend.rs"
click node_request "https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/request.rs"
click node_duckdb "https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/async_duckdb.rs"
click node_duckdb_asset "https://github.com/asfadmin/archive_heatmaps/blob/main/assets/duckdb-browser.mjs"
click node_mesh "https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/mesh.rs"
click node_app "https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/app.rs"
click node_state_camera_input "https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/state.rs"
click node_geometry "https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/geometry.rs"
click node_renderer "https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/pipeline.rs"
click node_png_export "https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/png.rs"
click node_deployment "https://github.com/asfadmin/archive_heatmaps/blob/main/.github/workflows/gh-pages-deploy.yml"

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_entry,node_bootstrap,node_trunk,node_deployment toneBlue
class node_ui_controls,node_ui_surfaces toneAmber
class node_request,node_duckdb,node_duckdb_asset,node_archive,node_mesh toneMint
class node_app,node_state_camera_input,node_geometry,node_renderer,node_png_export toneRose
class node_webgpu toneNeutral
```

## Components

### Web Delivery

- [Browser entry point](https://github.com/asfadmin/archive_heatmaps/blob/main/index.html): HTML/Wasm entry · `index.html`
- [Application bootstrap](https://github.com/asfadmin/archive_heatmaps/blob/main/src/main.rs): Rust startup · `src/main.rs`
- [Trunk build and serve](https://github.com/asfadmin/archive_heatmaps/blob/main/Trunk.toml): Wasm build tool · `Trunk.toml`
- [GitHub Pages deployment](https://github.com/asfadmin/archive_heatmaps/blob/main/.github/workflows/gh-pages-deploy.yml): static deployment · `.github/workflows/gh-pages-deploy.yml`

### Overlay UI

- [Query controls](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ui/user_interface.rs): UI coordinator · Collects archive filters and shows interaction feedback. · `src/ui/user_interface.rs`
- [Legend and transient UI](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ui/legend.rs): UI surfaces · `src/ui/legend.rs`

### Archive Ingest

- [Archive request](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/request.rs): query request · `src/ingest/request.rs`
- [Browser DuckDB](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/async_duckdb.rs): async query engine · Executes SQL in the browser. · `src/ingest/async_duckdb.rs`
- [DuckDB browser asset](https://github.com/asfadmin/archive_heatmaps/blob/main/assets/duckdb-browser.mjs): browser module · `assets/duckdb-browser.mjs`
- **Public Sentinel-1 archive**: external S3 data
- [Geographic mesh preparation](https://github.com/asfadmin/archive_heatmaps/blob/main/src/ingest/mesh.rs): record-to-mesh transform · Converts query results into GPU-friendly geographic geometry. · `src/ingest/mesh.rs`

### Canvas and GPU

- [Visualization lifecycle](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/app.rs): canvas orchestrator · `src/canvas/app.rs`
- [View state and input](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/state.rs): interaction state · Maintains render state, camera transforms, and browser gesture translation. · `src/canvas/state.rs`
- [GPU geometry](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/geometry.rs): render geometry · `src/canvas/geometry.rs`
- [Heatmap renderer](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/pipeline.rs): wgpu pipeline · Builds and composites GPU heatmap layers. · `src/canvas/pipeline.rs`
- [Image export](https://github.com/asfadmin/archive_heatmaps/blob/main/src/canvas/png.rs): PNG output · `src/canvas/png.rs`

### Other components

- **WebGPU/Wasm runtime**: browser GPU runtime

## Connections

- Trunk build and serve → Browser entry point: builds and serves
- Trunk build and serve → Application bootstrap: compiles to Wasm
- Browser entry point → Application bootstrap: loads
- Application bootstrap → Visualization lifecycle: starts
- Application bootstrap → Query controls: mounts
- Query controls → Legend and transient UI: updates
- Query controls → Archive request: submits filters
- Archive request → Browser DuckDB: drives query
- DuckDB browser asset → Browser DuckDB: provides browser engine
- Browser DuckDB → Public Sentinel-1 archive: queries
- Browser DuckDB → Geographic mesh preparation: returns records
- Geographic mesh preparation → GPU geometry: produces
- Visualization lifecycle → View state and input: coordinates
- View state and input → Visualization lifecycle: navigation and gestures
- GPU geometry → Heatmap renderer: uploads
- Visualization lifecycle → Heatmap renderer: renders with state
- Heatmap renderer → WebGPU/Wasm runtime: uses
- Heatmap renderer → Image export: exports image
- GitHub Pages deployment → Browser entry point: publishes static client
