Brian Hung
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/collabwebhookusersdoc_stateNext.js appApollo Client, ProseMirrornginxroutes by pathauth-serviceGo: sign up, sign inHasuraGraphQL over Postgrescollab-serviceNode, live Yjs docsredis-authrevoked tokensPostgres 13users, posts, lists, likesredis-collablive doc updatesThe six services run from one docker-compose.yml; nginx on the host routes to them.
Saving a live edit
local copyYjs update, WebSocketeach updatebroadcastbindState: load when openedwriteState: last editor leavesProseMirror editorySyncPlugin makes Yjs updatesIndexedDBy-indexeddbWSSharedDoccollab-service, one per postredis-collaby-redisOther editorssame postPostgres postsdoc_state and contentOnly the post's owner can join its room, so the other editors are the owner's other tabs and devices.