Under the Hood

This page is for the technically curious. If you just want to use Sparrow, you don't need to read this — but if you're interested in why Sparrow is fast and how it works, read on.

Why Rust?

Sparrow's backend is written entirely in Rust — a programming language known for speed and reliability. The UI is built with React, running inside a Tauri 2 shell. This is why Sparrow:

  • Starts instantly — no runtime to boot up, no interpreter overhead
  • Uses little memory — typically under 50 MB, compared to 200–500 MB for Electron-based email apps
  • Stays responsive — no garbage collector pauses or random slowdowns
  • Doesn't drain your battery — minimal CPU usage when idle

Modular architecture

Sparrow is built from 11 independent Rust crates, each handling one job:

CrateResponsibility
sparrow-appTauri application shell — system tray, window management, logging
sparrow-coreBusiness logic — account management, sync pipeline, snooze, avatars
sparrow-domainPure types — Account, Email, Folder, Rule, Template, Contact, Settings
sparrow-imapIMAP client — full RFC support, IDLE, CONDSTORE, QRESYNC, COMPRESS
sparrow-jmapJMAP client (early stage)
sparrow-smtpSMTP sending — password and OAuth2 auth, TLS/STARTTLS, attachments
sparrow-oauthOAuth2 with PKCE — Google, Microsoft, auto-detection by domain
sparrow-cryptoPGP (Sequoia) and S/MIME (OpenSSL) encryption
sparrow-searchFull-text search via Tantivy
sparrow-storageSQLite persistence — 23 migrations, all repositories
sparrow-keyringOS keyring for secure credential storage

How sync works

Sparrow keeps a local copy of all your emails in a SQLite database (WAL mode for concurrent access). When you're online:

  • New messages are downloaded in the background
  • Multiple folders sync using parallel connections
  • Changes you make (read, star, move, delete) apply instantly to the local DB
  • Operations are queued and sent to the server in the background
  • Real-time notifications via IMAP IDLE — no need to poll every few minutes
  • CONDSTORE/QRESYNC — only downloads changes since last sync, not everything

When you're offline, Sparrow queues your changes (flag changes, moves, deletes) and syncs them when you're back online. Each operation is retried up to 3 times with automatic cleanup.

IMAP capabilities

Sparrow detects and uses server capabilities automatically:

  • IDLE (RFC 2177) — real-time push for new messages, 25-min keepalive
  • CONDSTORE (RFC 7162) — delta sync using HIGHESTMODSEQ
  • QRESYNC (RFC 7162) — quick resync with VANISHED responses
  • MOVE (RFC 6851) — native message moving (falls back to copy+delete)
  • COMPRESS=DEFLATE (RFC 4978) — compressed connections for bandwidth savings
  • SORT / THREAD (RFC 5256) — server-side sorting and threading
  • NAMESPACE (RFC 2342) — discovers folder hierarchy
  • ESEARCH (RFC 4731) — efficient search with MIN/MAX/COUNT/ALL
  • SPECIAL-USE (RFC 6154) — auto-detects Inbox, Sent, Drafts, Trash, Junk
  • X-GM-EXT-1 — Gmail labels, message IDs, and thread IDs

Connections use exponential backoff reconnection (1s to 60s cap) and 120-second timeouts.

How search works

Instead of asking your email server to search (which is slow), Sparrow maintains its own Tantivy search index on your machine. When you type a query, it searches this local index — which is why results appear almost instantly.

The index covers subject, body text, sender/recipient names and emails, dates, attachment status, and read/starred flags. HTML is stripped before indexing so only the actual text content is searched.

Database

All data is stored in a single SQLite database at your system's local data directory using WAL (Write-Ahead Logging) mode for concurrent reads and writes. The schema is managed through 23 versioned migrations with foreign key enforcement and a 5-second busy timeout.

Open source

Sparrow is open source. You can inspect the code, report issues, or contribute on GitHub.