Frontend modules
The front end lives under src/. Each module has a narrow responsibility.
| Module | Responsibility |
|---|---|
main.ts | Boot: order init, create renderer, load assets, build the brain, start the loop. See Boot sequence. |
renderer.ts | Renderer factory: returns a classic WebGLRenderer and the 'webgl2' backend tag. |
scene.ts | Scene, camera, OrbitControls, Stats, helpers, stage sizing, status bar, and sceneSettings. |
brain.ts | The Brain wrapper around the WASM World. See Brain. |
run.ts | The requestAnimationFrame render loop. See Rendering pipeline. |
events.ts | Keyboard shortcuts and a debounced resize handler. |
gui.ts | The lil-gui settings panel. See UI Guide. |
brain-ui.ts | The product UI: mode tabs, stimulus upload, telemetry polling, live AI chat, and the custom searchable 9Router model menu. |
loaders.ts | Promise-wrapped OBJ and texture loaders. |
materials/neuron.ts, materials/axon.ts | The GLSL ShaderMaterials. See Materials. |
sim/types.ts | The TelemetrySnapshot contract types. See Telemetry. |
diag/logger.ts | The in-app diagnostics logger. See Diagnostics Logger. |
entry-server.ts | SSR stub for vite build --ssr. |
globals.d.ts | Ambient types (window.neuralNet, shader module declarations). |
Recent UI modules
| Module | Responsibility |
|---|---|
chat/client.ts | Browser client for EXEPERT Brain Chat: loads model metadata, builds chat requests, parses SSE tokens, logs sanitized diagnostics, and submits feedback to Supabase Edge Functions. |
chat/models.ts | Model/provider normalization and local icon mapping for the chat model picker. |
chat/diagnostics.ts | Chat-specific diagnostics redaction before events enter the global diagnostics panel. |
ui/observability.ts | Observability panel: mounts into #observabilitySlot in the activity-page view, with old #obsSlot as fallback; mounts project switcher, summary tile, trace list, and subscribes to project changes for re-render. Exports mountObservabilityPanel / unmountObservabilityPanel. |
ui/workbench.ts | Activity-bar view switching. Sets data-workbench-view for dashboard, prompts, observability, and settings; the Observability view shows the Trace Ingestion page outside the Chat area. |
scene.ts
Owns everything about the stage that is not the brain itself: the Scene, the
perspective camera, OrbitControls, the Stats overlay, the grid/axis
helpers, an optional floor platform, and the on-canvas status bar
(updateBrainStatusBar). It also holds sceneSettings, the mutable object the
GUI and keyboard handlers write to:
pause: toggled bySpace.enableGridHelper/enableAxisHelper: toggled byA/S.bgColor: background color (default0x0d0d0f), applied each frame becauseautoClearis off.enableFloorPlatform: optional floor.
events.ts
Registers two listeners:
window.addEventListener('keydown', (event) => {
switch (event.key) {
case ' ': sceneSettings.pause = !sceneSettings.pause; break
case 'a': case 'A': sceneSettings.enableGridHelper = !sceneSettings.enableGridHelper; break
case 's': case 'S': sceneSettings.enableAxisHelper = !sceneSettings.enableAxisHelper; break
}
})
Resize is debounced by 250 ms; onWindowResize updates the camera aspect,
the renderer size, and the pixel ratio from the current stage size.
loaders.ts
loadAllAssets() loads the two runtime assets in parallel and returns the
extracted vertices plus the texture:
const [brainGeom, electricTexture] = await Promise.all([
loadObj(objLoader, 'models/brain_vertex_low.obj'),
loadTexture(textureLoader, 'sprites/electric.png')
])
return { vertices: extractVertices(brainGeom), electricTexture }
extractVertices reads the OBJ's position attribute into an array of
Vector3. Those vertices are what the WASM World turns into neurons.
entry-server.ts
A small SSR entry used only by pnpm build:ssr. It returns a static HTML shell
that hydrates on the client; it is not part of the default build.