# ashishu23/orchestra-ai architecture

> Architecture diagram of the GitHub repository ashishu23/orchestra-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashishu23/orchestra-ai
- Repository: https://github.com/ashishu23/orchestra-ai

## Overview

1. **System shape**
   Orchestra AI is a three-service distributed system: an **Orchestrator** coordinates reasoning, a **Knowledge-Vault MCP** service handles document retrieval, and an **Executive-Sandbox MCP** service handles isolated Python execution. A separate **Qdrant** vector database stores the indexed corpus. The core architectural boundary is that the LLM-driven orchestrator never talks to Qdrant or user code directly; it only calls typed MCP tools over HTTP.

2. **Orchestrator as control plane**
   The `orchestrator/` service is the central API and workflow engine. It exposes `POST /research`, `GET /health`, and `GET /metrics` via FastAPI, and internally runs a LangGraph state machine. The graph is built around a shared `OrchestraState` and moves through planner, executor, critic, correction, and synthesizer phases.

3. **Agent responsibilities**
   The orchestrator’s agents are cleanly separated: `planner.py` turns a user query into a bounded JSON step plan, `executor.py` dispatches each step to an MCP tool, and `critic.py` evaluates whether results are grounded enough to pass. The graph can route from critic to correction and retry, which creates a self-correcting loop rather than a one-shot RAG pipeline.

4. **Tool access boundary via MCP**
   All external capabilities are accessed through the `orchestrator/mcp/` clients. `client.py` is the generic JSON-RPC 2.0 transport, while `vault_client.py` and `sandbox_client.py` are typed wrappers for the two MCP servers. This means the orchestration layer sees structured tool schemas, not direct service internals.

5. **Knowledge-Vault as retrieval subsystem**
   The `knowledge-vault/` service is a FastMCP server that wraps Qdrant-based retrieval. It provides semantic search, keyword search, hybrid search, and ingestion tools. Its internal `rag/` package forms a pipeline from raw document text or PDFs to chunks, embeddings, Qdrant upserts, and query-time rank fusion.

6. **Retrieval data flow**
   Ingestion flows from `ingestion/ingest_cli.py` or the vault MCP ingestion tools into `chunker.py`, then `embedder.py`, then `qdrant_store.py`. At query time, the vault can return dense vector results, sparse keyword results, or a hybrid mix fused with Reciprocal Rank Fusion in `rrf.py`. This is the repository’s main retrieval plane.

7. **Executive-Sandbox as execution subsystem**
   The `executive-sandbox/` service is the isolated computation plane for verifying numerical or programmatic claims. It exposes a single MCP tool, `execute_python`, which runs code through `sandbox/runner.py`. Execution happens in a fresh child process with resource limits and restricted builtins, so the orchestrator can validate calculations without embedding arbitrary execution in its own process.

8. **Data stores and persistence**
   Qdrant is the only durable application data store in the architecture. It is deployed as a StatefulSet with persistent storage, and it holds the `research_docs` collection with both dense and sparse representations. The other services are stateless beyond request-scoped state and local process isolation.

9. **Security and isolation boundaries**
   Security is enforced at several layers: MCP schemas constrain what the orchestrator can ask for, the sandbox container runs non-root with dropped capabilities, and Kubernetes NetworkPolicy blocks all sandbox egress. That combination prevents direct DB access from the LLM path and prevents sandboxed code from reaching the network or other internal services.

10. **Deployment topology**
   The repository supports both local and Kubernetes deployment. `docker-compose.yml` wires the four runtime services together for local development, while `helm/orchestra/` defines the production/minikube deployment: namespace, secrets, services, deployments, Qdrant StatefulSet, and network policies. The deployment is designed as isolated microservices rather than a monolith.

11. **Operational concerns**
   The orchestrator exposes Prometheus metrics for request volume, self-corrections, and verified chunks, making retrieval quality and retry behavior visible. The sandbox also has an HPA in Kubernetes, reflecting that execution workload can scale independently from orchestration and retrieval.

