README.md18 lines · main
1# @briven/realtime — reactive query WebSocket service
2
3per `CLAUDE.md §7.4`:
4
51. client calls `useQuery("getPosts", { userId })`
62. SDK sends query name + args to realtime over WebSocket
73. realtime computes a query hash, checks cache
84. on miss: invokes query via runtime, caches, returns
95. realtime subscribes to Postgres `LISTEN` channels for every table touched
106. on `NOTIFY` (auto-generated triggers), recompute and push deltas to subscribed clients
117. subscriptions expire when client disconnects
12
13**status: Phase 1 complete (2026-05-09).** wire protocol, refcounted LISTEN/UNLISTEN,
14NOTIFY → re-invoke fan-out, channel diffing on `touchedTables`, postgres.js
15v3 auto-reattach on reconnect. Caller auth is the runtime shared secret;
16SDK-direct connection (per-project JWT) is a Phase 2 follow-up.
17
18year-one scale target: 10,000 concurrent subscriptions. migrate to logical replication + WAL streaming if this becomes a bottleneck.
Preview

@briven/realtime — reactive query WebSocket service

per CLAUDE.md §7.4:

  1. client calls useQuery("getPosts", { userId })
  2. SDK sends query name + args to realtime over WebSocket
  3. realtime computes a query hash, checks cache
  4. on miss: invokes query via runtime, caches, returns
  5. realtime subscribes to Postgres LISTEN channels for every table touched
  6. on NOTIFY (auto-generated triggers), recompute and push deltas to subscribed clients
  7. subscriptions expire when client disconnects

status: Phase 1 complete (2026-05-09). wire protocol, refcounted LISTEN/UNLISTEN, NOTIFY → re-invoke fan-out, channel diffing on touchedTables, postgres.js v3 auto-reattach on reconnect. Caller auth is the runtime shared secret; SDK-direct connection (per-project JWT) is a Phase 2 follow-up.

year-one scale target: 10,000 concurrent subscriptions. migrate to logical replication + WAL streaming if this becomes a bottleneck.