cachapa / crdt_sync

A dart-native turnkey solution for painless network synchronization
https://pub.dev/packages/crdt_sync
Apache License 2.0
19 stars 1 forks source link

Supabase Support? #1

Open jtkeyva opened 1 year ago

jtkeyva commented 1 year ago

Still wrapping my head around CRDT...

Any plans to support Supabase (uses postgres) Sync?

cachapa commented 1 year ago

I'm not familiar enough with Supabase to answer definitively but the Postgres database requires CRDT extensions on both sides which are currently implemented as a Dart wrapper in postgres_crdt.

The issue is that making changes to the underlying database without the wrapper breaks the CRDT by failing to update the timestamps properly, or by deleting records instead of marking them as deleted.

There's also the issue of the communication protocol which crdt_sync uses to synchronize its nodes and how it would integrate into Supabase. I don't know enough about the Supabase side to comment on that though.

jtkeyva commented 1 year ago

ah thank you. so i found this: https://supabase.com/blog/postgres-crdt and https://github.com/supabase/pg_crdt

It's still experimental so I cannot rely on it for now. CRDT seems to be the way forward though.

cachapa commented 1 year ago

Extending Postgres as they are doing is the more correct approach since it removes the problem of direct access to the database using CRDT-unaware tooling.

This is actually in my long-term plans, but unlike Supabase I'm not swimming in VC capital so that might take some time :-)

jtkeyva commented 1 year ago

@cachapa ha. it might be worth reaching out. i know a couple of them and they are good people. maybe you can provide the offline/sync solution us supabase users want/need. they are supposed to be the firebase alternative and this is a huge hole and opportunity. maybe you're the guy they want/need!?

jtkeyva commented 1 year ago

@cachapa I posted here, maybe jump in on that convo? https://github.com/orgs/supabase/discussions/17496#discussioncomment-7059237

cachapa commented 1 year ago

Thanks for the heads up. I commented on the ticket.

jtkeyva commented 2 days ago

any updates on this? thx

cachapa commented 2 days ago

There was no reaction from the Supabase repository.

I'm currently not able to work on this, but am happy to support anyone who wants to take the challenge on.

I'm not familiar enough with Supabase to say for sure, but I suspect that it should be possible to implement a connector by simply extending sql_crdt.

I would begin with cloning postgres_crdt as a starting point.

jtkeyva commented 19 hours ago

Hi what you mean no reaction from the Supabase repository? Like as in it seems no one is interested?

I was playing around and added an Operations table and so each change is recorded there and streamed by the clients. Seems kinda too good to be true and a bit hacky but a todo list was kinda working.

I will dabble around with postgres_crdt.

cachapa commented 18 hours ago

Hi what you mean no reaction from the Supabase repository? Like as in it seems no one is interested?

I meant there was no further discussion. I can imagine there's interest but the reality is that I have very limited time to take this on myself regardless.

I was playing around and added an Operations table and so each change is recorded there and streamed by the clients. Seems kinda too good to be true and a bit hacky but a todo list was kinda working.

In principle all you need is to implement this interface: https://github.com/cachapa/sql_crdt/blob/master/lib/src/database_api.dart

You can then copy the tests from postgres_crdt and adapt them to instantiate your code instead.

jtkeyva commented 16 hours ago

understood thanks for the info. i will have a crack at it this weekend.