SORTMAIL.
System Design
Topology
& Data Flow.
Push, Don't Poll Pipeline
Database-First Load
Bypassing slow, rate-limited vendor API calls during initial load. The Next.js 14 frontend renders instantly from PostgreSQL (under 50ms) while background synchronization leverages Gmail's historyId for incremental delta syncing.
SSE Streaming
Polling creates UI stutter and wastes database resources. SortMail connects to the FastAPI backend via SSE. Redis Pub/Sub listens for worker completions and immediately pushes cache-invalidation payloads to React Query on the client.
Single-Pass Extraction
Rather than running LLMs in an endless loop, a single thread is sent to Gemini 2.0 Flash asking for a dense, strictly typed JSON object.