Open ryjen opened 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:
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.
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.
Use the "streams" edge function example to stream changes given request params:
Would probably require a change detection algo.
RQLite container with postlite
and edge function?
Using CRDTs:
https://supabase.com/blog/postgres-crdt
https://github.com/vlcn-io/cr-sqlite
https://github.com/CharlieTap/synk
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
Some new players on the scene for offline storage:
Use electric-sql which uses a standard "satalite protocol" over websockets.
Would require some work setting up a client in kotlin
Use PowerSync which uses the WAL (write-ahead-log) of postgres.
Would require creating a Kotlin client SDK.
Use Store which is a native kotlin wrapper around network fetching, bookeeping, and updating. Looks pretty good.
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: