Skip to content

System Architecture

Edge-Native System Architecture

AgentWiki is architected to run entirely on Cloudflare’s serverless edge infrastructure, ensuring sub-50ms latency across 300+ global data centers.

┌─────────────────────────────────────────────────────────────┐
│ Frontend Layer │
│ React 19 + BlockNote + TailwindCSS v4 │
│ Cloudflare Pages (app.agentwiki.cc) │
└────────────────────────┬────────────────────────────────────┘
│ HTTPS REST API
│
┌────────────────────────▼────────────────────────────────────┐
│ API Gateway Layer │
│ Hono on Cloudflare Workers (api.agentwiki.cc) │
│ ├── Routes: Auth, Documents, Search, Graph, Secrets... │
│ └── Middleware: AuthGuard, RateLimiter, CreditGuard │
└────────────────────────┬────────────────────────────────────┘
│
┌────────────────┼────────────────┐
│ │ │
┌───▼──┐ ┌───▼──┐ ┌─────▼──────┐
│ D1 │ │ R2 │ │ Vectorize │
│(SQL) │ │Files │ │(Embeddings)│
└──────┘ └──────┘ └────────────┘
│ │ │
┌───▼──┐ ┌───▼────┐ ┌─────▼──────┐
│ KV │ │ Queues │ │ Workers AI │
│Cache │ │(Async) │ │ (Inference)│
└──────┘ └────────┘ └────────────┘

Core Infrastructure Components

  1. Cloudflare Workers (packages/api): High-performance TypeScript API runtime powered by Hono.
  2. Cloudflare D1 (SQLite): Primary relational database managed via Drizzle ORM, storing tenants, users, documents, folders, tags, and audit logs.
  3. Cloudflare Vectorize: Vector database indexing 768-dimensional document embeddings for semantic similarity and RAG suggestions.
  4. Cloudflare R2: Object storage for file uploads, static site bundles, and media assets.
  5. Cloudflare KV: Ultra-low latency cache for API key validation, rate-limiting counters, and session states.
  6. Cloudflare Queues: Async message broker for background text chunking, embedding generation, and AI summarization.