Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 14 additions & 36 deletions docs/postgresql/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ Under the hood, SQLite Sync uses advanced **CRDT (Conflict-free Replicated Data
- When they reconnect, all changes are **merged automatically and without conflicts**.
- **No data loss. No overwrites. No manual conflict resolution.**

---

## IMPORTANT

- Make sure to use version **0.9.96 or newer**
(verify with `SELECT cloudsync_version();`)

- Until v0.9.96 is released upstream, always use the development fork:
https://github.com/sqliteai/sqlite-sync-dev
and **not** the original repository:
and **NOT** the original repository:
https://github.com/sqliteai/sqlite-sync

- Updated example apps are available at:
https://github.com/sqliteai/sqlite-sync-dev/tree/main/examples
- sport-tracker-app (WASM), see [SPORT_APP_README_SUPABASE.md](SPORT_APP_README_SUPABASE.md) for more details
- to-do-app (React)
- React-Native (Expo): https://github.com/sqliteai/sqlite-sync-react-native
- Remaining demos will be updated in the next days

---
- Updated example apps are available [here](https://github.com/sqliteai/sqlite-sync-dev/tree/main/examples):
- sport-tracker app (WASM), see [SPORT_APP_README_SUPABASE.md](SPORT_APP_README_SUPABASE.md) for more details
- to-do app (Expo)
- React Native Library: https://github.com/sqliteai/sqlite-sync-react-native
- Remaining demos will be updated in the next days

## Conversion Between SQLite and PostgreSQL Tables

Expand Down Expand Up @@ -140,9 +135,7 @@ SELECT cloudsync_init('notes');
- [ ] Same column names and order
- [ ] Same defaults (semantic match)

Database Schema Recommendations: https://github.com/sqliteai/sqlite-sync-dev?tab=readme-ov-file#database-schema-recommendations

---
Please follow [these Database Schema Recommendations](https://github.com/sqliteai/sqlite-sync-dev?tab=readme-ov-file#database-schema-recommendations)

## Pre-built Binaries

Expand All @@ -154,8 +147,6 @@ Download the appropriate pre-built binary for your platform from the official [R
- Android
- iOS



## Loading the Extension

```
Expand All @@ -166,34 +157,27 @@ Download the appropriate pre-built binary for your platform from the official [R
SELECT load_extension('./cloudsync');
```

## WASM Version -> React client-side


## WASM Version

Make sure to install the extension tagged as **dev** and not **latest**
```
npm i sqlite-wasm@dev
npm i @sqliteai/sqlite-wasm@dev
```

Then follow the instructions available from https://www.npmjs.com/package/@sqliteai/sqlite-wasm


Then follow the instructions from the [README](https://www.npmjs.com/package/@sqliteai/sqlite-wasm)

## Swift Package

You can [add this repository as a package dependency to your Swift project](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app#Add-a-package-dependency). After adding the package, you'll need to set up SQLite with extension loading by following steps 4 and 5 of [this guide](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/platforms/ios.md#4-set-up-sqlite-with-extension-loading).



## Android Package

Add the [following](https://central.sonatype.com/artifact/ai.sqlite/sync.dev) to your Gradle dependencies:

```
implementation 'ai.sqlite:sync.dev:0.9.92'
implementation 'ai.sqlite:sync.dev:0.9.96'
```



## Expo

Install the Expo package:
Expand All @@ -202,13 +186,9 @@ Install the Expo package:
npm install @sqliteai/sqlite-sync-expo-dev
```

Then follow the instructions from:
Then follow the instructions from the [README](https://www.npmjs.com/package/@sqliteai/sqlite-sync-expo-dev)

https://www.npmjs.com/package/@sqliteai/sqlite-sync-expo-dev



## React/Node
## Node -> React server-side

```js
npm i better-sqlite3
Expand All @@ -227,8 +207,6 @@ console.log('Sync extension version:', version);" >> index.js
node index.js
```

---

## Naming Clarification

- **sqlite-sync** → Client-side SQLite extension
Expand Down
14 changes: 3 additions & 11 deletions docs/postgresql/CLOUDSYNC.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Demo Deployment

For the current demo, a single cloudsync node is deployed in **Europe** on Fly.io.
For the current demo, a single CloudSync node is deployed in **Europe** on Fly.io.

If testing from other regions, latency will reflect this single-node deployment.
A production deployment would use **geographically distributed nodes with regional routing** for global coverage.

---

### Fly.io
## Fly.io

Project Name: **cloudsync-staging**
Fly.io App: https://fly.io/apps/cloudsync-staging
Expand All @@ -16,8 +14,6 @@ Logs: https://fly.io/apps/cloudsync-staging/monitoring

> Note: This is a **demo-only environment**, not intended for production use.

---

## Environment Variables

Edit in the Fly.io **Secrets** section:
Expand All @@ -35,8 +31,6 @@ Environment variables:
- `CLOUDSYNC_SERVICE_PROJECT_ID` — project ID for service user
- `CLOUDSYNC_SERVICE_DATABASE_CONNECTION_STRING` — service user DB connection

---

## Tables

- **cloudsync_jobs** — queue of asynchronous jobs
Expand All @@ -46,9 +40,7 @@ Environment variables:

- **cloudsync_artifacts** — blobs ready for client download
- **cloudsync_metrics** — collected metrics
- **cloudsync_push_tokens** — Expo push tokens

---
- **cloudsync_push_tokens** — Expo push tokens

## Metrics

Expand Down
72 changes: 52 additions & 20 deletions docs/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,57 @@ The **SQLite AI offline-sync solution** consists of three main components:

Together, these components provide a complete, production-grade **offline-first synchronization stack** for SQLite and PostgreSQL.


# SQLite Sync

**SQLite Sync** is a native SQLite extension that must be installed and loaded on all client devices.
We provide prebuilt binaries for:
* Desktop and mobile platforms
* WebAssembly (WASM)
* Popular frameworks including React, Expo, npm, and more

**Note:** The latest version (v0.9.96) is not yet available in the official SQLite Sync repository. Please use our development fork instead:[https://github.com/sqliteai/sqlite-sync-dev](https://github.com/sqliteai/sqlite-sync-dev)
* Popular package managers and frameworks including React Native, Expo, Node, Swift PM and Android AAR

**Note:** The latest version (v0.9.96) is not yet available in the official SQLite Sync repository. Please use our development fork instead: [https://github.com/sqliteai/sqlite-sync-dev](https://github.com/sqliteai/sqlite-sync-dev)

<details>
<summary>List of development fork binaries (v0.9.96)</summary>

### Android
- [cloudsync-android-aar-0.9.96.aar](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-aar-0.9.96.aar)
- [cloudsync-android-arm64-v8a-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-arm64-v8a-0.9.96.tar.gz)
- [cloudsync-android-arm64-v8a-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-arm64-v8a-0.9.96.zip)
- [cloudsync-android-armeabi-v7a-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-armeabi-v7a-0.9.96.tar.gz)
- [cloudsync-android-armeabi-v7a-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-armeabi-v7a-0.9.96.zip)
- [cloudsync-android-x86_64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-x86_64-0.9.96.tar.gz)
- [cloudsync-android-x86_64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-android-x86_64-0.9.96.zip)

### Apple (iOS / macOS)
- [cloudsync-apple-xcframework-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-apple-xcframework-0.9.96.zip)
- [cloudsync-ios-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-ios-0.9.96.tar.gz)
- [cloudsync-ios-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-ios-0.9.96.zip)
- [cloudsync-ios-sim-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-ios-sim-0.9.96.tar.gz)
- [cloudsync-ios-sim-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-ios-sim-0.9.96.zip)
- [cloudsync-macos-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-0.9.96.tar.gz)
- [cloudsync-macos-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-0.9.96.zip)
- [cloudsync-macos-arm64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-arm64-0.9.96.tar.gz)
- [cloudsync-macos-arm64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-arm64-0.9.96.zip)
- [cloudsync-macos-x86_64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-x86_64-0.9.96.tar.gz)
- [cloudsync-macos-x86_64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-macos-x86_64-0.9.96.zip)

### Linux
- [cloudsync-linux-arm64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-arm64-0.9.96.tar.gz)
- [cloudsync-linux-arm64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-arm64-0.9.96.zip)
- [cloudsync-linux-musl-arm64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-musl-arm64-0.9.96.tar.gz)
- [cloudsync-linux-musl-arm64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-musl-arm64-0.9.96.zip)
- [cloudsync-linux-musl-x86_64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-musl-x86_64-0.9.96.tar.gz)
- [cloudsync-linux-musl-x86_64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-musl-x86_64-0.9.96.zip)
- [cloudsync-linux-x86_64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-x86_64-0.9.96.tar.gz)
- [cloudsync-linux-x86_64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-linux-x86_64-0.9.96.zip)

### Windows
- [cloudsync-windows-x86_64-0.9.96.tar.gz](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-windows-x86_64-0.9.96.tar.gz)
- [cloudsync-windows-x86_64-0.9.96.zip](https://github.com/sqliteai/sqlite-sync-dev/releases/download/0.9.96/cloudsync-windows-x86_64-0.9.96.zip)

</details>

### Architecture Refactoring
The extension has been refactored to support both **SQLite** and **PostgreSQL** backends.
Expand All @@ -29,7 +71,7 @@ This modular design improves **portability**, **maintainability**, and **cross-d
* Code coverage exceeds **90%**
* PostgreSQL-specific code has its own dedicated test suite

Key Features
### Key Features
* Deep integration with SQLite — the default database for Edge applications
* Built-in network layer exposed as ordinary SQLite functions
* Cross-platform, language-agnostic payload format
Expand All @@ -45,7 +87,6 @@ Currently implemented CRDT algorithms:
Additional CRDTs can be implemented if needed, though LWW covers most real-world use cases.



# CloudSync

**CloudSync** is a lightweight, stateless microservice responsible for synchronizing clients with central servers.
Expand All @@ -58,9 +99,7 @@ Additional CRDTs can be implemented if needed, though LWW covers most real-world
* Collects operational metrics (connected devices, sync volume, traffic, etc.)
* Exposes a complete **REST API**


Technology Stack
### Technology Stack

* Written in **Go**
* Built on the high-performance **Gin Web Framework**
Expand All @@ -69,23 +108,18 @@ Technology Stack
* Stateless architecture enables horizontal scaling simply by adding nodes
* Serialized job queue ensures **no job loss**, even after restarts


Observability
### Observability

* Metrics dashboard available in [grafana-dashboard.json](grafana-dashboard.json)

* Additional logs available via the Fly.io monitoring dashboard

### Demo Deployment

Demo Deployment

For the current demo, a single CloudSYnc node is deployed in **Europe** on Fly.io.
For the current demo, a single CloudSync node is deployed in **Europe** on Fly.io.
If testing from other regions, latency will reflect this single-node deployment. A production deployment would use **geographically distributed nodes with regional routing** for global coverage.



# Postgres Sync

**Postgres Sync** is a native PostgreSQL extension derived from SQLite Sync.
Expand All @@ -105,16 +139,14 @@ SQLite does not support schemas, while PostgreSQL does. To bridge this differenc

This preserves PostgreSQL-native organization while maintaining SQLite compatibility.



# Current Limitations

The PostgreSQL integration is actively evolving. Current limitations include:

* **User Impersonation**: The microservice currently applies server changes using the Supabase Admin user. In the next version, changes will be applied under the identity associated with the client’s JWT.
* **Table Creation**: Tables must currently be created manually in PostgreSQL before synchronization. We are implementing automatic translation of SQLite CREATE TABLE statements to PostgreSQL syntax.
* **Row-Level Security**: RLS is fully implemented for SQLite Cloud servers.PostgreSQL RLS integration is in progress and will be included in the final release.
* **Beta Status**: While extensively tested, the PostgreSQL sync stack should currently be considered **beta software**. Please report any issues, we are committed to resolving them quickly.
* **Row-Level Security**: RLS is fully implemented for SQLite Cloud servers. PostgreSQL RLS integration is in progress and will be included in the final release.
* **Beta Status**: While extensively tested, the PostgreSQL sync stack should currently be considered **beta software**. Please report any issues; we are committed to resolving them quickly.

# Next
* [CLIENT](CLIENT.md) installation and setup
Expand Down
2 changes: 1 addition & 1 deletion docs/postgresql/SPORT_APP_README_SUPABASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A Vite/React demonstration app showcasing [**SQLite Sync (Dev)**](https://github

### 2. Database Setup
1. Create database
2. Execute the schema with [sport-tracker-schema-postgres.sql](sport-tracker-schema-postgres.sql).
2. Execute the schema with [sport-tracker-schema-postgres.sql](../../examples/sport-tracker-app/sport-tracker-schema-postgres.sql).
3. Enable CloudSync for all tables on the remote database with:
```sql
CREATE EXTENSION IF NOT EXISTS cloudsync;
Expand Down
2 changes: 0 additions & 2 deletions docs/postgresql/SUPABASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Supabase deployments.
- Supabase stack running (CLI local or self-hosted)
- The Supabase Postgres image tag in use (e.g. `public.ecr.aws/supabase/postgres:17.6.1.071`)



## Option A: Supabase CLI Local Stack

1) Start the stack once so the Postgres image is present:
Expand Down