How elie222/inbox-zero works
Main components
• Frontend (apps/web) – Next.js React app serving UI and client-side logic.
• Serverless API (apps/web/api) – Next.js API routes handling user actions, Gmail integration, AI requests, reply tracking, cleanup, etc.
• Background services
– Unsubscriber (apps/unsubscriber) – standalone Node process for bulk-unsubscribe jobs.
– mcp-server (apps/mcp-server) – minimal compute proxy for long-running tasks (optional).
• Data stores
– PostgreSQL (Prisma) – primary relational store for users, rules, history, settings.
– Redis (Upstash or local) – queues, real-time state (categorization progress, reply-tracker).
– Tinybird analytics – event ingestion & query engine for email analytics.
• External integrations
– Gmail API (via Google Pub/Sub webhook & REST calls)
– OAuth (NextAuth + Google)
– LLM providers (OpenAI, Anthropic, Ollama, etc.)
– Third-party email service (Resend)
– Payment/webhook (LemonSqueezy)
Relationships and data flow
• User → Browser → Next.js Frontend → Next.js API
• API → Prisma client → PostgreSQL
• API → Redis → job queues → background services
• API/Background → Gmail API (via Pub/Sub or REST)
• API/Background → LLM provider for AI-driven actions
• Email events (Pub/Sub webhook) → Next.js API → Redis/DB
• Analytics events → Tinybird
• Payment/webhooks → Next.js API → DB
Architectural patterns
• Monorepo (Turborepo + pnpm workspaces)
• Serverless first (Next.js API routes) augmented by small Node workers
• CQRS-style separation: API for commands/queries, Redis queues for tasks
• Externalized AI layering: all “intelligence” calls go through a unified AI-utils module
• Prisma for schema-driven migrations and type safety