Frontend-YH / whiteboard-app

React Native Whiteboard App
0 stars 0 forks source link

Localfirst paradigm #3

Open ljbergman opened 5 months ago

ljbergman commented 5 months ago

First store everything locally. Later auto synchronize with backend server. Check for updates/changes on server on regular intervals.

Advantages:

  1. No spinners: your work at your fingertips
  2. Your work is not trapped on one device
  3. The network is optional
  4. Seamless collaboration with your colleagues.
  5. The Long Now.
  6. Security and privacy by default-
  7. You retain ultimate ownership and control.
  8. Faster loading speeds.

https://www.youtube.com/watch?si=2pcBZH369G9JBe9p&v=qHSI5rxTp_Q&feature=youtu.be https://www.inkandswitch.com/local-first/

ljbergman commented 5 months ago

Store all custom records locally in SQLite:

• WhiteBoard ID: XyhZkgYz (senare även QR) • Post iD: xxx • Post timestamp: 2024-xx-xx xx:xx xx::xx • Response to: self or other postID • Post Styling/Theme: xxx • Post WhiteBoard Coordinates: x, y • Post Title: Your Post Title • Post Message (rich text box) • Post Image Array (uploaded images)

The posts are then synced together via an online database by reading which posts belong to which board and where on the board they sit.

You can edit your own posts, and reply to other people's posts, but not edit other people's sections on the Whiteboard.

Option to sort the Board by Timestamp or Selected Coordinates.

When you connect to your Whiteboard in the app's background code, it's lightning fast because it downloads everything locally, but in the background a sync check is run against the web-based Database server backend. It works like this:

• If you have updated something, a sync is run against the server at SAVE. The new data is pushed up on the server's DB and the server's public CHANGE variable gets a new timestamp.

• At regular intervals, you check whether new changes have taken place on the server. It then checks if the CHANGE timestamp has changed since the last time and goes through the existing Post-Idn and sees if the Timestamp date is newer: If so, the new Post-data is downloaded. Likewise, new Post posts are downloaded and synced into the local database. It is always the latest copy (the time stamp) that determines which version applies.

• If there is no internet, nothing is synced until you have internet again, the app can be used quickly and easily as usual anyway, but locally and only for yourself. You can still write and add photos to the board.

In other words, STEP 1 is that we build a fully functional Local version of the board. SQLite is probably most suitable as a DB due to good compatibility and flexibility.

STEP 2 will be building the synchronization mechanism of the different local copies. All local copies with the same Whiteboard ID, eg xhGuiOZg, are simply the same Whiteboard, and the sync system then takes that into account.