super-productivity/packages/super-sync-server
2025-12-12 20:48:13 +01:00
..
public feat: Implement Terms of Service and Privacy Policy acceptance for Super Sync registration 2025-12-12 20:48:13 +01:00
scripts fix(sync): wrap full-state operation payloads in appDataComplete 2025-12-12 20:47:48 +01:00
src Fix super-sync server auth and snapshot safety 2025-12-12 20:48:13 +01:00
tests Fix super-sync server auth and snapshot safety 2025-12-12 20:48:13 +01:00
.env.example feat(syncServer): add user isolation, public URL configuration for email links and improve user registration flow 2025-12-12 20:46:04 +01:00
.gitignore feat(syncServer): add SMTP email verification for user registration 2025-12-12 20:46:04 +01:00
Dockerfile.test test(sync): add offline queue persistence tests for OperationLogStoreService 2025-12-12 20:48:12 +01:00
package.json feat(sync): add shared schema versioning package for frontend/backend 2025-12-12 20:47:44 +01:00
privacy-policy-en.md docs: add draft for privacy policy and terms of service 2025-12-12 20:48:13 +01:00
privacy-policy.md docs: add draft for privacy policy and terms of service 2025-12-12 20:48:13 +01:00
README.md feat(super-sync-server): fix docs, add tests, and optimize snapshots 2025-12-12 20:46:23 +01:00
sync-server-architecture-diagrams.md docs(sync): add meta-reducer pattern to server architecture diagrams 2025-12-12 20:47:48 +01:00
terms-of-service-en.md docs: add draft for privacy policy and terms of service 2025-12-12 20:48:13 +01:00
terms-of-service.md docs: add draft for privacy policy and terms of service 2025-12-12 20:48:13 +01:00
tsconfig.json feat(syncServer): first draft 2025-12-12 20:46:04 +01:00

SuperSync Server

A custom, high-performance synchronization server for Super Productivity.

Note: This server implements a custom operation-based synchronization protocol (Event Sourcing), not WebDAV. It is designed specifically for the Super Productivity client's efficient sync requirements.

Architecture

The server uses an Append-Only Log architecture backed by SQLite:

  1. Operations: Clients upload atomic operations (Create, Update, Delete, Move).
  2. Sequence Numbers: The server assigns a strictly increasing server_seq to each operation.
  3. Synchronization: Clients request "all operations since sequence X".
  4. Snapshots: The server can regenerate the full state by replaying operations, optimizing initial syncs.

Quick Start

# Install dependencies
npm install

# Set JWT secret (required in production)
export JWT_SECRET="your-secure-random-secret"

# Start the server
npm run dev

# Or build and run
npm run build
npm start

Configuration

All configuration is done via environment variables. Copy .env.example to .env and customize:

Variable Default Description
PORT 1900 Server port
DATA_DIR ./data Directory for storing sync data (SQLite DB)
PUBLIC_URL - Publicly reachable URL used for email links
JWT_SECRET - Required in production. Secret for signing JWTs
CORS_ENABLED true Enable CORS for browser clients
CORS_ORIGINS * Allowed origins (comma-separated)
NODE_ENV - Set to production for production mode

API Endpoints

Authentication

Register a new user

POST /api/register
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "yourpassword"
}

Response:

{
  "message": "User registered. Please verify your email.",
  "id": 1,
  "email": "user@example.com"
}

Login

POST /api/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "yourpassword"
}

Response:

{
  "token": "jwt-token",
  "user": { "id": 1, "email": "user@example.com" }
}

Synchronization

All sync endpoints require Bearer authentication: Authorization: Bearer <jwt-token>

1. Upload Operations

Send new changes to the server.

POST /api/sync/ops

2. Download Operations

Get changes from other devices.

GET /api/sync/ops?sinceSeq=123

3. Get Snapshot

Get the full current state (optimized).

GET /api/sync/snapshot

4. Sync Status

Check pending operations and device status.

GET /api/sync/status

Client Configuration

In Super Productivity, configure the Custom Sync provider with:

  • Base URL: http://localhost:1900 (or your deployed URL)
  • Auth Token: JWT token from login

Development

# Run in development mode with hot reload
npm run dev

# Build TypeScript
npm run build

# Run production build
npm start

Docker

docker run -d \
  -p 1900:1900 \
  -e JWT_SECRET="your-secure-secret" \
  -e NODE_ENV="production" \
  -v ./data:/app/data \
  super-productivity/sync-server

Security Notes

  • Set JWT_SECRET to a secure random value in production.
  • Use HTTPS in production (via reverse proxy like nginx).
  • Restrict CORS origins in production.