Overview
Routa is a multi-agent coordination platform built with a dual-backend architecture to support both web deployment and desktop distribution:- Next.js Backend (TypeScript) — Web deployment on Vercel with Postgres/SQLite
- Rust Backend (Axum) — Desktop application (
routa-servercrate) with embedded server and SQLite
The Tauri desktop application is the primary distribution target. The web version is available for demo purposes only.
High-Level Architecture
Core Components
RoutaSystem
The central system object that holds all stores, event bus, and tools. Located insrc/core/routa-system.ts:31-52.
RoutaSystem Interface
RoutaSystem Interface
src/core/routa-system.ts:5-8):
- InMemory (no database) — For quick development and tests
- Postgres (
DATABASE_URLset) — Neon Serverless via Drizzle ORM for web/Vercel deployments - SQLite (
ROUTA_DB_DRIVER=sqliteor desktop) — Local file via better-sqlite3 for Tauri/Electron
Orchestrator
The core orchestration engine that bridges MCP tool calls with actual ACP process spawning. Located insrc/core/orchestration/orchestrator.ts:17-16.
Orchestration Flow: When a coordinator delegates a task, the orchestrator:
- Checks delegation depth (max 2 levels)
- Resolves specialist configuration
- Creates a child agent record with metadata
- Spawns a real ACP process for the child agent
- Sends the task as the initial prompt
- Subscribes for completion events
- Wakes the parent agent when the child reports back
src/core/orchestration/orchestrator.ts:217-425):
- Delegation depth tracking — Prevents infinite recursion (max 2 levels)
- Agent lifecycle management — Creates, spawns, and tracks child agents
- Parent wake-up coordination — Notifies parent agents when children complete
- Wait mode handling — Supports
immediateandafter_alldelegation patterns
Coordination Tools
Provides 12 coordination tools for multi-agent collaboration (src/core/tools/agent-tools.ts:4-23):
Core tools (6):
listAgents— List agents in a workspacereadAgentConversation— Read another agent’s conversationcreateAgent— Create ROUTA/CRAFTER/GATE agentsdelegate— Assign task to agentmessageAgent— Inter-agent messagingreportToParent— Completion report to parent
wakeOrCreateTaskAgent — Wake or create agent for task
8. sendMessageToTaskAgent — Message to task’s assigned agent
9. getAgentStatus — Agent status
10. getAgentSummary — Agent summary
Event subscription (2):
11. subscribeToEvents — Subscribe to workspace events
12. unsubscribeFromEvents — Unsubscribe
EventBus
A lightweight in-process pub/sub system for coordinating agent activities. Emits events like:TASK_ASSIGNED— Task delegated to agentREPORT_SUBMITTED— Agent completed and reported backAGENT_ERROR— Agent encountered an error
Storage Architecture
Three-Tier Storage Strategy
Storage Mode Selection Logic
Storage Mode Selection Logic
From
src/core/routa-system.ts:267-288:Workspace-Centric Data Model
Every agent, task, and note belongs to a workspace. This design enables:- Multi-project isolation
- GitHub virtual workspace imports (no local clone required)
- Workspace-scoped agent collaboration
Delegation Depth Tracking
To prevent unbounded recursive agent creation, Routa enforces a maximum delegation depth of 2 levels (src/core/orchestration/delegation-depth.ts:17-21):
- Depth 0: User-created agents (no delegation)
- Depth 1: First-level delegated agents (children of user-created agents)
- Depth 2: Second-level delegated agents (grandchildren - maximum allowed)
Agent.metadata (src/core/orchestration/delegation-depth.ts:127-148):
CLI (Rust)
The desktop distribution includes arouta CLI built on the same routa-core logic as the Rust server:
Next Steps
Multi-Agent Coordination
Learn how agents collaborate through MCP tools
Specialist Roles
Understanding ROUTA, CRAFTER, GATE, and DEVELOPER roles
Task Orchestration
How tasks are created, delegated, and verified
Protocol Overview
Deep dive into MCP, ACP, and A2A protocols