12. **Testing and code organization**
   Each subsystem has targeted tests: graph behavior and MCP client behavior in `orchestrator/tests`, retrieval and chunking behavior in `knowledge-vault/tests`, and subprocess safety/timeout behavior in `executive-sandbox/tests`. This mirrors the architecture: workflow logic, retrieval logic, and execution isolation are validated separately.

Main entry points: [`helm/orchestra`](https://github.com/ashishu23/orchestra-ai/tree/main/helm/orchestra) (Helm Chart), [`knowledge-vault/main.py`](https://github.com/ashishu23/orchestra-ai/blob/main/knowledge-vault/main.py) (Knowledge Vault), [`docker-compose.yml`](https://github.com/ashishu23/orchestra-ai/blob/main/docker-compose.yml) (Local Compose), [`executive-sandbox/main.py`](https://github.com/ashishu23/orchestra-ai/blob/main/executive-sandbox/main.py) (Executive Sandbox)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control_plane["Control Plane"]
  node_orchestrator_api["Orchestrator API<br/>FastAPI service<br/>[main.py]"]
  node_orchestrator_graph{{"Agent Graph<br/>LangGraph workflow<br/>[graph.py]"}}
  node_orchestrator_state["Orchestra State<br/>shared state<br/>[state.py]"]
  node_planner_agent["Planner<br/>planning agent<br/>[planner.py]"]
  node_executor_agent["Executor<br/>tool dispatch agent<br/>[executor.py]"]
  node_critic_agent["Critic<br/>verification agent<br/>[critic.py]"]
  node_mcp_client["MCP Client<br/>JSON-RPC transport<br/>[client.py]"]
  node_vault_client["Vault Client<br/>typed MCP client<br/>[vault_client.py]"]
  node_sandbox_client["Sandbox Client<br/>typed MCP client<br/>[sandbox_client.py]"]
end

subgraph group_retrieval_plane["Retrieval Plane"]
  node_vault_service["Knowledge Vault<br/>FastMCP service<br/>[main.py]"]
  node_vault_rag{{"RAG Pipeline<br/>retrieval pipeline"}}
  node_ingest_cli["Ingest CLI<br/>ingestion entrypoint<br/>[ingest_cli.py]"]
end

subgraph group_execution_plane["Execution Plane"]
  node_sandbox_service["Executive Sandbox<br/>FastMCP service<br/>[main.py]"]
  node_sandbox_runner{{"Sandbox Runner<br/>process runner<br/>[runner.py]"}}
end

subgraph group_platform["Platform"]
  node_qdrant_store[("Qdrant Store<br/>vector datastore<br/>[statefulset.yaml]")]
  node_deployment_local["Local Compose<br/>dev deployment<br/>[docker-compose.yml]"]
  node_deployment_helm["Helm Chart<br/>k8s deployment"]
  node_network_policy["Network Policy<br/>cluster security"]
end

node_orchestrator_api -->|"runs"| node_orchestrator_graph
node_orchestrator_graph -->|"mutates"| node_orchestrator_state
node_orchestrator_graph -->|"starts with"| node_planner_agent
node_planner_agent -->|"hands off"| node_executor_agent
node_executor_agent -->|"submits results"| node_critic_agent
node_critic_agent -.->|"corrects"| node_planner_agent
node_executor_agent -->|"uses"| node_mcp_client
node_mcp_client -->|"wraps"| node_vault_client
node_mcp_client -->|"wraps"| node_sandbox_client
node_vault_client -->|"calls"| node_vault_service
node_sandbox_client -->|"calls"| node_sandbox_service
node_vault_service -->|"uses"| node_vault_rag
node_ingest_cli -->|"feeds"| node_vault_rag
node_vault_rag -->|"indexes into"| node_qdrant_store
node_vault_service -->|"queries"| node_qdrant_store
node_sandbox_service -->|"executes via"| node_sandbox_runner
node_sandbox_runner -.->|"constrained by"| node_network_policy
node_deployment_local -->|"includes"| node_orchestrator_api
node_deployment_local -->|"includes"| node_vault_service
node_deployment_local -->|"includes"| node_sandbox_service
node_deployment_local -->|"includes"| node_qdrant_store
node_deployment_helm -->|"deploys"| node_orchestrator_api
node_deployment_helm -->|"deploys"| node_vault_service
node_deployment_helm -->|"deploys"| node_sandbox_service
node_deployment_helm -->|"deploys"| node_qdrant_store
node_deployment_helm -->|"defines"| node_network_policy

click node_orchestrator_api "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/main.py"
click node_orchestrator_graph "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/graph.py"
click node_orchestrator_state "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/state.py"
click node_planner_agent "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/planner.py"
click node_executor_agent "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/executor.py"
click node_critic_agent "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/critic.py"
click node_mcp_client "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/client.py"
click node_vault_client "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/vault_client.py"
click node_sandbox_client "https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/sandbox_client.py"
click node_vault_service "https://github.com/ashishu23/orchestra-ai/blob/main/knowledge-vault/main.py"
click node_vault_rag "https://github.com/ashishu23/orchestra-ai/tree/main/knowledge-vault/rag"
click node_ingest_cli "https://github.com/ashishu23/orchestra-ai/blob/main/ingestion/ingest_cli.py"
click node_qdrant_store "https://github.com/ashishu23/orchestra-ai/blob/main/helm/orchestra/templates/qdrant/statefulset.yaml"
click node_sandbox_service "https://github.com/ashishu23/orchestra-ai/blob/main/executive-sandbox/main.py"
click node_sandbox_runner "https://github.com/ashishu23/orchestra-ai/blob/main/executive-sandbox/sandbox/runner.py"
click node_deployment_local "https://github.com/ashishu23/orchestra-ai/blob/main/docker-compose.yml"
click node_deployment_helm "https://github.com/ashishu23/orchestra-ai/tree/main/helm/orchestra"
click node_network_policy "https://github.com/ashishu23/orchestra-ai/tree/main/helm/orchestra/templates/network-policy"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_orchestrator_api,node_orchestrator_graph,node_orchestrator_state,node_planner_agent,node_executor_agent,node_critic_agent,node_mcp_client,node_vault_client,node_sandbox_client toneBlue
class node_vault_service,node_vault_rag,node_ingest_cli toneAmber
class node_sandbox_service,node_sandbox_runner toneMint
class node_qdrant_store,node_deployment_local,node_deployment_helm,node_network_policy toneRose
```

## Components

### Control Plane

LLM orchestration, planning, and MCP client boundary.

- [Orchestrator API](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/main.py): FastAPI service · Exposes research, health, and metrics endpoints. · `orchestrator/main.py`
- [Agent Graph](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/graph.py): LangGraph workflow · Coordinates planner, executor, critic, correction, and synthesis phases. · `orchestrator/agents/graph.py`
- [Orchestra State](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/state.py): shared state · State object passed through the orchestration loop. · `orchestrator/agents/state.py`
- [Planner](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/planner.py): planning agent · Turns a query into a bounded step plan. · `orchestrator/agents/planner.py`
- [Executor](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/executor.py): tool dispatch agent · Calls typed MCP tools to execute each step. · `orchestrator/agents/executor.py`
- [Critic](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/agents/critic.py): verification agent · Checks grounding and decides whether to correct or continue. · `orchestrator/agents/critic.py`
- [MCP Client](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/client.py): JSON-RPC transport · Generic JSON-RPC 2.0 client used by typed wrappers. · `orchestrator/mcp/client.py`
- [Vault Client](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/vault_client.py): typed MCP client · Wrapper for retrieval and ingestion tools. · `orchestrator/mcp/vault_client.py`
- [Sandbox Client](https://github.com/ashishu23/orchestra-ai/blob/main/orchestrator/mcp/sandbox_client.py): typed MCP client · Wrapper for isolated code execution tools. · `orchestrator/mcp/sandbox_client.py`

### Retrieval Plane

Document ingestion, indexing, and hybrid search.

- [Knowledge Vault](https://github.com/ashishu23/orchestra-ai/blob/main/knowledge-vault/main.py): FastMCP service · Retrieval service exposing search and ingestion tools. · `knowledge-vault/main.py`
- [RAG Pipeline](https://github.com/ashishu23/orchestra-ai/tree/main/knowledge-vault/rag): retrieval pipeline · Chunks, embeds, stores, and ranks documents for search. · `knowledge-vault/rag`
- [Ingest CLI](https://github.com/ashishu23/orchestra-ai/blob/main/ingestion/ingest_cli.py): ingestion entrypoint · Loads raw documents into the retrieval pipeline. · `ingestion/ingest_cli.py`

### Execution Plane

Isolated Python execution for verification and computation.

- [Executive Sandbox](https://github.com/ashishu23/orchestra-ai/blob/main/executive-sandbox/main.py): FastMCP service · Isolated execution service exposing python execution. · `executive-sandbox/main.py`
- [Sandbox Runner](https://github.com/ashishu23/orchestra-ai/blob/main/executive-sandbox/sandbox/runner.py): process runner · Runs code in a fresh child process with limits. · `executive-sandbox/sandbox/runner.py`

### Platform

Local and Kubernetes deployment, storage, and security boundaries.

- [Qdrant Store](https://github.com/ashishu23/orchestra-ai/blob/main/helm/orchestra/templates/qdrant/statefulset.yaml): vector datastore · Durable dense and sparse corpus storage. · `helm/orchestra/templates/qdrant/statefulset.yaml`
- [Local Compose](https://github.com/ashishu23/orchestra-ai/blob/main/docker-compose.yml): dev deployment · Wires the runtime services together for local development. · `docker-compose.yml`
- [Helm Chart](https://github.com/ashishu23/orchestra-ai/tree/main/helm/orchestra): k8s deployment · Defines services, deployments, stateful storage, and policies. · `helm/orchestra`
- [Network Policy](https://github.com/ashishu23/orchestra-ai/tree/main/helm/orchestra/templates/network-policy): cluster security · Restricts sandbox egress and internal traffic boundaries. · `helm/orchestra/templates/network-policy`

## Connections

- Orchestrator API → Agent Graph: runs · Request handling hands off to the workflow graph.
- Agent Graph → Orchestra State: mutates · Graph nodes read and update shared orchestration state.
- Agent Graph → Planner: starts with · Initial phase creates a bounded plan.
- Planner → Executor: hands off · Plan items are executed step by step.
- Executor → Critic: submits results · Execution outputs are evaluated for grounding.
- Critic → Planner: corrects · Failed verification can route back for correction.
- Executor → MCP Client: uses · Tool calls go through the generic JSON-RPC transport.
- MCP Client → Vault Client: wraps · Typed wrapper for retrieval capabilities.
- MCP Client → Sandbox Client: wraps · Typed wrapper for execution capabilities.
- Vault Client → Knowledge Vault: calls · Orchestrator reaches retrieval tools over HTTP.
- Sandbox Client → Executive Sandbox: calls · Orchestrator reaches execution tools over HTTP.
- Knowledge Vault → RAG Pipeline: uses · Search and ingestion delegate to the retrieval pipeline.
- Ingest CLI → RAG Pipeline: feeds · CLI ingestion enters the chunk/embed/index flow.
- RAG Pipeline → Qdrant Store: indexes into · Chunks and embeddings are upserted into Qdrant.
- Knowledge Vault → Qdrant Store: queries · Semantic, keyword, and hybrid search hit the corpus store.
- Executive Sandbox → Sandbox Runner: executes via · Tool handler delegates to the isolated runner.
- Sandbox Runner → Network Policy: constrained by · Runner operates under egress restrictions and isolation.
- Local Compose → Orchestrator API: includes · Local development composition includes the orchestrator.
- Local Compose → Knowledge Vault: includes · Local development composition includes retrieval service.
- Local Compose → Executive Sandbox: includes · Local development composition includes execution service.
- Local Compose → Qdrant Store: includes · Local development composition includes the vector store.
- Helm Chart → Orchestrator API: deploys · Kubernetes manifests deploy the orchestrator service.
- Helm Chart → Knowledge Vault: deploys · Kubernetes manifests deploy the knowledge-vault service.
- Helm Chart → Executive Sandbox: deploys · Kubernetes manifests deploy the sandbox service.
- Helm Chart → Qdrant Store: deploys · Kubernetes manifests deploy persistent Qdrant storage.
- Helm Chart → Network Policy: defines · Cluster manifests include traffic restriction policies.
