How dunkeln/mobisim works
1. What this repo is
- mobisim is a SvelteKit application that serves a Chrome-first 360° vehicle inspection shell.
- The core experience is an asset-scoped viewer: one selected vehicle asset at a time, with chat, voice, inspection tools, semantic overlays, and deterministic edit/highlight behavior.
2. Top-level app boundaries
- The route structure is split into:
- Public routes for sign-in.
- Authenticated app routes under /(app)/app, including the inspection page.
- API routes under /api/... for chat, audio, semantic operations, and asset-specific actions.
- This is a strong boundary in the architecture: the UI shell is gated, while most stateful operations happen through server routes.
3. Viewer and inspection UI
- The 3D/inspection surface is built with Threlte-based components in src/lib/components/threlte.
- Key UI areas include:
- the inspection viewport
- the inspector sidebar
- a footer chat/orb interaction area
- semantic/selection overlays and controls
- The UI is designed to reflect the same asset state the backend uses, especially for selection, highlight, and semantic group visibility.
4. Client-side state management
- The app uses Svelte stores for cross-component state:
- request gating
- chat request status
- vehicle node selection
- vehicle patches
- semantic runtime state
- inspector sidebar and supplementary footer state
- These stores form the client-side coordination layer between the viewport, sidebar, footer, and async API results.
5. Asset-scoped semantic model
- The repository is built around a per-asset semantic boundary: all intent, selection, overlays, and edits are scoped to the current vehicle asset.
- The code and README emphasize that the semantic overlay is the source of truth for IDs, paths, meshes, and validation.
- When overlay data is absent or stale, the system can fall back to GLTF-derived structure/summary data, but the overlay remains authoritative when present.
6. Semantic ingestion and overlay pipeline
- The semantic stack is split into server connectors for:
- semantic ingress: receiving/organizing semantic data
- semantic assignments: binding semantic labels to asset structures
- semantic proposals: producing candidate semantic mappings
- semantic overlay: storing and serving the accepted overlay
- There is also support for GLTF preprocessing and structure extraction, which feeds the semantic system when a richer overlay is unavailable.
- This is the architecture’s main “asset understanding” pipeline.
7. Chat and intent execution pipeline
- The chat system is not just freeform messaging; it routes through an intent/execution engine.
- Server-side connectors under openai-chat and vehicle-intents handle:
- prompt construction
- model routing
- intent resolution
- tool definitions and arguments
- patch generation
- execution policy
- normalized output for the UI
- The important boundary here is that user text/voice becomes deterministic vehicle actions rather than ad hoc conversation.
8. Voice orb and audio paths
- The footer orb supports two audio flows:
- buffered audio: record → transcribe → execute the same vehicle chat/tool loop → synthesize a spoken reply
- full-duplex realtime voice: live session over WebRTC when supported
- The realtime path falls back to buffered audio if session setup fails.
- This means the voice subsystem is an alternate front end to the same backend execution pipeline, not a separate feature.
9. External services and persistence
- The main external integrations are:
- GitHub auth / auth secret infrastructure for the gated app shell
- OpenAI for chat, tool planning, transcription, TTS, and realtime voice
- DynamoDB for user/context history in production, with DynamoDB Local for local/demo use
- Semantic overlays are persisted separately in local storage paths by default, with a configurable local manifest directory.
10. Context history layering
- Footer chat context is assembled from multiple tiers:
- current request context
- current asset snapshot
- current asset recent history
- user-global summary
- That ordering is important to the architecture: it ensures the model sees the current asset and current selection first, while still allowing longer-term memory beneath it.
11. Server route shape
- The API surface is asset-centric:
- chat and audio endpoints
- vehicle asset download/highlight/inspection/intent/paint
- semantic ingress and overlay endpoints
- window tint and other asset modifications
- These routes are the bridge between the browser viewer and the server-side connectors that compute overlay changes, patches, and intent results.
12. Determinism and side-effect control
- The repo’s design strongly prefers deterministic, asset-local execution:
- semantic groups drive matching
- highlights and selections are mirrored between UI and model context
- whole-asset effects like x-ray/UV/wireframe are treated as deterministic view modes
- This is a key architectural boundary: model outputs are constrained by the asset’s semantic graph and current UI state, rather than by global or cross-asset context.
13. What to draw in an architecture diagram
- A useful diagram should show:
- browser UI shell and Threlte viewport
- Svelte stores as client state coordinator
- authenticated SvelteKit server routes
- connector layer for OpenAI, semantic overlay, vehicle intent, and context history
- persistence for overlays and history
- asset-specific semantic data flowing back into selection/highlight/patch UI
- The central path is: user action → client state/UI → API route → connector/model/storage → normalized result → viewer/store update.
Main entry points: semantic-runtime.ts Stores · +page.svelte Inspect asset · index.ts Overlay store · +server.ts Asset API
Components 22
Client app
SvelteKit browser shell, viewer, sidebar, footer, and shared client state.
- Viewport · 3D inspection surface and selection/highlight rendering.
src/lib/components/threlte/inspection-viewport.svelte - Inspector · Controls for selection, camera, lighting, and semantic ingress state.
src/lib/components/inspector/inspector-sidebar.svelte - Footer orb · Chat and voice interaction surface in the footer.
src/lib/components/ui/footer-orb.svelte - Request gate · Coordinates request availability and interaction gating.
src/lib/components/ui/request-gate.svelte - Stores · Shared client state for chat, selection, patches, semantic runtime, and sidebar/footer coordination.
src/lib/stores/semantic-runtime.ts - Selection runtime · Mirrors selected vehicle nodes and highlight state into the viewport.
src/lib/components/threlte/runtime-selection.ts - Semantic runtime · Client-side semantic overlay and visibility coordination.
src/lib/stores/semantic-runtime.ts
Routes
Public app routes and authenticated inspection entry points.
- Sign in · Public entry point for GitHub-gated access.
src/routes/(public)/signin/+page.svelte - App shell · Authenticated SvelteKit shell for the app area.
src/routes/(app)/app/+layout.svelte - Inspect asset · Asset-scoped inspection route for one selected vehicle at a time.
src/routes/(app)/app/inspect/[assetId]/+page.svelte
Server connectors
API handlers and backend orchestration for chat, semantic operations, and vehicle actions.
- Chat API · Main text chat endpoint that turns user intent into normalized actions.
src/routes/api/chat/+server.ts - Audio API · Buffered and realtime voice endpoints for the same execution loop.
src/routes/api/chat/audio/realtime/+server.ts - Asset API · Asset-centric endpoints for inspection, intent, highlight, paint, tint, and semantic operations.
src/routes/api/vehicle-assets/+server.ts - OpenAI chat · Prompting, routing, tool definitions, execution policy, and normalized model output.
src/lib/server/connectors/openai-chat/index.ts - Vehicle intents · Resolves chat output into deterministic vehicle actions and patch ops.
src/lib/server/connectors/vehicle-intents/index.ts - Semantic ingress · Receives and organizes semantic data for an asset.
src/lib/server/connectors/semantic-ingress/index.ts - Overlay store · Serves the authoritative per-asset overlay when present.
src/lib/server/connectors/vehicle-semantic-overlay/index.ts - GLTF pipeline · Preprocesses models and derives structure when richer overlays are unavailable.
src/lib/server/connectors/gltf-structure/index.ts - Context history · Builds current-request, asset, recent-history, and global-summary context.
src/lib/server/connectors/context-history/index.ts - Vehicle registry · Lookup and storage layer for vehicle asset metadata.
src/lib/server/connectors/vehicle-registry/index.ts - Auth identity · GitHub-backed identity gate for the authenticated shell.
src/lib/server/auth/identity.ts
Persistence
History and overlay storage used by server-side connectors.
- Data stores · DynamoDB history and local overlay storage used by server connectors.
Connections 26
- Sign in → Auth identity: sign in · Public access flows into the auth boundary.
- Auth identity → App shell: gate · Authenticated users reach the app shell.
- App shell → Inspect asset: route · Shell loads the asset-scoped inspection page.
- Inspect asset → Viewport: render · Page renders the Threlte inspection surface.
- Inspect asset → Inspector: render · Page renders the inspector controls.
- Inspect asset → Footer orb: render · Page renders chat and voice interaction.
- Footer orb → Request gate: gate · Voice/chat interactions are gated by request state.
- Viewport → Selection runtime: sync · Selection and highlight state are mirrored into the scene.
- Inspector → Stores: update · Inspector controls update shared client state.
- Footer orb → Stores: update · Chat and voice interactions update shared client state.
- Selection runtime → Semantic runtime: mirror · Viewer selection is reflected in semantic runtime state.
- Stores → Chat API: submit · Chat requests flow from client state to the server.
- Stores → Audio API: voice · Buffered or realtime voice requests flow to audio endpoints.
- Stores → Asset API: asset ops · Selection, highlight, paint, tint, and semantic operations go to asset routes.
- Chat API → OpenAI chat: plan · Chat route delegates to intent planning and model routing.
- Audio API → OpenAI chat: transcribe/tts · Audio routes reuse the same model-backed chat pipeline.
- Asset API → Vehicle intents: execute · Asset actions are normalized into deterministic vehicle intents.
- Asset API → Semantic ingress: ingest · Semantic ingress endpoints feed the semantic pipeline.
- Vehicle intents → Overlay store: patch · Intent execution produces overlay and asset-local patch results.
- Semantic ingress → GLTF pipeline: fallback · Structure extraction supports semantic ingestion when overlays are incomplete.
- Overlay store → Viewport: drive ui · Overlay data determines what the viewer can select and show.
- Overlay store → Semantic runtime: source · Overlay state is the source of truth for semantic visibility and IDs.
- OpenAI chat → Context history: context · Prompt assembly uses layered asset and user history.
- Context history → Data stores: read/write · History is backed by DynamoDB or local storage.
- Overlay store → Data stores: persist · Accepted overlays are stored separately from chat history.
- Vehicle registry → Asset API: lookup · Asset routes resolve the current vehicle and its metadata.