# patricksurry/g3 architecture

> Architecture diagram of the GitHub repository patricksurry/g3, 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/patricksurry/g3
- Repository: https://github.com/patricksurry/g3

## Overview

G3 is a browser-based JavaScript/SVG framework for composing live-metric instrument panels. The principal workflow is to assemble a panel and gauges, bind gauges to metric keys, feed reported values through a controller, and render indicator updates; interactive controls can send actions through the panel hub. The graph also preserves contributed navigation, engine, radio, electrical, clock, and switch instruments. Relationship evidence is limited to the README and the supplied source excerpts/index; unsampled subsystems are included only where the README or registry documents their capability.

Main entry points: [`src/gauge.ts`](https://github.com/patricksurry/g3/blob/master/src/gauge.ts) (Gauge component), [`src/contrib/__index__.ts`](https://github.com/patricksurry/g3/blob/master/src/contrib/__index__.ts) (Gauge registry), [`src/g3.ts`](https://github.com/patricksurry/g3/blob/master/src/g3.ts) (Public API), [`src/panel.ts`](https://github.com/patricksurry/g3/blob/master/src/panel.ts) (Panel builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_composition["Panel composition"]
  node_builder["Panel builder<br/>[panel.ts]"]
  node_panelgrid["Panel layout<br/>[grid.ts]"]
  node_api["Public API<br/>[g3.ts]"]
end

subgraph group_runtime["Metric runtime"]
  node_controller["Metric controller<br/>[controller.ts]"]
  node_metrics["Metric conversion<br/>[metrics.ts]"]
  node_hub["Action hub<br/>[hub.ts]"]
  node_fake["Fake timeseries<br/>[faketimeseries.ts]"]
end

subgraph group_rendering["SVG rendering"]
  node_gauge["Gauge component<br/>[gauge.ts]"]
  node_primitives["SVG primitives<br/>[common.ts]"]
  node_mixins["Render mixins<br/>[mixin.ts]"]
  node_axis["Axes and scales<br/>[axis.ts]"]
  node_indicators["Gauge indicators<br/>[indicate.ts]"]
  node_pointers["Pointer shapes<br/>[pointers.ts]"]
  node_surfaces["Gauge surfaces<br/>[sphere.ts]"]
  node_drum["Drum surface<br/>[drum.ts]"]
end

subgraph group_instruments["Contributed instruments"]
  node_registry["Gauge registry<br/>[__index__.ts]"]
  node_navigation["Navigation gauges<br/>[nav.ts]"]
  node_radio["Radio navigation<br/>[radionav.ts]"]
  node_engine["Engine gauges<br/>[dhc2-engine.ts]"]
  node_electrical["Electrical gauges<br/>[dhc2-electrical.ts]"]
  node_switches["Interactive switches<br/>[switches.ts]"]
  node_othergauges["Other gauges"]
end

node_simulator(("Simulator metrics"))
node_paneluser(("Panel author"))

node_paneluser -->|"assembles"| node_builder
node_builder -->|"lays out"| node_panelgrid
node_builder -->|"configures"| node_controller
node_builder -->|"configures"| node_hub
node_builder -->|"renders"| node_gauge
node_simulator -->|"reports metrics"| node_controller
node_controller -->|"converts units"| node_metrics
node_controller -.->|"updates"| node_gauge
node_gauge -->|"renders"| node_indicators
node_gauge -->|"renders"| node_panelgrid
node_gauge -->|"uses"| node_surfaces
node_gauge -->|"uses"| node_drum
node_gauge -->|"uses"| node_mixins
node_indicators -->|"registers metrics"| node_controller
node_indicators -->|"renders"| node_pointers
node_indicators -->|"uses"| node_mixins
node_axis -->|"uses"| node_mixins
node_primitives -->|"uses"| node_mixins
node_switches -->|"sends actions"| node_hub
node_switches -->|"composes controls"| node_api
node_registry -->|"registers"| node_navigation
node_registry -->|"registers"| node_radio
node_registry -->|"registers"| node_engine
node_registry -->|"registers"| node_electrical
node_registry -->|"registers"| node_switches
node_registry -->|"registers"| node_othergauges
node_navigation -->|"composes gauges"| node_api
node_radio -->|"composes gauges"| node_api
node_engine -->|"composes gauges"| node_api
node_electrical -.->|"composes gauges"| node_api
node_othergauges -.->|"provides gauges"| node_api
node_fake -.->|"supplies test data"| node_gauge

click node_builder "https://github.com/patricksurry/g3/blob/master/src/panel.ts"
click node_panelgrid "https://github.com/patricksurry/g3/blob/master/src/grid.ts"
click node_gauge "https://github.com/patricksurry/g3/blob/master/src/gauge.ts"
click node_primitives "https://github.com/patricksurry/g3/blob/master/src/common.ts"
click node_mixins "https://github.com/patricksurry/g3/blob/master/src/mixin.ts"
click node_axis "https://github.com/patricksurry/g3/blob/master/src/axis.ts"
click node_indicators "https://github.com/patricksurry/g3/blob/master/src/indicate.ts"
click node_pointers "https://github.com/patricksurry/g3/blob/master/src/pointers.ts"
click node_surfaces "https://github.com/patricksurry/g3/blob/master/src/sphere.ts"
click node_drum "https://github.com/patricksurry/g3/blob/master/src/drum.ts"
click node_controller "https://github.com/patricksurry/g3/blob/master/src/controller.ts"
click node_metrics "https://github.com/patricksurry/g3/blob/master/src/metrics.ts"
click node_hub "https://github.com/patricksurry/g3/blob/master/src/hub.ts"
click node_fake "https://github.com/patricksurry/g3/blob/master/src/faketimeseries.ts"
click node_api "https://github.com/patricksurry/g3/blob/master/src/g3.ts"
click node_registry "https://github.com/patricksurry/g3/blob/master/src/contrib/__index__.ts"
click node_navigation "https://github.com/patricksurry/g3/blob/master/src/contrib/nav.ts"
click node_radio "https://github.com/patricksurry/g3/blob/master/src/contrib/radionav.ts"
click node_engine "https://github.com/patricksurry/g3/blob/master/src/contrib/dhc2-engine.ts"
click node_electrical "https://github.com/patricksurry/g3/blob/master/src/contrib/dhc2-electrical.ts"
click node_switches "https://github.com/patricksurry/g3/blob/master/src/contrib/switches.ts"
click node_othergauges "https://github.com/patricksurry/g3/tree/master/src/contrib"

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_builder,node_panelgrid,node_api toneBlue
class node_controller,node_metrics,node_hub,node_fake toneAmber
class node_gauge,node_primitives,node_mixins,node_axis,node_indicators,node_pointers,node_surfaces,node_drum toneMint
class node_registry,node_navigation,node_radio,node_engine,node_electrical,node_switches,node_othergauges toneRose
class node_simulator,node_paneluser toneIndigo
```

## Components

### Panel composition

- [Panel builder](https://github.com/patricksurry/g3/blob/master/src/panel.ts): `src/panel.ts`
- [Panel layout](https://github.com/patricksurry/g3/blob/master/src/grid.ts): `src/grid.ts`
- [Public API](https://github.com/patricksurry/g3/blob/master/src/g3.ts): `src/g3.ts`

### Metric runtime

- [Metric controller](https://github.com/patricksurry/g3/blob/master/src/controller.ts): `src/controller.ts`
- [Metric conversion](https://github.com/patricksurry/g3/blob/master/src/metrics.ts): `src/metrics.ts`
- [Action hub](https://github.com/patricksurry/g3/blob/master/src/hub.ts): `src/hub.ts`
- [Fake timeseries](https://github.com/patricksurry/g3/blob/master/src/faketimeseries.ts): `src/faketimeseries.ts`

### SVG rendering

- [Gauge component](https://github.com/patricksurry/g3/blob/master/src/gauge.ts): `src/gauge.ts`
- [SVG primitives](https://github.com/patricksurry/g3/blob/master/src/common.ts): `src/common.ts`
- [Render mixins](https://github.com/patricksurry/g3/blob/master/src/mixin.ts): `src/mixin.ts`
- [Axes and scales](https://github.com/patricksurry/g3/blob/master/src/axis.ts): `src/axis.ts`
- [Gauge indicators](https://github.com/patricksurry/g3/blob/master/src/indicate.ts): `src/indicate.ts`
- [Pointer shapes](https://github.com/patricksurry/g3/blob/master/src/pointers.ts): `src/pointers.ts`
- [Gauge surfaces](https://github.com/patricksurry/g3/blob/master/src/sphere.ts): `src/sphere.ts`
- [Drum surface](https://github.com/patricksurry/g3/blob/master/src/drum.ts): `src/drum.ts`

### Contributed instruments

- [Gauge registry](https://github.com/patricksurry/g3/blob/master/src/contrib/__index__.ts): `src/contrib/__index__.ts`
- [Navigation gauges](https://github.com/patricksurry/g3/blob/master/src/contrib/nav.ts): `src/contrib/nav.ts`
- [Radio navigation](https://github.com/patricksurry/g3/blob/master/src/contrib/radionav.ts): `src/contrib/radionav.ts`
- [Engine gauges](https://github.com/patricksurry/g3/blob/master/src/contrib/dhc2-engine.ts): `src/contrib/dhc2-engine.ts`
- [Electrical gauges](https://github.com/patricksurry/g3/blob/master/src/contrib/dhc2-electrical.ts): `src/contrib/dhc2-electrical.ts`
- [Interactive switches](https://github.com/patricksurry/g3/blob/master/src/contrib/switches.ts): `src/contrib/switches.ts`
- [Other gauges](https://github.com/patricksurry/g3/tree/master/src/contrib): `src/contrib`

### Other components

- **Simulator metrics**
- **Panel author**

## Connections

- Panel author → Panel builder: assembles (evidence: `README.md`)
- Panel builder → Panel layout: lays out (evidence: `src/panel.ts`)
- Panel builder → Metric controller: configures (evidence: `src/panel.ts`)
- Panel builder → Action hub: configures (evidence: `src/panel.ts`)
- Panel builder → Gauge component: renders (evidence: `src/panel.ts`)
- Simulator metrics → Metric controller: reports metrics (evidence: `README.md`)
- Metric controller → Metric conversion: converts units (evidence: `src/controller.ts`)
- Metric controller → Gauge component: updates (evidence: `src/gauge.ts`)
- Gauge component → Gauge indicators: renders (evidence: `src/gauge.ts`)
- Gauge component → Panel layout: renders (evidence: `src/gauge.ts`)
- Gauge component → Gauge surfaces: uses (evidence: `src/gauge.ts`)
- Gauge component → Drum surface: uses (evidence: `src/gauge.ts`)
- Gauge component → Render mixins: uses (evidence: `src/gauge.ts`)
- Gauge indicators → Metric controller: registers metrics (evidence: `src/indicate.ts`)
- Gauge indicators → Pointer shapes: renders (evidence: `src/indicate.ts`)
- Gauge indicators → Render mixins: uses (evidence: `src/indicate.ts`)
- Axes and scales → Render mixins: uses (evidence: `src/axis.ts`)
- SVG primitives → Render mixins: uses (evidence: `src/common.ts`)
- Interactive switches → Action hub: sends actions (evidence: `src/contrib/switches.ts`)
- Interactive switches → Public API: composes controls (evidence: `src/contrib/switches.ts`)
- Gauge registry → Navigation gauges: registers (evidence: `src/contrib/__index__.ts`)
- Gauge registry → Radio navigation: registers (evidence: `src/contrib/__index__.ts`)
- Gauge registry → Engine gauges: registers (evidence: `src/contrib/__index__.ts`)
- Gauge registry → Electrical gauges: registers (evidence: `src/contrib/__index__.ts`)
- Gauge registry → Interactive switches: registers (evidence: `src/contrib/__index__.ts`)
- Gauge registry → Other gauges: registers (evidence: `src/contrib/__index__.ts`)
- Navigation gauges → Public API: composes gauges (evidence: `src/contrib/nav.ts`)
- Radio navigation → Public API: composes gauges (evidence: `src/contrib/radionav.ts`)
- Engine gauges → Public API: composes gauges (evidence: `src/contrib/dhc2-engine.ts`)
- Electrical gauges → Public API: composes gauges (evidence: `src/contrib/dhc2-electrical.ts`)
- Other gauges → Public API: provides gauges (evidence: `src/contrib/dhc2-engine.ts`)
- Fake timeseries → Gauge component: supplies test data
