# hummingbot/condor architecture

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

- Interactive diagram: https://gitdiagram.com/hummingbot/condor
- Repository: https://github.com/hummingbot/condor

## Overview

#### Purpose and entry points
Condor is a Python trading-control client for Hummingbot API: it monitors portfolios/bots, executes CEX/DEX actions through Hummingbot and Gateway, runs routines, and hosts LLM-driven trading agents. `main.py` is the process entry point, registering Telegram and application services; `condor/web/app.py` exposes the browser dashboard/API, consumed by the React entry point `frontend/src/main.tsx`. It supports explicit Telegram and local-dashboard modes.

#### Interaction surfaces and access boundary
Telegram command handling is organized by product domain under `handlers/`, while the web surface is a FastAPI-style route layer under `condor/web/routes/`. Both surfaces should converge on shared Condor services rather than independently implementing trading logic.
- `handlers/trading/router.py`
- `handlers/dex/router.py`
- `condor/web/routes/chat_ws.py`
- `condor/web/routes/portfolio.py`

Authentication, user ownership, server access, and local-mode behavior are material safety boundaries. Runtime confirmation and danger controls protect consequential agent/tool actions.
- `condor/web/auth.py`
- `utils/auth.py`
- `condor/runtime/confirmations.py`
- `condor/runtime/danger.py`

#### Hummingbot and market-data integration
The primary external control plane is Hummingbot API, accessed through typed fetchers for bots, executors, orders, positions, portfolios, connectors, and market data. Gateway is the DEX-facing boundary for wallets, tokens, pools, swaps, and CLMM positions. These modules isolate upstream API formats, pagination, validation, and error behavior from handlers and web routes.
- `condor/fetchers/market_data.py`
- `condor/fetchers/executors.py`
- `condor/fetchers/portfolio.py`
- `condor/fetchers/gateway_tokens.py`
- `condor/server_data_service.py`

Supporting upstreams include DEX candle/pool sources and Orca integration:
- `condor/dex_candles.py`
- `condor/pool_data.py`
- `condor/orca_api.py`

#### Agent runtime and LLM orchestration
The agent subsystem turns user requests into bounded sessions with prompts, strategy context, toolsets, streamed events, delegation, journals, risk checks, and shutdown behavior. Agent definitions are filesystem content: each domain agent supplies instructions, strategies, routines, and skills, while shared skills establish reusable operating procedures.
- `condor/agents/engine.py`
- `condor/agents/agent.py`
- `condor/runtime/sessions.py`
- `condor/runtime/events.py`
- `agents/directional_trader/AGENT.md`
- `agents/_shared/skills/strategy_builder/SKILL.md`

LLM providers support configured OpenAI-compatible endpoints and OpenRouter models:
- `condor/llm/custom_models.py`
- `condor/llm/openrouter_models.py`
- `condor/runtime/llm_client.py`

#### Automation, research, and reporting
Routines are discovered and scheduled Python workloads; they can run standalone or be initiated from an agent/chat context. Results can become persisted reports rendered by the backend and displayed in Telegram/web. Backtesting and code-running are adjacent controlled execution paths.
- `condor/routine_store.py`
- `condor/routine_hooks.py`
- `routines/base.py`
- `condor/reports/builder.py`
- `condor/backtesting.py`
- `condor/code_runner.py`

#### MCP integration boundary
Two MCP servers expose Condor’s agent, memory, routine, notification, and trading capabilities to external AI clients. The Hummingbot MCP server separately presents Hummingbot API operations with schemas and response formatters. This is an integration boundary requiring the same permissions and confirmation guarantees as native agent calls.
- `mcp_servers/condor/server.py`
- `mcp_servers/condor/tools/trading_agent.py`
- `mcp_servers/hummingbot_api/server.py`
- `mcp_servers/hummingbot_api/tools/trading.py`

