Topology &
Data Flow.
SortMail separates data ingestion from AI inference. By serving directly from local storage and pushing events over Server-Sent Events, the interface maintains sub-50ms reads regardless of upstream mail provider load.
Immediate Page Renders
SortMail eliminates blocking third-party API calls during inbox renders. Next.js reads directly from PostgreSQL in under 50 milliseconds while a background worker syncs delta state via Gmail historyId tokens.
Event-Driven Reactivity
Rather than polling the server every few seconds, the client maintains a persistent Server-Sent Events stream. Redis Pub/Sub detects background extraction completions and pushes targeted cache invalidation signals.
Strict Cost Predictability
Instead of multi-hop autonomous agent loops, SortMail dispatches one dense JSON schema query per thread to Gemini 2.0 Flash, achieving deterministic extraction at approximately ₹0.25 per message.
$ sortmail process --msg "NDA_Q3.eml" [info] Fetching thread via historyId: 18F4B2 [info] Cache hit: PostgreSQL local replica ready (38ms) [info] Invoking Gemini 2.0 Flash single-pass extractor [✓] Extracted bluf: "Priya Mehta shared updated Q3 agreement for review." [✓] Deadline Extracted: 2026-10-17T17:00:00Z (Priority: High) [✓] Extracted action items: 3 tasks routed to tasks table [✓] Attachment verified: Q3_Analytics_Agreement.pdf (MIME: application/pdf) [!] Threat check complete: 0 warnings [info] Published intel_ready on Redis channel: thread_18F4B2 (62ms)