Engineering

How WeekDone Syncs Offline-First Across Desktop, Web, and Mobile

Inside WeekDone's local-first architecture: SQLite WAL storage, monotonic server sync cursors, Server-Wins conflict JSON dumps, and L2 AES-256-GCM envelope encryption.

Why build Local-First instead of a pure cloud web app?

When you press ⌘K to capture an idea or click a checkbox in Darkroom, waiting 300ms for a remote API round-trip breaks focus. Worse, airplane mode or unstable hotel Wi-Fi turns cloud-only task apps into read-only placeholders.

WeekDone reverses the dependency: local storage is the primary source of truth for the UI, and the Go backend acts as an asynchronous delta sync relay.

How does the 6-table SQLite WAL + Pull-Merge-Push protocol work?

On macOS and Windows (Tauri v2), the desktop host persists state across six core tables (tasks, task_steps, pomodoro_logs, attachments, weekly_reviews, sync_meta) in SQLite WAL mode (PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL;).

Each sync cycle follows a predictable Pull-Merge-Push sequence:

  1. Pull: Client calls GET /api/v1/sync/pull?cursor={last_sync_cursor}&limit=100 to receive all records with server_updated_at > cursor.
  2. Merge & Conflict Safety: Incoming server records update clean local entities. If a local entity is dirty and the server also changed it, the client writes a conflict copy (conflicts/{uuid}_{ts}.json) before adopting the server state.
  3. Push: Client pushes remaining local dirty mutations via POST /api/v1/sync/push and advances its local last_sync_cursor.
  4. Live Wakeup: Connected clients subscribe to Server-Sent Events (GET /api/v1/sync/events) to pull immediately when another device pushes changes.
text
Device A (Offline Edit) ──▶ Local SQLite WAL (dirty)
                                  │
                          Network Restored
                                  ▼
      Pull (?cursor=41) ──▶ Merge + Dump Conflicts ──▶ Push Dirty Batch ──▶ SSE Broadcast to Device B

How are attachments and user data secured?

LayerMechanismPurpose
AuthenticationGoogle OAuth 2.0 (openid email profile) + HMAC-signed JWTs1-hour access token + 30-day refresh token
Envelope EncryptionOptional L2 AES-256-GCM per-user DEK wrapped by Master KEKProtects synced task titles & notes at rest
Attachment StorageDirect-to-R2 SigV4 presigned URLs + backend proxy fallbackZero public bucket exposure; 100 MB free quota
TelemetryZero third-party ad or behavioral tracking SDKsComplete user privacy across all platforms

Frequently Asked Questions

Can I use WeekDone completely offline without signing in?

Yes. All core features—The Stage, Garden, Darkroom timer, local attachments, and Energy Map—work offline without an account.

How does WeekDone handle sync conflicts between two offline devices?

WeekDone uses a deterministic Server-Wins reconciliation strategy while dumping the overwritten local version to a local conflicts/{uuid}_{timestamp}.json file on Desktop so no edit is ever lost.

How is cloud-synced data protected at rest?

Passwords use Argon2id/HMAC verification, and user task payloads support optional L2 AES-256-GCM envelope encryption with per-user Data Encryption Keys (DEKs).

Gang Wang
Creator & Architect of WeekDone

Building calm, offline-first productivity software with local SQLite, Go, and Tauri v2.

Try focusing on just 7 tasks this week.

Offline-first across Web, macOS, Windows, and Mobile. Zero ads, zero tracking.

Open WeekDone