# oc8-ai/oc8 architecture

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

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

## Overview

oc8 is a self-hosted business-agent orchestration platform. Members configure agents with models, knowledge, tools, and autonomy boundaries; runs start from schedules, events, or chat, execute through governed tool calls, and pause for human approval when required. Results and actions are auditable and surfaced live. The graph emphasizes that run-and-govern workflow while retaining knowledge ingestion, agent/runtime isolation, extensible integrations, collaboration flows, and realtime visibility. Edges cite README statements or shown source references; unsampled subsystem wiring is omitted or marked unverified.

Main entry points: [`backend/src/oc8/agent/engine.py`](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/engine.py) (Agent loop), [`backend/src/oc8/runtime`](https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/runtime) (Run lifecycle), [`frontend/src/router.tsx`](https://github.com/oc8-ai/oc8/blob/main/frontend/src/router.tsx) (Web interface), [`backend/src/oc8/realtime/manager.py`](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/realtime/manager.py) (Live updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Product entry"]
  node_frontend["Web interface<br/>[router.tsx]"]
  node_api["Control API<br/>[main.py]"]
  node_agent_admin["Agent setup"]
  node_triggers["Run triggers"]
end

subgraph group_execution["Agent execution"]
  node_runtime["Run lifecycle"]
  node_agent_engine["Agent loop<br/>[engine.py]"]
  node_control_tools["Control tools<br/>[control_tools.py]"]
  node_mcp_client["MCP client<br/>[mcp_client.py]"]
  node_mcp_gateway["MCP gateway<br/>[mcp_gateway.py]"]
  node_model_router["Model routing<br/>[router.py]"]
  node_collab["Department flows<br/>[flow_engine.py]"]
end

subgraph group_governance["Governance"]
  node_harness["Safety harness<br/>[pipeline.py]"]
  node_approvals["Human approvals<br/>[service.py]"]
  node_audit["Audit trail<br/>[chain.py]"]
end

subgraph group_knowledge["Knowledge and integrations"]
  node_knowledge_ingest["Knowledge ingestion<br/>[ingest.py]"]
  node_knowledge_retrieval["Knowledge retrieval<br/>[retrieval.py]"]
  node_connectors["Capa integrations<br/>[base.py]"]
end

subgraph group_platform["Platform services"]
  node_realtime["Live updates<br/>[manager.py]"]
  node_data[("Tenant data<br/>[knowledge.py]")]
  node_sandbox["Isolated runtime<br/>[reaper.py]"]
end

node_member(("Member"))
node_external_systems["Business systems"]
node_human_approver(("Approver"))

node_member -->|"configures"| node_frontend
node_frontend -->|"uses REST/WS"| node_api
node_api -.->|"manages agents"| node_agent_admin
node_member -->|"starts runs"| node_triggers
node_triggers -.->|"dispatches"| node_runtime
node_runtime -.->|"executes"| node_agent_engine
node_agent_engine -->|"requests completion"| node_model_router
node_agent_engine -->|"applies checks"| node_harness
node_agent_engine -->|"offers tools"| node_control_tools
node_agent_engine -.->|"opens sessions"| node_mcp_client
node_mcp_client -.->|"calls gateway"| node_mcp_gateway
node_mcp_gateway -->|"dispatches tools"| node_external_systems
node_harness -->|"requests approval"| node_approvals
node_human_approver -->|"reviews"| node_approvals
node_agent_engine -->|"audits actions"| node_audit
node_knowledge_ingest -->|"syncs sources"| node_connectors
node_knowledge_ingest -->|"stores chunks"| node_data
node_agent_engine -->|"retrieves context"| node_knowledge_retrieval
node_knowledge_retrieval -.->|"reads knowledge"| node_data
node_collab -.->|"hands off work"| node_runtime
node_collab -->|"publishes events"| node_realtime
node_runtime -.->|"runs isolated"| node_sandbox
node_runtime -.->|"streams status"| node_realtime
node_realtime -->|"delivers updates"| node_frontend

click node_frontend "https://github.com/oc8-ai/oc8/blob/main/frontend/src/router.tsx"
click node_api "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/main.py"
click node_agent_admin "https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/agents"
click node_triggers "https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/triggers"
click node_runtime "https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/runtime"
click node_agent_engine "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/engine.py"
click node_harness "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/harness/pipeline.py"
click node_control_tools "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/control_tools.py"
click node_mcp_client "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/mcp_client.py"
click node_mcp_gateway "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/api/mcp_gateway.py"
click node_approvals "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/approvals/service.py"
click node_audit "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/audit/chain.py"
click node_knowledge_ingest "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/ingest.py"
click node_knowledge_retrieval "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/retrieval.py"
click node_connectors "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/connectors/base.py"
click node_model_router "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/modelrouter/router.py"
click node_collab "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/collab/flow_engine.py"
click node_realtime "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/realtime/manager.py"
click node_data "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/models/knowledge.py"
click node_sandbox "https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/sandbox/reaper.py"

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_frontend,node_api,node_agent_admin,node_triggers toneBlue
class node_runtime,node_agent_engine,node_control_tools,node_mcp_client,node_mcp_gateway,node_model_router,node_collab toneAmber
class node_harness,node_approvals,node_audit toneMint
class node_knowledge_ingest,node_knowledge_retrieval,node_connectors toneRose
class node_realtime,node_data,node_sandbox,node_member,node_external_systems,node_human_approver toneIndigo
```

## Components

### Product entry

- [Web interface](https://github.com/oc8-ai/oc8/blob/main/frontend/src/router.tsx): `frontend/src/router.tsx`
- [Control API](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/main.py): `backend/src/oc8/main.py`
- [Agent setup](https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/agents): `backend/src/oc8/agents`
- [Run triggers](https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/triggers): `backend/src/oc8/triggers`

### Agent execution

- [Run lifecycle](https://github.com/oc8-ai/oc8/tree/main/backend/src/oc8/runtime): `backend/src/oc8/runtime`
- [Agent loop](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/engine.py): `backend/src/oc8/agent/engine.py`
- [Control tools](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/control_tools.py): `backend/src/oc8/agent/control_tools.py`
- [MCP client](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/mcp_client.py): `backend/src/oc8/agent/mcp_client.py`
- [MCP gateway](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/api/mcp_gateway.py): `backend/src/oc8/api/mcp_gateway.py`
- [Model routing](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/modelrouter/router.py): `backend/src/oc8/modelrouter/router.py`
- [Department flows](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/collab/flow_engine.py): `backend/src/oc8/collab/flow_engine.py`

### Governance

- [Safety harness](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/agent/harness/pipeline.py): `backend/src/oc8/agent/harness/pipeline.py`
- [Human approvals](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/approvals/service.py): `backend/src/oc8/approvals/service.py`
- [Audit trail](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/audit/chain.py): `backend/src/oc8/audit/chain.py`

### Knowledge and integrations

- [Knowledge ingestion](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/ingest.py): `backend/src/oc8/knowledge/ingest.py`
- [Knowledge retrieval](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/retrieval.py): `backend/src/oc8/knowledge/retrieval.py`
- [Capa integrations](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/knowledge/connectors/base.py): `backend/src/oc8/knowledge/connectors/base.py`

### Platform services

- [Live updates](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/realtime/manager.py): `backend/src/oc8/realtime/manager.py`
- [Tenant data](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/models/knowledge.py): `backend/src/oc8/models/knowledge.py`
- [Isolated runtime](https://github.com/oc8-ai/oc8/blob/main/backend/src/oc8/sandbox/reaper.py): `backend/src/oc8/sandbox/reaper.py`

### Other components

- **Member**
- **Business systems**
- **Approver**

## Connections

- Member → Web interface: configures (evidence: `README.md`)
- Web interface → Control API: uses REST/WS (evidence: `README.md`)
- Control API → Agent setup: manages agents
- Member → Run triggers: starts runs (evidence: `README.md`)
- Run triggers → Run lifecycle: dispatches
- Run lifecycle → Agent loop: executes
- Agent loop → Model routing: requests completion (evidence: `backend/src/oc8/agent/engine.py`)
- Agent loop → Safety harness: applies checks (evidence: `backend/src/oc8/agent/engine.py`)
- Agent loop → Control tools: offers tools (evidence: `backend/src/oc8/agent/engine.py`)
- Agent loop → MCP client: opens sessions (evidence: `backend/src/oc8/agent/engine.py`)
- MCP client → MCP gateway: calls gateway
- MCP gateway → Business systems: dispatches tools (evidence: `README.md`)
- Safety harness → Human approvals: requests approval
- Approver → Human approvals: reviews (evidence: `README.md`)
- Agent loop → Audit trail: audits actions (evidence: `backend/src/oc8/agent/engine.py`)
- Knowledge ingestion → Capa integrations: syncs sources (evidence: `backend/src/oc8/knowledge/ingest.py`)
- Knowledge ingestion → Tenant data: stores chunks (evidence: `backend/src/oc8/knowledge/ingest.py`)
- Agent loop → Knowledge retrieval: retrieves context (evidence: `backend/src/oc8/agent/engine.py`)
- Knowledge retrieval → Tenant data: reads knowledge
- Department flows → Run lifecycle: hands off work (evidence: `backend/src/oc8/collab/flow_engine.py`)
- Department flows → Live updates: publishes events (evidence: `backend/src/oc8/collab/flow_engine.py`)
- Run lifecycle → Isolated runtime: runs isolated
- Run lifecycle → Live updates: streams status
- Live updates → Web interface: delivers updates (evidence: `README.md`)
