Skip to main content

MOE-Agents Architecture: C4 Model v2.0 (Unified Persistent)

System: Multi-tenant AI Agent Platform with CODITECT-CORE orchestration
Version: 2.0.0 - Unified Persistent Architecture
Scope: Multi-Organization → Multi-Team → Multi-User → Multi-Project
LLM Providers: Gemini, Claude-Code, Codex, Kimi (in-workspace coordination)
Storage: GCS Primary + R2 Mirror + SQLite Cluster


Architecture Changes v2.0

Componentv1.0 (Ephemeral)v2.0 (Persistent)
ComputeEphemeral sandboxes per LLMSingle persistent workspace
Storage PrimaryR2GCS with gcsfuse
Storage CacheNoneR2 hot mirror
Session StateDurable Objects onlySQLite + JSONL
LLM CoordinationExternal routerIn-workspace orchestrator
Data Persistence30-min timeout8+ hours, full durability

C4 Level 4: Code (Implementation Classes)


C4 Level 3: Component Diagram (CODITECT-CORE Internals)


C4 Level 2: Container Diagram (System Architecture)


C4 Level 1: System Context Diagram


Data Flow Diagrams

Flow 1: Workspace Initialization

Flow 2: Multi-Agent Task Execution

Flow 3: Session Persistence & Recovery

Flow 4: Database Backup & Archive


Multi-Tenancy Data Model v2.0


Key Architectural Decisions v2.0

DecisionRationale
Single Persistent WorkspaceAll LLMs share context, zero cold starts, instant agent coordination
GCS as Primary StorageMature gcsfuse, reliable SQLite-over-FUSE, multi-regional
R2 as MirrorCost-effective hot cache, zero egress for cached data
SQLite Cluster (6 DBs)Specialized schemas, fast queries, WAL for durability
Session JSONLAppend-only audit trail, easy replay, compression friendly
In-Workspace AgentsDirect coordination, shared memory, no network overhead
8-Hour Session LifetimeBalance between persistence and cost, renewable

Deployment Topology v2.0

┌─────────────────────────────────────────────────────────────────┐
│ Cloudflare Edge │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────────┐ │
│ │ Workers │ │ WebSocket │ │ Durable Objects │ │
│ │ (API) │ │ (Streams) │ │ (Workspace Registry) │ │
│ └──────┬──────┘ └──────┬──────┘ └─────────────────────────┘ │
│ │ │ │
│ ┌──────▼────────────────▼──────┐ ┌─────────────────────────┐ │
│ │ CODITECT-CORE │ │ GCS / R2 │ │
│ │ (Orchestrator + DO) │ │ (Primary + Mirror) │ │
│ └──────┬────────────────┬──────┘ └─────────────────────────┘ │
└─────────┼────────────────┼───────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ Persistent Workspace Pool (GKE / Cloudflare) │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Unified Workspace (per user/session) │ │
│ │ │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ Claude │ │ Gemini │ │ Agent │ │ │
│ │ │ Agent │ │ Agent │ │ Coordinator│ │ │
│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ │ ┌────────────────────────────────────────────────────┐ │ │
│ │ │ SQLite Database Cluster │ │ │
│ │ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │ │
│ │ │ │sessions│ │messages│ │artifacts│ │parsed │ │ │ │
│ │ │ │ .db │ │ .db │ │ .db │ │sessions│ │ │ │
│ │ │ └────────┘ └────────┘ └────────┘ └────────┘ │ │ │
│ │ │ ┌────────┐ ┌────────┐ │ │ │
│ │ │ │metrics │ │workspace│ │ │ │
│ │ │ │ .db │ │ .db │ │ │ │
│ │ │ └────────┘ └────────┘ │ │ │
│ │ └────────────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ /home/developer/projects/ ← GCS FUSE mount │ │
│ │ ├── .coditect/sessions/ ← JSONL archives │ │
│ │ └── .coditect/databases/ ← SQLite files │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────┐
│ External Providers │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Anthropic│ │ Google │ │ OpenAI │ │ Moonshot │ │
│ │ Claude │ │ Gemini │ │ Codex │ │ Kimi │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────────┘

Document Owner: Platform Engineering Team
Version: 2.0.0
Last Updated: 2026-01-31