Architecture
How it works
10 loops covering the full revenue lifecycle: inbound lead processing and outbound signal-driven prospecting. Every process is version-controlled, testable code. Every decision is explainable.
System Architecture
The full platform: four interfaces (Salesforce for the field, Claude + MCP for conversational BI, Claude Code + MCP for dev/ops, Hex for static + ad-hoc BI), API layer, workflow engine, and external services.
Lead Creation Flow (End-to-End)
When a lead is created in Salesforce: Generate enriches via PDL (synchronous), scores, then hands to the territory-aware Route loop, and Engage composes a personalized email sequence with a task on the Lead.
Route Resolution
The shared rule evaluator behind POST /api/loops/route/resolve. Rules in rules.yaml are walked in priority order; the first matching rule's action dispatches to a handler that resolves to a Salesforce ownerId. The diagram shows the shape of what's possible — any number of rules of any type can compose. The same engine powers preview_routing for simulation and assign_territories for accounts — one codebase, multiple callers.
Opportunity Flow: Pursue Deal
When a lead converts to an opportunity: Pursue selects a deal play and creates milestone tasks with staggered due dates.
Deploy Loop: Territory Management
Salesforce Enterprise Territory Management is wired up as the org substrate for routing. The hierarchy + roles live in config/design/ (Design owns the strategic structure); SF match rules + assignments + pools live under config/deploy/. Two MCP tools reconcile to Salesforce: sync_territories writes the tree + user assignments, assign_territories matches accounts to patches using a deterministic engine with Claude Haiku + web_search agent fallback for ambiguous geography. Low-confidence matches land in pending:* sentinel states, surfaced for review via list_pending_territories.
Design Loop: Capacity Model + Scenarios
Strategic sibling to Deploy. Design owns target productivity per (motion archetype × segment × territory), ramp curves, roster, and annual targets. A scenario is a complete, sharable plan — lives at config/design/scenarios/{id}.yaml and declares its own roster, targets, and target_productivity. The live plan is whatever capacity_config.active_scenario points to; promoting a scenario is a one-line commit. Modeling is Python on Modal; TS is a thin IO + scenario-resolution proxy. (Renamed from Plan loop 2026-04-27 per Revenue Loops v0.1.)
MCP Tools: Natural Language Operations
Ops and reps interact with the system via Claude Code + MCP. 37 tools across 5 role tiers (9 rep, +3 manager, +0 leadership with wider scope, +23 ops, +2 eng). Arrows point from the broader role to the narrower one: eng ⊃ ops ⊃ leadership ⊃ manager ⊃ rep — eng sees everything. The tools below each tier are representative examples; the full catalog lives in docs/PRODUCT.md §6.
Signal-Driven Outbound
100 target accounts scanned by Claude Haiku + web search (1 per tick, every 5 min). Detected signals flow through Generate Outbound Signal for territory matching and scoring, then to Engage for AI-composed outreach with signal-specific plays.