Skip to main content
Version: 0.2

Frontend modules

The front end lives under src/. Each module has a narrow responsibility.

ModuleResponsibility
main.tsBoot: order init, create renderer, load assets, build the brain, start the loop. See Boot sequence.
renderer.tsRenderer factory: returns a classic WebGLRenderer and the 'webgl2' backend tag.
scene.tsScene, camera, OrbitControls, Stats, helpers, stage sizing, status bar, and sceneSettings.
brain.tsThe Brain wrapper around the WASM World. See Brain.
run.tsThe requestAnimationFrame render loop. See Rendering pipeline.
events.tsKeyboard shortcuts and a debounced resize handler.
gui.tsThe lil-gui settings panel. See UI Guide.
brain-ui.tsThe product UI: mode tabs, stimulus upload, telemetry polling, live AI chat, and the custom searchable 9Router model menu.
loaders.tsPromise-wrapped OBJ and texture loaders.
materials/neuron.ts, materials/axon.tsThe GLSL ShaderMaterials. See Materials.
sim/types.tsThe TelemetrySnapshot contract types. See Telemetry.
diag/logger.tsThe in-app diagnostics logger. See Diagnostics Logger.
entry-server.tsSSR stub for vite build --ssr.
globals.d.tsAmbient types (window.neuralNet, shader module declarations).

Recent UI modules

ModuleResponsibility
chat/client.tsBrowser 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.tsModel/provider normalization and local icon mapping for the chat model picker.
chat/diagnostics.tsChat-specific diagnostics redaction before events enter the global diagnostics panel.
ui/observability.tsObservability 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.tsActivity-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 by Space.
  • enableGridHelper / enableAxisHelper: toggled by A / S.
  • bgColor: background color (default 0x0d0d0f), applied each frame because autoClear is off.
  • enableFloorPlatform: optional floor.

events.ts

Registers two listeners:

src/events.ts
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:

src/loaders.ts
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.