Architecture
A local server that disappears when you're done
The app launches with a single command — Python starts a Flask server bound to localhost, finds a free port, and opens your default browser automatically. From the user's perspective it behaves exactly like a native app. The server shuts down cleanly when you close the terminal.
Search is a two-stage pipeline. A Whoosh full-text index handles the free-text portion of a query — scoring and ranking across subject, body, sender, and recipient fields with optional fuzzy matching. Results pass through a SQLite post-filter that handles structured predicates: date ranges, attachment type, read/starred state, label membership, and cross-archive filtering. Neither engine alone is sufficient for all query types; together they cover the full space without a heavier dependency.
Import runs in a background thread so the UI stays responsive for large archives. Progress streams to the browser via Server-Sent Events in real time. The SQLite database uses WAL mode throughout, which allows concurrent reads to proceed without blocking the ongoing write — so browsing earlier imports while a new one indexes works cleanly.
Attachment files are extracted from archives on import and stored in a local directory, each keyed by a stable hash. The database records filename, MIME type, size, and inline Content-ID for accurate HTML email rendering — inline images and attachments distinguished automatically.