Skip to main content

Cloud Sync Setup

Cloud sync connects your local device to the SuperFast backend server, enabling data sharing across multiple devices and automatic cloud backup.

Prerequisitesโ€‹

Before setting up cloud sync you need:

  1. A running SuperFast backend server (see Docker Deployment)
  2. The server's public URL (e.g. https://api.yourdomain.com)
  3. A registered store on the server, or you can register a new one during the connection flow

Connecting a Deviceโ€‹

Step 1 โ€” Open Cloud Sync Settingsโ€‹

  1. Open Settings โ†’ tap the Cloud Sync tab.

Step 2 โ€” Enter Server URLโ€‹

Enter your server URL without a trailing slash:

https://api.yourdomain.com
tip

If you're testing locally, use your machine's local IP:

http://192.168.1.100:8080

Step 3 โ€” Enter Device Nameโ€‹

Give this device a recognizable name, e.g.:

  • "Ahmed's iPhone"
  • "Store Counter Tablet"
  • "Office Desktop"

Device names appear in the server dashboard and help you manage connected devices.

Step 4 โ€” Connectโ€‹

Tap Connect. The app will:

  1. Validate the server URL by calling GET /api/v1/health
  2. Register this device by calling POST /api/v1/auth/device/login
  3. Receive a JWT access token and refresh token
  4. Trigger an initial pull to download all existing data

The entire process takes 2โ€“10 seconds depending on data volume.

Step 5 โ€” Verify Connectionโ€‹

A green Connected badge and the server version number appear in the Cloud Sync tab. The Last Sync timestamp updates every 30 seconds.


What Gets Syncedโ€‹

Synced to Cloudโ€‹

Data TypeSync Direction
Customers (name, phone, credit limit)Bidirectional
Suppliers (all fields)Bidirectional
Customer TransactionsBidirectional
Supplier TransactionsBidirectional
RemindersBidirectional
Store Name & CurrencyBidirectional
Product TemplatesBidirectional

NOT Synced (Stays Local)โ€‹

Data TypeReason
Theme (dark/light)Device preference
Language settingDevice preference
Biometric settingDevice security
PINDevice security (stored hashed locally)
WhatsApp connection statePer-device WhatsApp session
Device NameSet during connect

Sync Frequencyโ€‹

ScenarioSync Trigger
App in foregroundEvery 30 seconds
App comes to foregroundImmediately
Manual (tap Sync Now)Immediately
New transaction createdWithin 30 seconds
App in background (Android)Every 15 minutes (if background refresh enabled)

Sync Token Managementโ€‹

SuperFast uses JWT tokens for sync authentication:

  • Access Token: Valid for 24 hours
  • Refresh Token: Valid for 30 days

The app automatically refreshes the access token before it expires. If the refresh token expires (device not used for 30+ days), the device must reconnect via Settings โ†’ Cloud Sync โ†’ Connect.


Disconnecting a Deviceโ€‹

To remove cloud sync from a device without deleting local data:

  1. Go to Settings โ†’ Cloud Sync.
  2. Tap Disconnect.
  3. The device stops syncing; all local data remains intact.

To reconnect, repeat the Connecting a Device steps.


Multiple Storesโ€‹

A single SuperFast server can host multiple stores. Each store is completely isolated โ€” its data is never visible to other stores. Devices authenticate with store-specific credentials.


Sync Error Handlingโ€‹

Common Errorsโ€‹

ErrorCauseFix
ERR_CONNECTION_REFUSEDServer is down or URL is wrongCheck server is running, verify URL
401 UnauthorizedToken expired or device not registeredReconnect via Settings โ†’ Cloud Sync
409 ConflictConflicting update (resolved automatically)None needed; app handles it
503 Service UnavailableServer overloadedWait and retry; auto-retries in 60s

Stuck Sync Queueโ€‹

If the sync queue has many error items that aren't clearing:

  1. Check the server logs for errors.
  2. In Settings โ†’ Server, use Clear Sync Queue (danger zone) to flush stuck items.
  3. Trigger a manual sync.
warning

Clearing the sync queue on the server removes pending items permanently. Any offline changes from other devices that haven't been pushed yet will be lost. Only do this if you understand the consequences.