Brian Hung
Projects
Threads
A social notes app: write in a rich-text editor, collect posts into lists, and follow other people.
How the services fit together
HTTPS, WebSocket
/auth
/hasura
/collab
webhook
users
doc_state
Next.js app
Apollo Client, ProseMirror
nginx
routes by path
auth-service
Go: sign up, sign in
Hasura
GraphQL over Postgres
collab-service
Node, live Yjs docs
redis-auth
revoked tokens
Postgres 13
users, posts, lists, likes
redis-collab
live doc updates
The six services run from one docker-compose.yml; nginx on the host routes to them.
Saving a live edit
local copy
Yjs update, WebSocket
each update
broadcast
bindState: load when opened
writeState: last editor leaves
ProseMirror editor
ySyncPlugin makes Yjs updates
IndexedDB
y-indexeddb
WSSharedDoc
collab-service, one per post
redis-collab
y-redis
Other editors
same post
Postgres posts
doc_state and content
Only the post's owner can join its room, so the other editors are the owner's other tabs and devices.