Stop being the product.
Become the owner.
or
sign uplog in

How we sync Postgres to the browser: ElectricSQL for rows…

How we sync Postgres to the browser: ElectricSQL for rows, Yjs for documents

Author here (I'm building Plain, a GitHub alternative), so flagging the affiliation up front.

The writeup is about treating sync as the substrate instead of adding realtime to features one at a time. Two engines, because there are two kinds of state:

\- Rows (issues, PRs, CI, messages) stream out of Postgres via ElectricSQL as "shapes" over HTTP. The browser holds a live query. Electric is read-path only, so writes go through server functions and reconcile optimistically via a Postgres transaction id

(pg\_current\_xact\_id()) that Electric stamps on the row when it streams back.

\- Document bodies are CRDTs over Yjs/Hocuspocus, since people type into the same paragraph at once. Presence/typing is just Yjs awareness, so no heartbeat table.

I'm honest about the costs in the post too: two stateful services, Postgres on logical replication, and the auth proxy in front of Electric as the obvious choke point. Curious how others have handled the rows-vs-documents split, and where people expect this to strain at scale.
#technology #js #programming #dev
earnings
1,000 mlx total
$0  total
engagement
2 views
0 reactions

0 comments