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
| Repo | Purpose | Deploy |
|---|---|---|
cortex | Frontend (Next.js) | Vercel |
cortex-api | Backend (FastAPI) | Railway |
cortex-docs | Documentation (Nextra) | Vercel |
Key Design Decisions
-
SQLite over Postgres β Simpler deployment, zero infrastructure. Litestream provides durability via continuous replication to S3-compatible storage.
-
ChromaDB for embeddings β Embedded vector database. No separate service to manage.
-
Haiku by default β Cost efficiency. Most queries donβt need Sonnetβs reasoning power. Auto-escalation handles the exceptions.
-
SSE over WebSockets β Simpler, works through more proxies, sufficient for one-way event streaming.
-
JWT over sessions β Stateless authentication. No server-side session store needed.
Last updated on