> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powersync.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write Path Overview

> The architecture of PowerSync writes, and what you need to implement or configure.

PowerSync syncs data from your source database to your app's local SQLite database. Your app writes to this local database, and the client SDK records changes to synced tables in an ordered **upload queue**.

Your backend applies the queued changes to your source database, so your business logic, such as validation and authorization, can run before a change is stored.

![Diagram of the PowerSync architecture. The source database replicates to the PowerSync Service, which syncs to the SDK in the client app. Two dashed boxes marked with question marks, uploadData() and a write endpoint, carry writes from the SDK back to the source database. An auth provider issues the JWTs.](https://mintcdn.com/powersync/O2UFKk2N_bhUL-Fp/images/handling-writes/write-path-overview.png?fit=max\&auto=format\&n=O2UFKk2N_bhUL-Fp\&q=85\&s=3b7be6c2ff2dc4969dd5b8ddefc3e48e)

PowerSync handles the read path. The dashed lines show the write path through your backend connector and write endpoint.

The two orange boxes with dashed borders are the parts you integrate: an `uploadData()` function in your app's backend connector and a **write endpoint** in your application backend.

You can use an existing API, Supabase's PostgREST API, or the reference write implementation. Your write endpoint is responsible for [authenticating and authorizing writes](https://docs.powersync.com/handling-writes/write-path/concepts.md#authenticating-writes).

## How a Write Reaches Your Source Database

You implement steps 3 and 4. The client SDK and the PowerSync Service handle the other steps.

1. When your app writes to a synced table in the client-side SQLite database, the client SDK also adds the write to the [upload queue](https://docs.powersync.com/architecture/client-architecture.md#writing-data-via-sqlite-database-and-upload-queue).
2. The client SDK calls the `uploadData()` function in your [backend connector](https://docs.powersync.com/configuration/app-backend/client-side-integration.md#backend-connector) to upload the queued writes. You never call `uploadData()` directly. See [When `uploadData()` is Called](https://docs.powersync.com/configuration/app-backend/client-side-integration#when-uploaddata-is-called).
3. Your `uploadData()` function sends the queued writes to your write endpoint. After a successful response, your function calls `complete()` on the transaction or batch it sent, which removes those writes from the upload queue. If the request fails with an error that a retry can fix, such as a network error, your function throws instead. The writes stay in the queue, and later writes wait behind them until a retry succeeds.
4. Your write endpoint applies the writes to your source database before it responds. Otherwise, the change can disappear from the device until the write reaches the source database and syncs. See [Applying Writes Before Responding](https://docs.powersync.com/handling-writes/write-path/concepts.md#applying-writes-before-responding).
5. The PowerSync Service replicates the changes from your source database and syncs them to every client whose [Sync Streams](https://docs.powersync.com/sync/streams/overview.md) include the changed rows.

Your app sees its own change immediately after step 1, because it reads from the local database. Other users' apps see it after step 5. If your write endpoint rejects or changes the write, the synced result replaces the local change. While the device is offline, steps 2 to 5 wait until it reconnects.

## Choose Where to Start

To pick a setup for your backend, see [Choosing Your Setup](https://docs.powersync.com/handling-writes/write-path/choosing-your-setup.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.