CarnetApp / CarnetDocumentation

GNU General Public License v3.0
257 stars 11 forks source link

[Feature Request] Please consider using a CRDT for syncing #134

Open MayeulC opened 1 year ago

MayeulC commented 1 year ago

Conflict-Free Replicated Datatypes are a data type that can be synced at any point during the lifetime of the data, without causing conflicts. It is well-suited to collaborative editing where editing can be performed offline, or online, asynchronously or concurently, and merges can be performed without conflicts¹ or data loss at any point.

Have a look at https://www.inkandswitch.com/local-first/ for an intro on "local-first" software.

It's quite easy to find documentation on the subject. Here's one about Operational Transform vs CRDT: https://josephg.com/blog/crdts-are-the-future/

A widely-used library is y.js: https://github.com/yjs/yjs (link to docs), it has also been ported to other languages, like Rust and WASM, but I think js should be enough for Carnet?


I am proposing this since it's annoying to wait for Carnet to sync on start-up while it could be done later; it's a bit dangerous to edit notes offline in case of a conflict, and I lost a note content recently when trying to edit it before sync was done. I am not alone apparently: https://github.com/CarnetApp/CarnetFdroid/issues/12

This would make collaborative editing possible (https://github.com/CarnetApp/CarnetAndroid/issues/143), and offline editing easier, as well as reducing reliance on syncing (faster start-up and note opening). Multiple back-ends can also be used for syncing.


¹Conflicts still exist, obviously, but CRDTs ensure that they get resolved in the same manner on every client, and both versions prior to the conflict can be retrieved to present more choice to the user, if needs be.