# resnais-beefhair/brain-concert architecture

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

- Interactive diagram: https://gitdiagram.com/resnais-beefhair/brain-concert
- Repository: https://github.com/resnais-beefhair/brain-concert

## Overview

Brain Concert is a browser-based fruit-fly connectome artwork: it loads and validates a pinned network, runs a WebGPU neural simulation, and presents activity through interactive 3D visuals and procedural audio. The main application coordinates user controls, sensory stimulation, inspection, sharing and event export. Several core modules are only indexed by their imports, so those edges reflect documented or indexed wiring rather than inspected implementation details; no build or test machinery is included.

Main entry points: [`src/main.ts`](https://github.com/resnais-beefhair/brain-concert/blob/main/src/main.ts) (App orchestrator), [`src/gpu.ts`](https://github.com/resnais-beefhair/brain-concert/blob/main/src/gpu.ts) (WebGPU simulation), [`src/ui.ts`](https://github.com/resnais-beefhair/brain-concert/blob/main/src/ui.ts) (Interface controls), [`src/inspector.ts`](https://github.com/resnais-beefhair/brain-concert/blob/main/src/inspector.ts) (Neuron inspection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_app["App orchestrator<br/>[main.ts]"]
  node_state["App state<br/>[state.ts]"]
  node_events["Event export<br/>[event-log.ts]"]
  node_errors["Error mapping<br/>[errors.ts]"]
end

subgraph group_model["Network simulation"]
  node_data["Network loading<br/>[data.ts]"]
  node_gpu["WebGPU simulation<br/>[gpu.ts]"]
  node_inputs["Sensory inputs<br/>[inputs.ts]"]
end

subgraph group_experience["Visual and audio experience"]
  node_scene["3D visualization<br/>[scene.ts]"]
  node_sound["Procedural audio<br/>[sound.ts]"]
end

subgraph group_interaction["Controls and inspection"]
  node_loading["Load progress<br/>[loading.ts]"]
  node_ui["Interface controls<br/>[ui.ts]"]
  node_inspector["Neuron inspection<br/>[inspector.ts]"]
  node_urlstate["Shared settings<br/>[url-state.ts]"]
  node_i18n["English and Finnish<br/>[i18n.ts]"]
end

node_user(("User"))
node_browser["Browser APIs"]

node_user -->|"controls"| node_app
node_app -->|"mounts controls"| node_ui
node_app -->|"loads network"| node_data
node_app -->|"reports progress"| node_loading
node_app -->|"runs simulation"| node_gpu
node_app -->|"supplies stimulation"| node_inputs
node_app -->|"updates visuals"| node_scene
node_app -->|"schedules notes"| node_sound
node_app -->|"routes inspection"| node_inspector
node_app -->|"exports events"| node_events
node_app -->|"shares settings"| node_urlstate
node_app -->|"updates state"| node_state
node_app -->|"maps errors"| node_errors
node_app -->|"localizes interface"| node_i18n
node_data -->|"fetches and verifies"| node_browser
node_data -->|"builds network"| node_gpu
node_gpu -->|"dispatches WebGPU"| node_browser
node_scene -->|"reads network frames"| node_gpu
node_sound -->|"reads spike frames"| node_gpu
node_sound -->|"plays Web Audio"| node_browser
node_loading -->|"translates progress"| node_i18n
node_loading -->|"uses progress types"| node_data
node_ui -->|"renders loader"| node_loading
node_ui -->|"translates controls"| node_i18n
node_ui -->|"syncs settings"| node_state
node_inspector -->|"reads neuron data"| node_gpu
node_inspector -->|"renders details"| node_ui
node_inspector -->|"translates details"| node_i18n
node_urlstate -->|"serializes preferences"| node_state

click node_app "https://github.com/resnais-beefhair/brain-concert/blob/main/src/main.ts"
click node_state "https://github.com/resnais-beefhair/brain-concert/blob/main/src/state.ts"
click node_events "https://github.com/resnais-beefhair/brain-concert/blob/main/src/event-log.ts"
click node_errors "https://github.com/resnais-beefhair/brain-concert/blob/main/src/errors.ts"
click node_data "https://github.com/resnais-beefhair/brain-concert/blob/main/src/data.ts"
click node_loading "https://github.com/resnais-beefhair/brain-concert/blob/main/src/loading.ts"
click node_gpu "https://github.com/resnais-beefhair/brain-concert/blob/main/src/gpu.ts"
click node_inputs "https://github.com/resnais-beefhair/brain-concert/blob/main/src/inputs.ts"
click node_scene "https://github.com/resnais-beefhair/brain-concert/blob/main/src/scene.ts"
click node_sound "https://github.com/resnais-beefhair/brain-concert/blob/main/src/sound.ts"
click node_ui "https://github.com/resnais-beefhair/brain-concert/blob/main/src/ui.ts"
click node_inspector "https://github.com/resnais-beefhair/brain-concert/blob/main/src/inspector.ts"
click node_urlstate "https://github.com/resnais-beefhair/brain-concert/blob/main/src/url-state.ts"
click node_i18n "https://github.com/resnais-beefhair/brain-concert/blob/main/src/i18n.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_app,node_state,node_events,node_errors,node_user,node_browser toneBlue
class node_data,node_gpu,node_inputs toneAmber
class node_scene,node_sound toneMint
class node_loading,node_ui,node_inspector,node_urlstate,node_i18n toneRose
```

## Components

### Application runtime

- [App orchestrator](https://github.com/resnais-beefhair/brain-concert/blob/main/src/main.ts): `src/main.ts`
- [App state](https://github.com/resnais-beefhair/brain-concert/blob/main/src/state.ts): `src/state.ts`
- [Event export](https://github.com/resnais-beefhair/brain-concert/blob/main/src/event-log.ts): `src/event-log.ts`
- [Error mapping](https://github.com/resnais-beefhair/brain-concert/blob/main/src/errors.ts): `src/errors.ts`

### Network simulation

- [Network loading](https://github.com/resnais-beefhair/brain-concert/blob/main/src/data.ts): `src/data.ts`
- [WebGPU simulation](https://github.com/resnais-beefhair/brain-concert/blob/main/src/gpu.ts): `src/gpu.ts`
- [Sensory inputs](https://github.com/resnais-beefhair/brain-concert/blob/main/src/inputs.ts): `src/inputs.ts`

### Visual and audio experience

- [3D visualization](https://github.com/resnais-beefhair/brain-concert/blob/main/src/scene.ts): `src/scene.ts`
- [Procedural audio](https://github.com/resnais-beefhair/brain-concert/blob/main/src/sound.ts): `src/sound.ts`

### Controls and inspection

- [Load progress](https://github.com/resnais-beefhair/brain-concert/blob/main/src/loading.ts): `src/loading.ts`
- [Interface controls](https://github.com/resnais-beefhair/brain-concert/blob/main/src/ui.ts): `src/ui.ts`
- [Neuron inspection](https://github.com/resnais-beefhair/brain-concert/blob/main/src/inspector.ts): `src/inspector.ts`
- [Shared settings](https://github.com/resnais-beefhair/brain-concert/blob/main/src/url-state.ts): `src/url-state.ts`
- [English and Finnish](https://github.com/resnais-beefhair/brain-concert/blob/main/src/i18n.ts): `src/i18n.ts`

### Other components

- **User**
- **Browser APIs**

## Connections

- User → App orchestrator: controls (evidence: `README.md`)
- App orchestrator → Interface controls: mounts controls (evidence: `src/main.ts`)
- App orchestrator → Network loading: loads network (evidence: `src/main.ts`)
- App orchestrator → Load progress: reports progress (evidence: `src/main.ts`)
- App orchestrator → WebGPU simulation: runs simulation (evidence: `src/main.ts`)
- App orchestrator → Sensory inputs: supplies stimulation (evidence: `src/main.ts`)
- App orchestrator → 3D visualization: updates visuals (evidence: `README.md`)
- App orchestrator → Procedural audio: schedules notes (evidence: `README.md`)
- App orchestrator → Neuron inspection: routes inspection (evidence: `src/main.ts`)
- App orchestrator → Event export: exports events (evidence: `README.md`)
- App orchestrator → Shared settings: shares settings (evidence: `src/main.ts`)
- App orchestrator → App state: updates state (evidence: `src/main.ts`)
- App orchestrator → Error mapping: maps errors (evidence: `src/main.ts`)
- App orchestrator → English and Finnish: localizes interface (evidence: `src/main.ts`)
- Network loading → Browser APIs: fetches and verifies (evidence: `src/data.ts`)
- Network loading → WebGPU simulation: builds network (evidence: `src/data.ts`)
- WebGPU simulation → Browser APIs: dispatches WebGPU (evidence: `src/gpu.ts`)
- 3D visualization → WebGPU simulation: reads network frames (evidence: `src/scene.ts`)
- Procedural audio → WebGPU simulation: reads spike frames (evidence: `src/sound.ts`)
- Procedural audio → Browser APIs: plays Web Audio (evidence: `README.md`)
- Load progress → English and Finnish: translates progress (evidence: `src/loading.ts`)
- Load progress → Network loading: uses progress types (evidence: `src/loading.ts`)
- Interface controls → Load progress: renders loader (evidence: `src/ui.ts`)
- Interface controls → English and Finnish: translates controls (evidence: `src/ui.ts`)
- Interface controls → App state: syncs settings (evidence: `src/ui.ts`)
- Neuron inspection → WebGPU simulation: reads neuron data (evidence: `src/inspector.ts`)
- Neuron inspection → Interface controls: renders details (evidence: `src/inspector.ts`)
- Neuron inspection → English and Finnish: translates details (evidence: `src/inspector.ts`)
- Shared settings → App state: serializes preferences (evidence: `src/url-state.ts`)
