Note: PowerSync is currently in Developer Preview. It is not suitable for use in production environments yet.
PowerSync is a cloud service and Flutter SDK that keeps PostgreSQL databases in sync with on-device databases.
The cloud service and mobile SDK operate in unison to keep client-side databases in sync with a server-side PostgreSQL database. From the client-side perspective, there are two data flow paths: reading data from the server or downloading data, and writing changes back to the server, or uploading data.
App clients always read data from a local database. The local database is asynchronously hydrated from the PowerSync cloud service. The PowerSync cloud service connects directly to PostgreSQL databases and uses the Write-Ahead-Log (WAL) to first calculate dynamic and contextual data partitions, called sync buckets. Sync buckets are used to partition data because in most cases, only a subset of data is required in a client's database and not an entire copy of all data. The sync buckets are then served to client applications over a REST API.
Client-side data modifications, namely updates, deletes and inserts, are stored in an upload queue. The upload queue is a blocking FIFO queue that gets processed when network connectivity is available. Each entry in the queue is processed by writing the entry to your custom backend application API. This is to ensure that your existing backend business logic is re-used when uploading data changes. For more information, see the section on integrating with your backend.
The PowerSync cloud service uses Database Native credentials and authenticates directly against a PostgreSQL database using the configured credentials.
The PowerSync mobile SDK uses JWTs and authenticates directly against both the PowerSync cloud service when reading data, and against your existing backend API when writing data.
Once configured, a typical PowerSync system looks as follows:
Typical System Architecture
Comments for various subsystems are included in the below diagram:
Architecture With Comments