More of the Software You Build May Need to Work Without the Server
A field engineer opens your app in a basement plant room with no signal. The screen shows a spinner, then an error. The job sheet they need was on their phone ten minutes ago, but the app only knows how to ask the server
A field engineer opens your app in a basement plant room with no signal. The screen shows a spinner, then an error. The job sheet they need was on their phone ten minutes ago, but the app only knows how to ask the server, and the server is out of reach.
For years, most apps have been built this way. The real data lives on the server, and the device shows a copy for as long as the connection holds. It is simple to reason about, and it works well enough in an office.
A different idea has been gaining ground. In 2019, researchers at the lab Ink and Switch, including Martin Kleppmann, published an essay called Local-first software: you own your data, in spite of the cloud. They argued that the main copy of a user's data should live on the user's own device. The app should work fully offline, and the cloud should be used to sync and back up between devices and collaborators, not as the only place the data can be.
The hard part is what happens when two people edit the same thing while disconnected. The essay explored a family of data structures called CRDTs, short for conflict-free replicated data types, which are designed so that changes made separately can always be merged into the same result. Open source libraries such as Automerge and Yjs now make this practical for things like shared documents, lists and notes.
Not every app should be built this way. Bank balances and stock levels need one place that decides. But many tools people use every day, notes, task lists, design files, forms filled in on site, could work much better if they never needed to ask permission from a server before saving.
For developers, this changes some familiar questions. Where is the source of truth? What does a conflict look like, and who sees it? How do you change the shape of data that already lives on thousands of devices? How do you delete something everywhere?
You do not need to rebuild anything today. But the next time you design a feature, ask what happens with no connection at all. If the honest answer is a spinner, it may be worth thinking about whether the data could live a little closer to the person using it.
– Asael Shinder
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.