# banrod/unit architecture

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

- Interactive diagram: https://gitdiagram.com/banrod/unit
- Repository: https://github.com/banrod/unit

## Overview

Unit is a visual programming language and web environment: users compose programs as graphs of multi-input/multi-output units, then run them in a system and inspect or render results. The core runtime is centered on Graph, Unit, Pin, and System; specs represent and parse programs, while the client environment provides interaction and rendering. The README documents booting a system and instantiating a bundle, and the sampled storage primitive shows a platform API backed by browser storage. Some environment and integration links are documented only at a high level; unsampled implementation details are not inferred.

Main entry points: [`src/Class/Graph/index.ts`](https://github.com/banrod/unit/blob/main/src/Class/Graph/index.ts) (Graph execution), [`src/system.ts`](https://github.com/banrod/unit/blob/main/src/system.ts) (System context), [`src/boot/index.ts`](https://github.com/banrod/unit/blob/main/src/boot/index.ts) (System boot), [`src/spec/parser.ts`](https://github.com/banrod/unit/blob/main/src/spec/parser.ts) (Spec parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Visual authoring"]
  node_editor["Visual environment<br/>[component.ts]"]
  node_client_graph["Graph editor<br/>[graph.ts]"]
end

subgraph group_language["Language and specs"]
  node_spec_parser["Spec parser<br/>[parser.ts]"]
  node_spec_model["Graph specs<br/>[GraphSpec.ts]"]
  node_spec_values["Spec evaluation"]
  node_system_functions["Unit library"]
end

subgraph group_runtime["Graph runtime"]
  node_boot["System boot<br/>[index.ts]"]
  node_system["System context<br/>[system.ts]"]
  node_graph["Graph execution<br/>[index.ts]"]
  node_unit["Unit FSM<br/>[index.ts]"]
  node_pin["MIMO pins<br/>[Pin.ts]"]
end

subgraph group_environment["Client and platform"]
  node_render["Client rendering<br/>[index.ts]"]
  node_browser_api["Browser APIs<br/>[API.ts]"]
end

subgraph group_services["System services"]
  node_storage_primitive["Storage unit<br/>[Storage_.ts]"]
  node_storage_backend[("Browser storage<br/>[storage.ts]")]
  node_remote_client["Remote client<br/>[RemoteClient.ts]"]
  node_debug_tools["Runtime inspection<br/>[index.ts]"]
end

node_programmer(("Programmer"))

node_programmer -->|"composes programs"| node_editor
node_editor -.->|"edits graphs"| node_client_graph
node_client_graph -.->|"expresses graph specs"| node_spec_model
node_spec_parser -.->|"parses specs"| node_spec_model
node_spec_parser -->|"resolves unit values"| node_system_functions
node_programmer -->|"boots and instantiates"| node_boot
node_boot -->|"creates context"| node_system
node_boot -->|"starts bundle"| node_graph
node_system -->|"provides runtime context"| node_graph
node_graph -->|"manages units"| node_unit
node_unit -->|"maintains input and output pins"| node_pin
node_programmer -->|"renders bundles"| node_render
node_render -.->|"returns running graph"| node_graph
node_system -->|"exposes APIs"| node_browser_api
node_storage_primitive -->|"reads and writes"| node_storage_backend
node_remote_client -.->|"uses remote system"| node_system
node_debug_tools -->|"watches graph"| node_graph

click node_editor "https://github.com/banrod/unit/blob/main/src/client/component.ts"
click node_client_graph "https://github.com/banrod/unit/blob/main/src/client/graph.ts"
click node_spec_parser "https://github.com/banrod/unit/blob/main/src/spec/parser.ts"
click node_spec_model "https://github.com/banrod/unit/blob/main/src/types/GraphSpec.ts"
click node_spec_values "https://github.com/banrod/unit/blob/main/src/spec/evaluateDataValue.ts"
click node_system_functions "https://github.com/banrod/unit/tree/main/src/system/f"
click node_boot "https://github.com/banrod/unit/blob/main/src/boot/index.ts"
click node_system "https://github.com/banrod/unit/blob/main/src/system.ts"
click node_graph "https://github.com/banrod/unit/blob/main/src/Class/Graph/index.ts"
click node_unit "https://github.com/banrod/unit/blob/main/src/Class/Unit/index.ts"
click node_pin "https://github.com/banrod/unit/blob/main/src/Pin.ts"
click node_render "https://github.com/banrod/unit/blob/main/src/client/render/index.ts"
click node_browser_api "https://github.com/banrod/unit/blob/main/src/API.ts"
click node_storage_primitive "https://github.com/banrod/unit/blob/main/src/system/platform/api/storage/Storage_.ts"
click node_storage_backend "https://github.com/banrod/unit/blob/main/src/client/util/storage.ts"
click node_remote_client "https://github.com/banrod/unit/blob/main/src/RemoteClient.ts"
click node_debug_tools "https://github.com/banrod/unit/blob/main/src/debug/index.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_editor,node_client_graph toneBlue
class node_spec_parser,node_spec_model,node_spec_values,node_system_functions toneAmber
class node_boot,node_system,node_graph,node_unit,node_pin toneMint
class node_render,node_browser_api toneRose
class node_storage_primitive,node_storage_backend,node_remote_client,node_debug_tools,node_programmer toneIndigo
```

## Components

### Visual authoring

- [Visual environment](https://github.com/banrod/unit/blob/main/src/client/component.ts): `src/client/component.ts`
- [Graph editor](https://github.com/banrod/unit/blob/main/src/client/graph.ts): `src/client/graph.ts`

### Language and specs

- [Spec parser](https://github.com/banrod/unit/blob/main/src/spec/parser.ts): `src/spec/parser.ts`
- [Graph specs](https://github.com/banrod/unit/blob/main/src/types/GraphSpec.ts): `src/types/GraphSpec.ts`
- [Spec evaluation](https://github.com/banrod/unit/blob/main/src/spec/evaluateDataValue.ts): `src/spec/evaluateDataValue.ts`
- [Unit library](https://github.com/banrod/unit/tree/main/src/system/f): `src/system/f`

### Graph runtime

- [System boot](https://github.com/banrod/unit/blob/main/src/boot/index.ts): `src/boot/index.ts`
- [System context](https://github.com/banrod/unit/blob/main/src/system.ts): `src/system.ts`
- [Graph execution](https://github.com/banrod/unit/blob/main/src/Class/Graph/index.ts): `src/Class/Graph/index.ts`
- [Unit FSM](https://github.com/banrod/unit/blob/main/src/Class/Unit/index.ts): `src/Class/Unit/index.ts`
- [MIMO pins](https://github.com/banrod/unit/blob/main/src/Pin.ts): `src/Pin.ts`

### Client and platform

- [Client rendering](https://github.com/banrod/unit/blob/main/src/client/render/index.ts): `src/client/render/index.ts`
- [Browser APIs](https://github.com/banrod/unit/blob/main/src/API.ts): `src/API.ts`

### System services

- [Storage unit](https://github.com/banrod/unit/blob/main/src/system/platform/api/storage/Storage_.ts): `src/system/platform/api/storage/Storage_.ts`
- [Browser storage](https://github.com/banrod/unit/blob/main/src/client/util/storage.ts): `src/client/util/storage.ts`
- [Remote client](https://github.com/banrod/unit/blob/main/src/RemoteClient.ts): `src/RemoteClient.ts`
- [Runtime inspection](https://github.com/banrod/unit/blob/main/src/debug/index.ts): `src/debug/index.ts`

### Other components

- **Programmer**

## Connections

- Programmer → Visual environment: composes programs
- Visual environment → Graph editor: edits graphs
- Graph editor → Graph specs: expresses graph specs
- Spec parser → Graph specs: parses specs
- Spec parser → Unit library: resolves unit values (evidence: `src/spec/parser.ts`)
- Programmer → System boot: boots and instantiates
- System boot → System context: creates context (evidence: `src/boot/index.ts`)
- System boot → Graph execution: starts bundle (evidence: `src/boot/index.ts`)
- System context → Graph execution: provides runtime context (evidence: `src/system.ts`)
- Graph execution → Unit FSM: manages units (evidence: `src/Class/Graph/index.ts`)
- Unit FSM → MIMO pins: maintains input and output pins (evidence: `src/Class/Unit/index.ts`)
- Programmer → Client rendering: renders bundles
- Client rendering → Graph execution: returns running graph
- System context → Browser APIs: exposes APIs (evidence: `src/system.ts`)
- Storage unit → Browser storage: reads and writes (evidence: `src/system/platform/api/storage/Storage_.ts`)
- Remote client → System context: uses remote system
- Runtime inspection → Graph execution: watches graph (evidence: `src/debug/index.ts`)
