Collab API
Collab API is a self-hostable WebSocket backend that adds real-time collaborative editing to any app. Documents sync with Yjs CRDTs, so concurrent edits merge without conflicts in any arrival order, and each tenant is isolated at the database layer rather than only in application code.
- CRDT
- merges concurrent edits in any order
- RLS
- a PostgreSQL schema per tenant
- Redis
- pub/sub to scale across instances
What I built
- CRDT sync over the Yjs binary protocol removes last-write-wins conflicts, regardless of the order operations arrive in.
- Schema-per-tenant PostgreSQL with row-level security makes cross-tenant leaks impossible at the database layer, not just in middleware.
- A WebSocket auth lifecycle (onAuthenticate → onLoadDocument → onStoreDocument) carries a scoped userId and tenantId through every step.
- A Redis pub/sub adapter scales horizontally across instances without sticky sessions.
- Structured as a monorepo of packages: the server, a client provider, React hooks, a ProseMirror/Tiptap transformer, and extensions for SQLite, Redis, S3 and webhooks.
Stack
- Node.js
- TypeScript
- Yjs
- WebSockets
- PostgreSQL
- Prisma
- Redis
- JWT
- Docker
