How lethalchip/spacechatdb works
SpaceChatDb is a browser-based chat and voice/video calling app backed by SpacetimeDB. The apparent workflow is to connect, exchange chat or call actions, and stream media during calls; the sampled connection code also routes incoming media events to call runtime handlers. The README is only a Svelte starter template and does not document product capabilities. The page and several runtime sections were not excerpted, so UI-to-state wiring and parts of the connection/subscription flow are not asserted.
Main entry points: index.ts Typed module API · stdb.ts App connection state · callRuntime.ts Call runtime · +page.svelte Chat UI
Components 19
Client state and runtime
- Chat UI
src/routes/+page.svelte - App connection state
src/lib/stdb.ts
SpacetimeDB bindings
- Typed module API
src/module_bindings/index.ts - Call reducers
src/module_bindings - Chat reducers
src/module_bindings/send_message_reducer.ts - Audio frame reducer
src/module_bindings/send_audio_frame_reducer.ts - Video frame reducer
src/module_bindings/send_video_frame_reducer.ts - Call sessions
src/module_bindings/call_session_table.ts - Chat messages
src/module_bindings/chat_message_table.ts - Users
src/module_bindings/user_table.ts - Media settings table
src/module_bindings/media_settings_table.ts - Audio frame events
src/module_bindings/audio_frame_event_table.ts - Video frame events
src/module_bindings/video_frame_event_table.ts
Calling and media
- Media settings
src/lib/mediaSettings.ts - Call runtime
src/lib/callRuntime.ts - PCM capture worklet
src/lib/pcm-capture-worklet.ts
Other components
- User
- SpacetimeDB
- Browser media APIs
Connections 19
- User → Chat UI: uses
- Chat UI → App connection state: invokes
- App connection state → Typed module API: connects through
src/lib/stdb.ts - Typed module API → SpacetimeDB: connects to
src/module_bindings/index.ts - Typed module API → Call reducers: registers schemas
src/module_bindings/index.ts - Typed module API → Chat reducers: registers schema
src/module_bindings/index.ts - Typed module API → Audio frame reducer: registers schema
src/module_bindings/index.ts - Typed module API → Video frame reducer: registers schema
src/module_bindings/index.ts - Typed module API → Call sessions: registers schema
src/module_bindings/index.ts - Typed module API → Chat messages: registers schema
src/module_bindings/index.ts - Typed module API → Users: registers schema
src/module_bindings/index.ts - Typed module API → Media settings table: registers schema
src/module_bindings/index.ts - Typed module API → Audio frame events: registers schema
src/module_bindings/index.ts - Typed module API → Video frame events: registers schema
src/module_bindings/index.ts - App connection state → Call runtime: dispatches media events
src/lib/stdb.ts - App connection state → Media settings: updates settings
src/lib/stdb.ts - Call runtime → Media settings: reads configuration
src/lib/callRuntime.ts - Call runtime → Browser media APIs: captures and plays
src/lib/callRuntime.ts - Call runtime → PCM capture worklet: loads worklet
src/lib/callRuntime.ts