# dabai-fu/travel_harness architecture

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

- Interactive diagram: https://gitdiagram.com/dabai-fu/travel_harness
- Repository: https://github.com/dabai-fu/travel_harness
- Video tour (about a minute): https://gitdiagram.com/dabai-fu/travel_harness/video

## Overview

PyTravel-Harness is a multi-tenant enterprise travel and budget-analysis assistant. An employee signs in and submits a request through the web workspace; the gateway authenticates the user, and the run manager routes the request into LangGraph workflows for trip planning and booking, policy questions, expense drafts, or budget insights. The workflows use LLMs and MCP integrations, with human confirmation for consequential actions, then stream results to the workspace. The graph includes key security, middleware, and persistence layers. The README documents several capabilities whose implementation was not sampled; those subsystem links are shown only where documented.

Main entry points: [`apps/agent_harness/runtime/run_manager.py`](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/run_manager.py) (Run manager), [`apps/agent_harness/graphs/master.py`](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/master.py) (Workflow graph), [`apps/agent_harness/runtime/mcp_client.py`](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/mcp_client.py) (MCP client), [`frontend/src/App.tsx`](https://github.com/dabai-fu/travel_harness/blob/main/frontend/src/App.tsx) (Web workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_workspace["Web workspace<br/>[App.tsx]"]
  node_chat_store["Chat store<br/>[chatStore.ts]"]
end

subgraph group_orchestration["Agent orchestration"]
  node_gateway["API gateway<br/>[main.py]"]
  node_chat_route["Chat route<br/>[chat.py]"]
  node_run_manager["Run manager<br/>[run_manager.py]"]
  node_router["Intent routing<br/>[l3_llm.py]"]
  node_trip["Trip planning<br/>[trip_plan_book.py]"]
  node_policy["Policy answers<br/>[policy_info.py]"]
  node_expense["Expense drafts<br/>[expense_draft.py]"]
  node_budget["Budget insights<br/>[budget_insight.py]"]
  node_master["Workflow graph<br/>[master.py]"]
  node_llm["LLM client<br/>[llm_client.py]"]
end

subgraph group_integrations["Enterprise integrations"]
  node_mcp_client["MCP client<br/>[mcp_client.py]"]
  node_tuniu["Travel provider<br/>[tuniu_mcp.py]"]
  node_oa["OA service<br/>[oa_mcp.py]"]
  node_erp["Expense ERP<br/>[erp_expense_mcp.py]"]
  node_weather["Weather service<br/>[weather_mcp.py]"]
  node_sandbox["Isolated sandbox<br/>[docker_runner.py]"]
end

subgraph group_platform["Security and state"]
  node_auth["Authentication<br/>[auth.py]"]
  node_guardrails["Action guardrails<br/>[guardrails.py]"]
  node_tenant_context["Tenant context<br/>[tenant_context.py]"]
  node_pipeline["Middleware pipeline<br/>[pipeline.py]"]
  node_context["Context engineering"]
  node_services["Preference memory<br/>[services.py]"]
  node_state["Workflow state<br/>[state.py]"]
  node_db[("PostgreSQL<br/>[db.py]")]
  node_redis[("Redis<br/>[redis_client.py]")]
  node_circuit["Circuit breaker<br/>[circuit_breaker.py]"]
  node_cluster_cancel["Cluster cancellation<br/>[cluster_cancel.py]"]
end

node_employee(("Employee"))

node_employee -->|"uses"| node_workspace
node_workspace -->|"dispatches"| node_chat_store
node_workspace -->|"sends requests"| node_gateway
node_gateway -->|"registers"| node_auth
node_gateway -->|"registers"| node_chat_route
node_chat_route -->|"authenticates"| node_auth
node_chat_route -->|"starts run"| node_run_manager
node_run_manager -->|"routes query"| node_router
node_run_manager -->|"executes graph"| node_master
node_master -->|"dispatches"| node_trip
node_master -->|"dispatches"| node_policy
node_master -->|"dispatches"| node_expense
node_master -->|"dispatches"| node_budget
node_run_manager -->|"updates"| node_state
node_run_manager -->|"loads memory"| node_services
node_trip -->|"calls tools"| node_mcp_client
node_trip -->|"checks actions"| node_guardrails
node_mcp_client -->|"calls"| node_tuniu
node_mcp_client -->|"calls"| node_oa
node_mcp_client -->|"calls"| node_erp
node_mcp_client -->|"calls"| node_weather
node_erp -->|"runs analysis"| node_sandbox
node_run_manager -->|"invokes"| node_llm
node_llm -->|"prepares prompts"| node_pipeline
node_pipeline -->|"applies"| node_context
node_run_manager -->|"binds context"| node_tenant_context
node_auth -->|"loads identity"| node_db
node_auth -->|"checks session"| node_redis
node_run_manager -->|"persists conversation"| node_db
node_services -->|"reads preferences"| node_db
node_services -->|"caches preferences"| node_redis
node_tuniu -->|"uses breaker"| node_circuit
node_chat_route -->|"checks cancellation"| node_cluster_cancel
node_cluster_cancel -->|"stores markers"| node_redis
node_circuit -->|"stores state"| node_redis
node_run_manager -->|"streams results"| node_workspace
node_workspace -->|"shows results"| node_employee

click node_workspace "https://github.com/dabai-fu/travel_harness/blob/main/frontend/src/App.tsx"
click node_chat_store "https://github.com/dabai-fu/travel_harness/blob/main/frontend/src/store/chatStore.ts"
click node_gateway "https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/main.py"
click node_auth "https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/auth.py"
click node_chat_route "https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/routes/chat.py"
click node_run_manager "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/run_manager.py"
click node_router "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/router/l3_llm.py"
click node_trip "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/trip_plan_book.py"
click node_policy "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/policy_info.py"
click node_expense "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/expense_draft.py"
click node_budget "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/budget_insight.py"
click node_master "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/master.py"
click node_llm "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/llm_client.py"
click node_guardrails "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/guardrails.py"
click node_mcp_client "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/mcp_client.py"
click node_tuniu "https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/tuniu_mcp.py"
click node_oa "https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/oa_mcp.py"
click node_erp "https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/erp_expense_mcp.py"
click node_weather "https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/weather_mcp.py"
click node_sandbox "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/sandbox/docker_runner.py"
click node_tenant_context "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/tenant_context.py"
click node_pipeline "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/pipeline.py"
click node_context "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/context_engineering.py"
click node_services "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/services.py"
click node_state "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/state.py"
click node_db "https://github.com/dabai-fu/travel_harness/blob/main/apps/common/db.py"
click node_redis "https://github.com/dabai-fu/travel_harness/blob/main/apps/common/redis_client.py"
click node_circuit "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/circuit_breaker.py"
click node_cluster_cancel "https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/cluster_cancel.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_workspace,node_chat_store toneBlue
class node_gateway,node_chat_route,node_run_manager,node_router,node_trip,node_policy,node_expense,node_budget,node_master,node_llm toneAmber
class node_mcp_client,node_tuniu,node_oa,node_erp,node_weather,node_sandbox toneMint
class node_auth,node_guardrails,node_tenant_context,node_pipeline,node_context,node_services,node_state,node_db,node_redis,node_circuit,node_cluster_cancel toneRose
class node_employee toneIndigo
```

## Components

### User experience

- [Web workspace](https://github.com/dabai-fu/travel_harness/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat store](https://github.com/dabai-fu/travel_harness/blob/main/frontend/src/store/chatStore.ts): `frontend/src/store/chatStore.ts`

### Agent orchestration

- [API gateway](https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/main.py): `apps/api_gateway/main.py`
- [Chat route](https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/routes/chat.py): `apps/api_gateway/routes/chat.py`
- [Run manager](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/run_manager.py): `apps/agent_harness/runtime/run_manager.py`
- [Intent routing](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/router/l3_llm.py): `apps/agent_harness/router/l3_llm.py`
- [Trip planning](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/trip_plan_book.py): `apps/agent_harness/graphs/trip_plan_book.py`
- [Policy answers](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/policy_info.py): `apps/agent_harness/graphs/policy_info.py`
- [Expense drafts](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/expense_draft.py): `apps/agent_harness/graphs/expense_draft.py`
- [Budget insights](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/budget_insight.py): `apps/agent_harness/graphs/budget_insight.py`
- [Workflow graph](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/graphs/master.py): `apps/agent_harness/graphs/master.py`
- [LLM client](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/llm_client.py): `apps/agent_harness/runtime/llm_client.py`

### Enterprise integrations

- [MCP client](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/mcp_client.py): `apps/agent_harness/runtime/mcp_client.py`
- [Travel provider](https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/tuniu_mcp.py): `apps/mcp_servers/tuniu_mcp.py`
- [OA service](https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/oa_mcp.py): `apps/mcp_servers/oa_mcp.py`
- [Expense ERP](https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/erp_expense_mcp.py): `apps/mcp_servers/erp_expense_mcp.py`
- [Weather service](https://github.com/dabai-fu/travel_harness/blob/main/apps/mcp_servers/weather_mcp.py): `apps/mcp_servers/weather_mcp.py`
- [Isolated sandbox](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/sandbox/docker_runner.py): `apps/agent_harness/sandbox/docker_runner.py`

### Security and state

- [Authentication](https://github.com/dabai-fu/travel_harness/blob/main/apps/api_gateway/auth.py): `apps/api_gateway/auth.py`
- [Action guardrails](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/guardrails.py): `apps/agent_harness/runtime/guardrails.py`
- [Tenant context](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/tenant_context.py): `apps/agent_harness/middlewares/tenant_context.py`
- [Middleware pipeline](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/pipeline.py): `apps/agent_harness/middlewares/pipeline.py`
- [Context engineering](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/context_engineering.py): `apps/agent_harness/middlewares/context_engineering.py`
- [Preference memory](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/runtime/services.py): `apps/agent_harness/runtime/services.py`
- [Workflow state](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/state.py): `apps/agent_harness/state.py`
- [PostgreSQL](https://github.com/dabai-fu/travel_harness/blob/main/apps/common/db.py): `apps/common/db.py`
- [Redis](https://github.com/dabai-fu/travel_harness/blob/main/apps/common/redis_client.py): `apps/common/redis_client.py`
- [Circuit breaker](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/circuit_breaker.py): `apps/agent_harness/middlewares/circuit_breaker.py`
- [Cluster cancellation](https://github.com/dabai-fu/travel_harness/blob/main/apps/agent_harness/middlewares/cluster_cancel.py): `apps/agent_harness/middlewares/cluster_cancel.py`

### Other components

- **Employee**

## Connections

- Employee → Web workspace: uses (evidence: `README.md`)
- Web workspace → Chat store: dispatches (evidence: `frontend/src/App.tsx`)
- Web workspace → API gateway: sends requests (evidence: `README.md`)
- API gateway → Authentication: registers (evidence: `apps/api_gateway/main.py`)
- API gateway → Chat route: registers (evidence: `apps/api_gateway/main.py`)
- Chat route → Authentication: authenticates (evidence: `apps/api_gateway/routes/chat.py`)
- Chat route → Run manager: starts run (evidence: `apps/api_gateway/routes/chat.py`)
- Run manager → Intent routing: routes query (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Run manager → Workflow graph: executes graph (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Workflow graph → Trip planning: dispatches (evidence: `apps/agent_harness/graphs/master.py`)
- Workflow graph → Policy answers: dispatches (evidence: `apps/agent_harness/graphs/master.py`)
- Workflow graph → Expense drafts: dispatches (evidence: `apps/agent_harness/graphs/master.py`)
- Workflow graph → Budget insights: dispatches (evidence: `apps/agent_harness/graphs/master.py`)
- Run manager → Workflow state: updates (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Run manager → Preference memory: loads memory (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Trip planning → MCP client: calls tools (evidence: `apps/agent_harness/graphs/trip_plan_book.py`)
- Trip planning → Action guardrails: checks actions (evidence: `apps/agent_harness/graphs/trip_plan_book.py`)
- MCP client → Travel provider: calls (evidence: `apps/agent_harness/runtime/mcp_client.py`)
- MCP client → OA service: calls (evidence: `apps/agent_harness/runtime/mcp_client.py`)
- MCP client → Expense ERP: calls (evidence: `apps/agent_harness/runtime/mcp_client.py`)
- MCP client → Weather service: calls (evidence: `apps/agent_harness/runtime/mcp_client.py`)
- Expense ERP → Isolated sandbox: runs analysis (evidence: `apps/mcp_servers/erp_expense_mcp.py`)
- Run manager → LLM client: invokes (evidence: `apps/agent_harness/runtime/run_manager.py`)
- LLM client → Middleware pipeline: prepares prompts (evidence: `apps/agent_harness/runtime/llm_client.py`)
- Middleware pipeline → Context engineering: applies (evidence: `apps/agent_harness/middlewares/pipeline.py`)
- Run manager → Tenant context: binds context (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Authentication → PostgreSQL: loads identity (evidence: `apps/api_gateway/auth.py`)
- Authentication → Redis: checks session (evidence: `apps/api_gateway/auth.py`)
- Run manager → PostgreSQL: persists conversation (evidence: `apps/agent_harness/runtime/run_manager.py`)
- Preference memory → PostgreSQL: reads preferences (evidence: `apps/agent_harness/runtime/services.py`)
- Preference memory → Redis: caches preferences (evidence: `apps/agent_harness/runtime/services.py`)
- Travel provider → Circuit breaker: uses breaker (evidence: `apps/mcp_servers/tuniu_mcp.py`)
- Chat route → Cluster cancellation: checks cancellation (evidence: `apps/api_gateway/routes/chat.py`)
- Cluster cancellation → Redis: stores markers (evidence: `apps/agent_harness/middlewares/cluster_cancel.py`)
- Circuit breaker → Redis: stores state (evidence: `apps/agent_harness/middlewares/circuit_breaker.py`)
- Run manager → Web workspace: streams results (evidence: `README.md`)
- Web workspace → Employee: shows results (evidence: `README.md`)
