ElectricSQL implements active-active, conflict-free replication between SQLite and Postgres, via AntidoteDB. Replication from SQLite, within a local app, is handled transparently, in the background as a side effect of electrifying your database driver.
As a result, as a developer, you don’t need to do anything special to enable or control replication. It just happens in the background. However, there are a number of things that it’s useful to be aware of and to potentially configure and control.
As described in the configuration guide, you can configure the
url that the local app connects to when establishing replication.
Replication from SQLite sends changesets, encoded using protocol buffers, over a web socket connection. You can see the protocol buffers specification here and the backend implementation here.
The core replication layer uses AntidoteDB. This provides transactional causal+ consistency with CRDTs. Rows are stored as an antidote_crdt_map_rr (a CRDT map that supports deletes using a reset mechanism). Replicated updates always contain the whole row.
Within the local devices, we use additional merge logic to arbitrate conflicts so that last write wins. Compensations are applied using add-wins semantics.
See the reference pages on consistency, integrity and anomalies.