System Topology, Storage & Hybrid RAG
Single-binary Go + React architecture, bounded IMAP streaming, SHA-256 blob deduplication, and RRF vector search.
Layered Backend & Frontend Architecture
- Go Single Binary (
backend/cmd/bryfo): Thin HTTP/SSE/MCP handlers ininternal/api/delegate domain invariants and PostgreSQL transactions toauth,mail,ai,privacy,storage,billing,mcp,netguard,ops,queue,settings, andcrypto. - Frontend Feature Isolation (
web/src/): Non-admin workspaces (features/mail,features/auth,features/billing) never importfeatures/admin, keeping/admin/*,admin.json, andrechartsisolated inside lazy-loaded admin chunks.
Bounded IMAP Ingest & Tiered IDLE
- Zero
fetchCmd.Collect()OOMs: Messages stream one by one viafetchCmd.Next()with a35 MiBper-message cap (64 KiBheader/summary fallback for oversized messages) and automatic rollback blob cleanup if a DB transaction aborts. - Resilient
IDLEManager: Renews IMAPIDLEevery 25 minutes per RFC 2177, resets backoff upon reconnect, clears stale UID maps onUIDVALIDITYchanges, and tierscloudconnections via Valkeyuser:active:<uid>windows.
Content-Addressable Storage & Hybrid RRF Search
- SHA-256 Deduplication (
blob_objects): Local and S3/R2 blobs deduplicate across messages atsha256/<2>/<2>/<sha256>with reference counting and a 6-hour two-phase tombstone GC sweep (zeroed_at+ 1-hour grace window +FOR UPDATE SKIP LOCKED). - Reciprocal Rank Fusion (
k=60): Merges PostgreSQLpg_trgmlexical hits withpgvectorcosine similarity (vectorHNSW up to2000dims; automatichalfvecHNSW for2001–4000dims).