Back to Blog
Engineering

Under the Hood: How Snigo Syncs Across Devices

Snigo Team7 min readEngineering

One of Snigo's core promises is that your snippets are always available, no matter which device you're on. Save a snippet on your work laptop, and it's on your home desktop in seconds. In this post, we'll explain how we built our sync engine.

The Architecture

Our sync system is built on three pillars:

  1. Conflict-Free Replicated Data Types (CRDTs): We use CRDTs to handle concurrent edits without data loss. If you edit the same snippet on two devices simultaneously, both changes are preserved and merged intelligently.
  2. WebSocket Connections: Every connected client maintains a persistent WebSocket connection to our sync server. Changes propagate in real-time — typically under 200ms.
  3. Offline Queue: When you're offline, changes are queued locally and synced the moment connectivity is restored. The queue is persisted to disk, so even a crash won't lose unsaved changes.

Handling Conflicts

The trickiest part of any sync system is conflict resolution. Here's our approach:

  • Title and metadata: Last-write-wins with a timestamp-based tiebreaker.
  • Code content: Character-level CRDT merge. Both edits are preserved, with visual markers if the changes overlap.
  • Labels and collections: Set-based CRDTs — additions and removals from both sides are merged without conflicts.

Performance Numbers

Here are our current sync benchmarks:

  • Average sync latency: 180ms (same region), 350ms (cross-region)
  • Offline queue capacity: 10,000 operations
  • Sync payload size for a typical snippet: ~2KB
  • Monthly data transfer per user: ~15MB

What's Next

We're working on peer-to-peer sync for teams on the same local network, which will bring sync latency down to under 50ms. We're also exploring end-to-end encryption for the sync pipeline. Follow our blog for updates.