headbase-app / headbase

The customizable database for your brain. Note-taking, task-management, personal knowledge bases and more.
GNU Affero General Public License v3.0
2 stars 0 forks source link

Move to a local first approach #1

Closed ben-ryder closed 1 year ago

ben-ryder commented 2 years ago

Problem

Right now this application is "server first", meaning that the server holds the single source of truth and data is updated via HTTP requests. This works fine, but will not be ideal for offline support going forwards. If I wanted to support offline usage I would probably have to implement some sort of rudimentary sync system which would store a log of changes locally, then calculate the difference when online and push these changes. This would have a number of problems including conflict issues if multiple clients make offline changes then attempt to push these changes later.

There's also the general question of data ownership too, especially for a notes app where offline use and owning your data is of paticualr importance.

Solution

I should look at changing this application around, so it works primarily as as a local first, offline first web app (using service worker etc?) which saves and reads data to a local store (such as IndexDB, in-browser sqlite etc?). Data could then be synced via a CRDT system such as automerge with changes being communicated via a technology like websockets rather than a REST API. I could then still use a server as always online data sync client/backup and a central way to communicate between different clients.

Links to more info:

Implementation Ideas

ben-ryder commented 2 years ago

Initial Local First App v0.1:

Local First v1.0