Skip to Content
Bryfo Docsv0.2.1

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 in internal/api/ delegate domain invariants and PostgreSQL transactions to auth, mail, ai, privacy, storage, billing, mcp, netguard, ops, queue, settings, and crypto.
  • Frontend Feature Isolation (web/src/): Non-admin workspaces (features/mail, features/auth, features/billing) never import features/admin, keeping /admin/*, admin.json, and recharts isolated inside lazy-loaded admin chunks.

Bounded IMAP Ingest & Tiered IDLE

  • Zero fetchCmd.Collect() OOMs: Messages stream one by one via fetchCmd.Next() with a 35 MiB per-message cap (64 KiB header/summary fallback for oversized messages) and automatic rollback blob cleanup if a DB transaction aborts.
  • Resilient IDLEManager: Renews IMAP IDLE every 25 minutes per RFC 2177, resets backoff upon reconnect, clears stale UID maps on UIDVALIDITY changes, and tiers cloud connections via Valkey user:active:<uid> windows.
  • SHA-256 Deduplication (blob_objects): Local and S3/R2 blobs deduplicate across messages at sha256/<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 PostgreSQL pg_trgm lexical hits with pgvector cosine similarity (vector HNSW up to 2000 dims; automatic halfvec HNSW for 2001–4000 dims).

On this page