Skip to main content

Real-time

Race Platform's real-time pipeline keeps every connected client synchronised when a teammate edits a run sheet, drags a board card, or saves a plan change.

The components

ComponentRole
Realtime service (apps/realtime/)WebSocket fan-out. Locally on ws + Node (port 6162), production on Cloudflare Durable Objects.
One room per sessionEach Durable Object instance corresponds to a sessionId.
API → Realtime broadcastAfter a successful write, the API POSTs the event to the matching room.
Automerge CRDTConflict-free merging of concurrent edits on the same document.
Client subscriptionThe Flutter client opens a WebSocket per active session and applies events to local state.

What you can do today

  • The realtime service is up and tested10/10 tests pass in apps/realtime/.
  • Clients can subscribe to a session room.
  • The API broadcast wire-up exists but client-side subscription isn't wired into Flutter yet — today the client refreshes by polling.

What's coming

This is one of the largest unfinished work items:

  • Wire the WebSocket subscription into the Flutter client and apply lap.updated, runSheet.updated, boardCard.moved events to local Riverpod state
  • Automerge wire-up — replace REST-PATCH editing of run sheets, the board, and run plans with CRDT operations
  • Drag-and-drop on the board with optimistic update + server-pushed reconciliation
  • Latency budget: target ≤ 500 ms for an edit on machine A to appear on machine B over LAN; ≤ 1 s over WAN
  • Reconnection / replay when the WebSocket drops
  • Presence indicator — show which other engineers are viewing the same run sheet

Acceptance test progress

From .context/progress.md:

  • Realtime service spins up and accepts connections
  • Editing a lap on desktop appears in web within 500 ms
  • Drag a card on web; desktop reflects within 100 ms
  • Edge ingester feeds → run sheets auto-populate within 1 s

The boxes above are the live-race MVP acceptance test for real-time.