Serverless Multi-Device Apps

If we can synchronize files, we can also synchronize databases
Our last article about simplifying the architecture for self-hostable webapps using PostgREST seems to have struck a chord. Users do want control on their own data, but they also want the convenience of moving easily from one device to another, as well as not have the burden of maintaining a server.
"People don’t want to run their own servers, and never will." - @moxie
There's a lot of truth in this. Servers are notoriously brittle. Part of it has to do with that they are exposed to public Internet and therefore vulnerable to attacks, which increases the security and maintainability burden. At the same time, databases like PostgreSQL do still require a good amount of administrative know-how, even if the goal is to use it for personal apps.
Is there a way users can run an app and access their data across all their devices WITHOUT having to run or trust a central database server? Can it be made robust enough to survive intermittent outages (say, people moving to a new house or a city)?
We believe there's an architecture pattern that can achieve this.
  • Build local apps that read and store their data in a local sqlite database (which is just a file)
  • Run any of the popular file synchronization services like Google Drive, Dropbox, iCloud, or Syncthing (did you know Syncthing has an Android app?) on all your devices. This is leveraging the fact that user is typically only using one device at a time, so concurrent writes is not that big of a worry.
  • If a user has only one device, they can still get the benefits by encrypting the database file and sharing storage with their friends, thereby achieving redundancy without compromising on privacy.
These kind of apps can be built with any programming language stack that allows local file-access. So, Swift, .NET, Flutter, Java, C, C++, Golang, Rust, Electron - all should work, except perhaps PWAs.
Let's actually try to do this. We have had a "dashboard for your personal life" page over at LearnAwesome but because it is a single HTML page, it can only stores user's data in browser's localStorage. This has a big drawback that user cannot see their data on another device. We did not want to turn this into a server-based app, because a "dashboard for personal life" can have very private and intimate data, and it's best that it remains completely in user's own control.
This makes it a good use-case for the above architecture pattern. Here is our plan of action:
  • Investigate which desktop app framework supports both webview (so that our existing code works with minimal changes) AND filesystem-access (so that data can be stored in a local .sqlite file).