Skip to Content
DocumentationArchitectureOverview

Architecture

Cortex is a three-tier application with a clear separation between frontend, backend, and storage.

System Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Frontend β”‚ β”‚ Next.js 15 Β· App Router Β· Tailwind CSS Β· Redux β”‚ β”‚ Vercel (Production) Β· localhost:3000 (Dev) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ HTTPS / SSE β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Backend β”‚ β”‚ FastAPI Β· Python 3.12 Β· Uvicorn β”‚ β”‚ Railway (Production) Β· localhost:8000 (Dev) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ ZettelStore β”‚ ChromaDB β”‚ Anthropic API β”‚ β”‚ (SQLite + β”‚ (Vector β”‚ (Claude Haiku/Sonnet) β”‚ β”‚ FTS5) β”‚ Embeddings)β”‚ β”‚ β”‚ β”‚ sentence- β”‚ ElevenLabs API β”‚ β”‚ β”‚ transformersβ”‚ (TTS, optional) β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β” β”‚ Litestream β”‚ β†’ Cloudflare R2 (continuous replication) β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repositories

RepoPurposeDeploy
cortexFrontend (Next.js)Vercel
cortex-apiBackend (FastAPI)Railway
cortex-docsDocumentation (Nextra)Vercel

Key Design Decisions

  1. SQLite over Postgres β€” Simpler deployment, zero infrastructure. Litestream provides durability via continuous replication to S3-compatible storage.

  2. ChromaDB for embeddings β€” Embedded vector database. No separate service to manage.

  3. Haiku by default β€” Cost efficiency. Most queries don’t need Sonnet’s reasoning power. Auto-escalation handles the exceptions.

  4. SSE over WebSockets β€” Simpler, works through more proxies, sufficient for one-way event streaming.

  5. JWT over sessions β€” Stateless authentication. No server-side session store needed.

Last updated on