hackelia-micrantha / eyespie

a game of "eye spy" with machine vision for clues and proof
1 stars 0 forks source link

Offline First #13

Open ryjen opened 1 year ago

ryjen commented 1 year ago

The application being a mobile device should still function offline.

User Story 1:

As a user, I want to go to remote locations to skout things and still have the application work without or with intermittent connectivity.

User Story 2:

As a user, I want to save money on data, and use the application without cellular service.

Tasks:

ryjen commented 1 year ago

Offline would require a data sync at some point. All of the recomended solutions by supabase are in javascript, but they are working on their own using the db WAL.

In the meantime:

Data

What data does the app actually require right off the bat?

A list of all things would be the mimum to allow location updates and functionality.

Idea 1)

Use an edge function to export an encrypted compressed sqlite database for mobile clients.

(possibly with foreign data wrappers).

Then use realtime updates to keep in sync once installed on the client.

Would also allow clients to generate their own crypto key for the database.

Idea 2)

Use the "streams" edge function example to stream changes given request params:

Would probably require a change detection algo.

Idea 2)

RQLite container with postlite and edge function?

Idea 3)

Using CRDTs:
https://supabase.com/blog/postgres-crdt

https://github.com/vlcn-io/cr-sqlite

https://github.com/CharlieTap/synk

Idea 4)

SqlDelight direct access to Postgres instance, cache to Sqlite.


Conclusion:

Am thinking MVP a simple sync with direct remote DB access to rewrite the local db.

Can combine with generating a new database if none exists yet

And optimizing with CRDTs / Synk

ryjen commented 1 year ago

Some new players on the scene for offline storage:

Idea 5)

Use electric-sql which uses a standard "satalite protocol" over websockets.

Would require some work setting up a client in kotlin

Idea 6)

Use PowerSync which uses the WAL (write-ahead-log) of postgres.

Would require creating a Kotlin client SDK.

Idea 7)

Use Store which is a native kotlin wrapper around network fetching, bookeeping, and updating. Looks pretty good.