Skip to main content

Offline Mode

SuperFast is offline-first by design. Every feature that involves reading or writing data works without an internet connection. Network access is only required for syncing with other devices and for WhatsApp messaging.

What Works Offlineโ€‹

All core app functionality is fully available offline:

FeatureOffline AvailableNotes
View DashboardYesData from local SQLite
Add / Edit / Delete CustomersYesWritten to local DB + sync queue
Add / Edit / Delete SuppliersYesWritten to local DB + sync queue
Record Transactions (debts & payments)YesWritten to local DB + sync queue
View Transaction HistoryYesAll local data
Print StatementsYesLocal data only
Create / Edit / Delete RemindersYesWritten to local DB + sync queue
View Reports & AnalyticsYesAll computed from local data
Export BackupYesReads local SQLite
Import BackupYesWrites to local SQLite
Product Template AutocompleteYesLocal templates
PIN / Biometric LoginYesVerified locally

What Requires Network Accessโ€‹

FeatureWhy Network is Needed
Cloud Sync (push/pull)Communicates with backend server
WhatsApp message sendingCalls Evolution API on the server
WhatsApp QR code / connectionCalls Evolution API
Chat list & messagesFetched from Evolution API
Server Metrics DashboardCalls /api/v1/server/metrics
Initial device registrationOne-time call to the server

Offline Indicatorโ€‹

When the device has no network connection, a small Offline badge appears:

  • In the header bar (top of screen)
  • On the Cloud Sync settings tab

This badge disappears as soon as connectivity is restored.


How Offline Writes Are Queuedโ€‹

When you create a transaction while offline:

1. User taps "Save"
2. App writes the transaction to local SQLite immediately
3. App inserts a row into sync_queue with status='pending'
4. UI updates instantly (no spinner, no waiting)
5. [Later, when online] Sync engine reads sync_queue
6. Items are pushed to the server
7. sync_queue rows are marked status='synced'

The user never waits for a network response. The experience is identical whether online or offline.


Sync on Reconnectโ€‹

When network connectivity is restored, the sync engine detects it within 5 seconds and automatically triggers a push + pull cycle. You will see the Last Sync timestamp update in Settings โ†’ Cloud Sync.

On Android, network state changes are monitored via the system NetworkCallback API. On desktop (Windows/macOS/Linux), the app polls connectivity every 5 seconds.


Conflict Handling After Offline Periodโ€‹

If two devices both made changes to the same record while offline:

  1. Whichever device pushes first has its change stored on the server.
  2. When the second device pushes, the server compares timestamps.
  3. The later timestamp wins (Last-Write-Wins).
  4. The first device gets the second device's version on its next pull.

For transactions, conflicts almost never occur because each transaction has a unique UUID generated on the device. Two devices creating transactions for the same customer don't conflict โ€” both transactions are preserved.


Long Offline Periodsโ€‹

If a device has been offline for a very long time (weeks or months):

  1. The JWT access token may expire (24h) and the refresh token may also expire (30 days).
  2. When the device comes back online, it will get an 401 Unauthorized error.
  3. The user must re-authenticate via Settings โ†’ Cloud Sync โ†’ Connect.
  4. After re-authentication, the pending sync queue items are pushed.
tip

To avoid token expiry on long-offline devices, ensure the app is opened occasionally (even with Wi-Fi off) โ€” the app will attempt to refresh the token whenever the device has network access.


Testing Offline Modeโ€‹

To test offline behavior manually:

  1. Enable Airplane Mode on your device.
  2. Open SuperFast โ€” notice the Offline badge in the header.
  3. Add a customer and create a transaction.
  4. Disable Airplane Mode.
  5. Within 5 seconds, the sync should trigger automatically and the data should appear on another device.