#### State, deployment, and runtime infrastructure
Persistent local state covers configuration/preferences, agent memory, sessions, routine/report artifacts, caches, and telemetry outbox. The frontend is a Vite/React SPA using HTTP plus WebSockets/SSE for live chat, candles, bot, and market updates.
- `config_manager.py`
- `condor/persistence.py`
- `condor/memory/store.py`
- `condor/runtime/state.py`
- `condor/web/ws_manager.py`
- `frontend/src/App.tsx`

Production depends on Python, Telegram, Hummingbot API (typically Docker-hosted), Gateway/DEX connectors, optional LLM providers, and recommended Tailscale private networking. Telemetry is consent-controlled:
- `condor/telemetry/consent.py`
- `condor/telemetry/emitter.py`

Main entry points: [`condor/agents/engine.py`](https://github.com/hummingbot/condor/blob/main/condor/agents/engine.py) (Agent engine), [`condor/server_data_service.py`](https://github.com/hummingbot/condor/blob/main/condor/server_data_service.py) (Trading data service), [`condor/web/routes/chat_ws.py`](https://github.com/hummingbot/condor/blob/main/condor/web/routes/chat_ws.py) (Web routes), [`condor/persistence.py`](https://github.com/hummingbot/condor/blob/main/condor/persistence.py) (Local persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Interaction Surfaces"]
  node_telegram["Telegram handlers<br/>command routers<br/>[router.py]"]
  node_web["Web application<br/>FastAPI dashboard<br/>[app.py]"]
  node_web_routes["Web routes<br/>HTTP and WebSocket routes<br/>[chat_ws.py]"]
  node_frontend["React SPA<br/>Vite client<br/>[main.tsx]"]
end

subgraph group_core["Condor Runtime"]
  node_process["Process entry<br/>Python bootstrap<br/>[main.py]"]
  node_auth{{"Access control<br/>auth and ownership<br/>[auth.py]"}}
  node_agent_engine["Agent engine<br/>LLM orchestration<br/>[engine.py]"]
  node_sessions["Runtime sessions<br/>session and event runtime<br/>[sessions.py]"]
  node_safety{{"Action safety<br/>confirmation and danger controls<br/>[confirmations.py]"}}
  node_agent_content["Agent definitions<br/>filesystem prompts and skills<br/>[AGENT.md]"]
  node_routines["Routine automation<br/>discovery and hooks<br/>[routine_store.py]"]
  node_reports["Reports and controlled execution<br/>reporting and execution<br/>[builder.py]"]
  node_trading_data["Trading data service<br/>typed upstream facade"]
end

subgraph group_integrations["External Integrations"]
  node_llm["LLM client<br/>provider abstraction<br/>[llm_client.py]"]
  node_hummingbot{{"Hummingbot API<br/>trading control plane"}}
  node_gateway{{"Gateway and DEX<br/>DEX control plane<br/>[gateway_tokens.py]"}}
  node_mcp["MCP servers<br/>external AI integration<br/>[server.py]"]
end

subgraph group_state["State &amp; Observability"]
  node_persistence[("Local persistence<br/>state and artifacts<br/>[persistence.py]")]
  node_realtime["Live updates<br/>WebSocket manager<br/>[ws_manager.py]"]
  node_telemetry["Consent telemetry<br/>telemetry outbox<br/>[emitter.py]"]
end

node_process -->|"registers"| node_telegram
node_process -->|"starts"| node_web
node_telegram -->|"authorizes"| node_auth
node_web -->|"mounts"| node_web_routes
node_web_routes -->|"authorizes"| node_auth
node_frontend -->|"HTTP"| node_web
node_frontend -->|"WebSocket/SSE"| node_realtime
node_telegram -->|"requests"| node_agent_engine
node_web_routes -->|"chat requests"| node_agent_engine
node_agent_engine -->|"creates"| node_sessions
node_agent_engine -->|"loads"| node_agent_content
node_agent_engine -->|"invokes"| node_llm
node_agent_engine -->|"gates tools"| node_safety
node_agent_engine -->|"initiates"| node_routines
node_routines -->|"produces"| node_reports
node_agent_engine -->|"uses tools"| node_trading_data
node_web_routes -->|"portfolio data"| node_trading_data
node_trading_data -->|"typed API calls"| node_hummingbot
node_trading_data -->|"DEX operations"| node_gateway
node_mcp -->|"agent capabilities"| node_agent_engine
node_mcp -->|"trading schemas"| node_trading_data
node_mcp -->|"same safeguards"| node_safety
node_sessions -->|"stores state"| node_persistence
node_routines -->|"stores artifacts"| node_persistence
node_reports -->|"persists reports"| node_persistence
node_sessions -->|"streams events"| node_realtime
node_telemetry -->|"consent and outbox"| node_persistence

click node_process "https://github.com/hummingbot/condor/blob/main/main.py"
click node_telegram "https://github.com/hummingbot/condor/blob/main/handlers/trading/router.py"
click node_web "https://github.com/hummingbot/condor/blob/main/condor/web/app.py"
click node_web_routes "https://github.com/hummingbot/condor/blob/main/condor/web/routes/chat_ws.py"
click node_frontend "https://github.com/hummingbot/condor/blob/main/frontend/src/main.tsx"
click node_auth "https://github.com/hummingbot/condor/blob/main/condor/web/auth.py"
click node_agent_engine "https://github.com/hummingbot/condor/blob/main/condor/agents/engine.py"
click node_sessions "https://github.com/hummingbot/condor/blob/main/condor/runtime/sessions.py"
click node_safety "https://github.com/hummingbot/condor/blob/main/condor/runtime/confirmations.py"
click node_agent_content "https://github.com/hummingbot/condor/blob/main/agents/directional_trader/AGENT.md"
click node_llm "https://github.com/hummingbot/condor/blob/main/condor/runtime/llm_client.py"
click node_routines "https://github.com/hummingbot/condor/blob/main/condor/routine_store.py"
click node_reports "https://github.com/hummingbot/condor/blob/main/condor/reports/builder.py"
click node_trading_data "https://github.com/hummingbot/condor/blob/main/condor/server_data_service.py"
click node_gateway "https://github.com/hummingbot/condor/blob/main/condor/fetchers/gateway_tokens.py"
click node_mcp "https://github.com/hummingbot/condor/blob/main/mcp_servers/condor/server.py"
click node_persistence "https://github.com/hummingbot/condor/blob/main/condor/persistence.py"
click node_realtime "https://github.com/hummingbot/condor/blob/main/condor/web/ws_manager.py"
click node_telemetry "https://github.com/hummingbot/condor/blob/main/condor/telemetry/emitter.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_telegram,node_web,node_web_routes,node_frontend toneBlue
class node_process,node_auth,node_agent_engine,node_sessions,node_safety,node_agent_content,node_routines,node_reports,node_trading_data toneAmber
class node_llm,node_hummingbot,node_gateway,node_mcp toneMint
class node_persistence,node_realtime,node_telemetry toneRose
```

## Components

### Interaction Surfaces

- [Telegram handlers](https://github.com/hummingbot/condor/blob/main/handlers/trading/router.py): command routers · `handlers/trading/router.py`
- [Web application](https://github.com/hummingbot/condor/blob/main/condor/web/app.py): FastAPI dashboard · `condor/web/app.py`
- [Web routes](https://github.com/hummingbot/condor/blob/main/condor/web/routes/chat_ws.py): HTTP and WebSocket routes · `condor/web/routes/chat_ws.py`
- [React SPA](https://github.com/hummingbot/condor/blob/main/frontend/src/main.tsx): Vite client · Consumes dashboard HTTP and live-update endpoints. · `frontend/src/main.tsx`

### Condor Runtime

- [Process entry](https://github.com/hummingbot/condor/blob/main/main.py): Python bootstrap · Registers application and Telegram services. · `main.py`
- [Access control](https://github.com/hummingbot/condor/blob/main/condor/web/auth.py): auth and ownership · Enforces authentication, ownership, server access, and local mode. · `condor/web/auth.py`
- [Agent engine](https://github.com/hummingbot/condor/blob/main/condor/agents/engine.py): LLM orchestration · Builds bounded agent sessions, tools, delegation, and strategy context. · `condor/agents/engine.py`
- [Runtime sessions](https://github.com/hummingbot/condor/blob/main/condor/runtime/sessions.py): session and event runtime · Streams lifecycle events and maintains agent session state. · `condor/runtime/sessions.py`
- [Action safety](https://github.com/hummingbot/condor/blob/main/condor/runtime/confirmations.py): confirmation and danger controls · Gates consequential agent and tool actions. · `condor/runtime/confirmations.py`
- [Agent definitions](https://github.com/hummingbot/condor/blob/main/agents/directional_trader/AGENT.md): filesystem prompts and skills · Domain instructions, strategies, routines, and reusable skills. · `agents/directional_trader/AGENT.md`
- [Routine automation](https://github.com/hummingbot/condor/blob/main/condor/routine_store.py): discovery and hooks · Schedules standalone or agent-initiated Python workloads. · `condor/routine_store.py`
- [Reports and controlled execution](https://github.com/hummingbot/condor/blob/main/condor/reports/builder.py): reporting and execution · Builds persisted reports alongside backtesting and code-running paths. · `condor/reports/builder.py`
- [Trading data service](https://github.com/hummingbot/condor/blob/main/condor/server_data_service.py): typed upstream facade · Normalizes bots, orders, positions, portfolios, connectors, and market data. · `condor/server_data_service.py`

### External Integrations

- [LLM client](https://github.com/hummingbot/condor/blob/main/condor/runtime/llm_client.py): provider abstraction · Uses configured OpenAI-compatible and OpenRouter models. · `condor/runtime/llm_client.py`
- **Hummingbot API**: trading control plane
- [Gateway and DEX](https://github.com/hummingbot/condor/blob/main/condor/fetchers/gateway_tokens.py): DEX control plane · Provides wallets, tokens, pools, swaps, and CLMM positions. · `condor/fetchers/gateway_tokens.py`
- [MCP servers](https://github.com/hummingbot/condor/blob/main/mcp_servers/condor/server.py): external AI integration · Exposes Condor and Hummingbot trading capabilities to AI clients. · `mcp_servers/condor/server.py`

### State & Observability

- [Local persistence](https://github.com/hummingbot/condor/blob/main/condor/persistence.py): state and artifacts · Stores preferences, memory, sessions, routine/report artifacts, and caches. · `condor/persistence.py`
- [Live updates](https://github.com/hummingbot/condor/blob/main/condor/web/ws_manager.py): WebSocket manager · Publishes chat, candle, bot, and market updates. · `condor/web/ws_manager.py`
- [Consent telemetry](https://github.com/hummingbot/condor/blob/main/condor/telemetry/emitter.py): telemetry outbox · Emits telemetry only under user consent. · `condor/telemetry/emitter.py`

## Connections

- Process entry → Telegram handlers: registers
- Process entry → Web application: starts
- Telegram handlers → Access control: authorizes
- Web application → Web routes: mounts
- Web routes → Access control: authorizes
- React SPA → Web application: HTTP
- React SPA → Live updates: WebSocket/SSE
- Telegram handlers → Agent engine: requests
- Web routes → Agent engine: chat requests
- Agent engine → Runtime sessions: creates
- Agent engine → Agent definitions: loads
- Agent engine → LLM client: invokes
- Agent engine → Action safety: gates tools
- Agent engine → Routine automation: initiates
- Routine automation → Reports and controlled execution: produces
- Agent engine → Trading data service: uses tools
- Web routes → Trading data service: portfolio data
- Trading data service → Hummingbot API: typed API calls
- Trading data service → Gateway and DEX: DEX operations
- MCP servers → Agent engine: agent capabilities
- MCP servers → Trading data service: trading schemas
- MCP servers → Action safety: same safeguards
- Runtime sessions → Local persistence: stores state
- Routine automation → Local persistence: stores artifacts
- Reports and controlled execution → Local persistence: persists reports
- Runtime sessions → Live updates: streams events
- Consent telemetry → Local persistence: consent and outbox
