FWIW, I think you might be better off with immutable rows and lamport clocks.
Everything is a full new row because it is “a message” including read receipts. Some messages like read receipts just don’t render in the chat.
Edits can work the same way by rendering over a previous message, even though the local and remote DB have multiple rows for the original and edited messages.
mockingloris · 1h ago
Amazing write-up! I’m thrilled to see your exploration of a reactive SQLite sync engine; it resonates deeply with my own journey toward Local‑First, Offline‑Resilient tools aimed at relieving pressure, not just impressing. Keeping all user data local in SQLite while enabling seamless, encrypted syncing and reactivity. A nice segue in pragmatic autonomy.
It mirrors the moment I embraced tools like Obsidian; designing for real-world constraints; valuing simplicity, privacy, and functionality; especially in low‑connectivity environments.
PS: I was hooked on ...SQLite
Bravo!
mrkeen · 43m ago
> Selecting a sync engine is a lot about knowing the constraints of your application.
Not so sure about this. These seem more like fundamentals than sliding scales.
> How many people will concurrently edit the same resources?
More than 1.
> How write-heavy is it?
Write-heavy enough that you'll encounter an unexpected write between two reads.
> Can you expect unreliable connections or offline usage?
Yes.
CAP with Electron and SQLite is no different from CAP with Tauri and MySQL.
boris · 2h ago
> And because Electric syncs every change granularly, you are certain that the state of your local database is exactly the same as the server's.
I don't see how this certainty follows from "granularity" (whatever that means in this context). I believe to have such a certainty one would need the synchronization to happen within a single transaction that spans both client and server databases.
ethan_smith · 1h ago
Correct - granular syncing alone doesn't guarantee consistency; you'd need either a distributed transaction protocol or a conflict resolution strategy with eventual consistency semantics.
boris · 29m ago
I would say there is no certainty with eventual consistency, only hope.
judge123 · 2h ago
It feels like everyone is solving the sync problem from a slightly different angle. Has anyone here used a few of these in production?
Thanks for sharing this talk. I didn’t know about MobX, but I did use your fork of wa-sqlite (https://github.com/team-reflect/wa-sqlite/) since I also needed the sqlite-vec extension :)
By the way, Reflect is an awesome app; I'm actually a paid subscriber.
Jarwain · 2h ago
I love the timing of how, over the past week or so I've been digging into the ecosystem and options around this, and now here's another article!
gczh · 3h ago
very cool! have you tried Tanstack DB and ElectricSQL?
Not sure about Tanstack DB, but from the second paragraph in the article:
> First Try: PGlite and Electric
oDot · 2h ago
The whole line of Tanstack products is very well made yet poorly designed at the same time. I don't know if it's inherited from React by trying (and succeeding) to be a seamless React experience or if it's part of their own philosophy, but most of the tools make it very easy to mix state everywhere in your app which is just bad.
Really people should just move to Gleam and Lustre or Elm, even if it means I'll have much fewer clients paying good money to untangle state issues...
robinfaraj · 3h ago
very cool stuff!
st-keller · 2h ago
Ok is this about a reactive app with with a local database automatically synced to a remote db? All fully encrypted (at rest and in transit)?
I thought this is what everyone does nowadays!
We built an app like this in 2019 - yes - it was a bit of a challenge with the encryption but the „syncing data“-part is what every litte multiplayer-game has to deal with like forever now. Seems i‘m out of touch with the current state of affairs.
Nice article though!
JSR_FDED · 1h ago
The value is in the author’s experience with other tools that caused problems as his database grew, and in learning from his reasoning about the appropriate solution for his particular problem.
Everything is a full new row because it is “a message” including read receipts. Some messages like read receipts just don’t render in the chat.
Edits can work the same way by rendering over a previous message, even though the local and remote DB have multiple rows for the original and edited messages.
It mirrors the moment I embraced tools like Obsidian; designing for real-world constraints; valuing simplicity, privacy, and functionality; especially in low‑connectivity environments.
PS: I was hooked on ...SQLite
Bravo!
Not so sure about this. These seem more like fundamentals than sliding scales.
> How many people will concurrently edit the same resources?
More than 1.
> How write-heavy is it?
Write-heavy enough that you'll encounter an unexpected write between two reads.
> Can you expect unreliable connections or offline usage?
Yes.
CAP with Electron and SQLite is no different from CAP with Tauri and MySQL.
I don't see how this certainty follows from "granularity" (whatever that means in this context). I believe to have such a certainty one would need the synchronization to happen within a single transaction that spans both client and server databases.
Using the wa-sqlite library, and our own Mobx-based model layer similar to what Linear does.
I gave a short talk about it a few months ago https://www.youtube.com/watch?v=b0GKWzeyZko
https://x.com/marcelohbairros/status/1956892684859158892
> First Try: PGlite and Electric
Really people should just move to Gleam and Lustre or Elm, even if it means I'll have much fewer clients paying good money to untangle state issues...