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
| Component | v1.0 (Ephemeral) | v2.0 (Persistent) |
|---|---|---|
| Compute | Ephemeral sandboxes per LLM | Single persistent workspace |
| Storage Primary | R2 | GCS with gcsfuse |
| Storage Cache | None | R2 hot mirror |
| Session State | Durable Objects only | SQLite + JSONL |
| LLM Coordination | External router | In-workspace orchestrator |
| Data Persistence | 30-min timeout | 8+ 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
| Decision | Rationale |
|---|---|
| Single Persistent Workspace | All LLMs share context, zero cold starts, instant agent coordination |
| GCS as Primary Storage | Mature gcsfuse, reliable SQLite-over-FUSE, multi-regional |
| R2 as Mirror | Cost-effective hot cache, zero egress for cached data |
| SQLite Cluster (6 DBs) | Specialized schemas, fast queries, WAL for durability |
| Session JSONL | Append-only audit trail, easy replay, compression friendly |
| In-Workspace Agents | Direct coordination, shared memory, no network overhead |
| 8-Hour Session Lifetime | Balance 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