Solidground: Musings on Local-first Development

Yesterday night I got a bit nerd-sniped while watching Johannes Schickling (@schihckling@mas.to) WorkerConf 2022 presentation “A new era of Web Development” (the link of which was dropped in wasmCloud slack).

Johannes is building “Overtone”, a local-first app that takes input from a range of music services and presents them in a local, very crisp and snappy UI, built with Tauri.

Rationale of Local-first

The whole video is worth a watch. Johannes starts by listing 4 qualities of great software:

  • Correct
  • Easy to use
  • Well designed
  • Portable

But then he adds what he finds missing in most software:

  • Responsive / Fast
  • Always Available
  • Longevity
  • Privacy
  • User Agency
  • Collaborative

And in a more recent presentation he adds developer benefits:

  • Simpler architecture (he uses event sourcing too)
  • Distributed systems problem is contained (ditch cloud complexity)
  • Easier to develop, test and debug
  • Great DX

To given an example he compares his app with Spotify on local-first qualities:

Architecture and techstack

In the architecture diagram we recognize Ports & Adapters and CQRS/ES:

And the techstack has a range of front-end technology frameworks to handle the local-first UI:

In this list Riffle is a reactive sql layer on top of SQLite that Johannes is working on (not available as yet, but comparable to VLCN and ElectricSQL). It aims to be Persistent, Reactive, Transactional, Fast and have Synchronous Queries.

The concepts of Riffle are elaborated in the article:

https://riffle.systems/essays/prelude/

Also note this page on local-first technology projects:

(HN discussion)

SQLite local-first libraries

SQLSync

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.

Features

  • Eventually consistent SQLite
  • Optimistic reads and writes
  • Real-time collaboration
  • Offline-first
  • Cross-tab sync
  • React library

The library is built in Rust and uses WebAssembly. The maintainer is member of wasmCloud slack as Carl Sverre.

cr-sqlite

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite.

A run-time loadable extension for SQLite and libSQL. It allows merging different SQLite databases together that have taken independent writes.

In other words, you can write to your SQLite database while offline. I can write to mine while offline. We can then both come online and merge our databases together, without conflict.