# hning86/adk_swarm architecture

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

- Interactive diagram: https://gitdiagram.com/hning86/adk_swarm
- Repository: https://github.com/hning86/adk_swarm
- Video tour (about a minute): https://gitdiagram.com/hning86/adk_swarm/video

## Overview

This is a Google ADK customer-support swarm. A customer message enters through the dispatcher, which selects a starting specialist; specialists then hand off directly to peers, share findings and proposals through session state, and return a response after consensus or escalate when the handoff limit is reached. The app also exposes ADK web/API and A2A surfaces, plus feedback logging. The source excerpts show the serving setup and core swarm/tool mechanics; specialist routing and several workflow details are additionally documented in the README.

Main entry points: [`app/agent.py`](https://github.com/hning86/adk_swarm/blob/main/app/agent.py) (Technical specialist), [`app/swarm.py`](https://github.com/hning86/adk_swarm/blob/main/app/swarm.py) (Swarm blackboard), [`app/fast_api_app.py`](https://github.com/hning86/adk_swarm/blob/main/app/fast_api_app.py) (FastAPI app), [`app/tools.py`](https://github.com/hning86/adk_swarm/blob/main/app/tools.py) (Billing tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Serving surfaces"]
  node_fastapi["FastAPI app<br/>[fast_api_app.py]"]
  node_a2a_routes["A2A routes<br/>[a2a.py]"]
  node_feedback["Feedback logging<br/>[fast_api_app.py]"]
  node_feedback_schema["Feedback schema<br/>[typing.py]"]
end

subgraph group_swarm["Swarm collaboration"]
  node_dispatcher["Triage dispatcher<br/>[agent.py]"]
  node_blackboard["Swarm blackboard<br/>[swarm.py]"]
  node_consensus["Proposal consensus<br/>[swarm.py]"]
  node_escalation["Handoff escalation<br/>[swarm.py]"]
end

subgraph group_domains["Support domains"]
  node_technical["Technical specialist<br/>[agent.py]"]
  node_billing["Billing specialist<br/>[agent.py]"]
  node_account["Account specialist<br/>[agent.py]"]
  node_tech_tools["Technical diagnostics<br/>[tools.py]"]
  node_billing_tools["Billing tools<br/>[tools.py]"]
  node_account_tools["Account policy tools<br/>[tools.py]"]
end

subgraph group_state["Shared state"]
  node_shared_services["Shared ADK services<br/>[services.py]"]
  node_session_state[("Session state")]
end

node_customer(("Customer"))
node_http_client(("Web/API client"))
node_a2a_client(("A2A client"))

node_customer -->|"sends inquiry"| node_dispatcher
node_dispatcher -->|"routes to start"| node_technical
node_dispatcher -->|"routes to start"| node_billing
node_dispatcher -->|"routes to start"| node_account
node_technical -->|"hands off"| node_billing
node_technical -->|"hands off"| node_account
node_billing -->|"hands off"| node_technical
node_billing -->|"hands off"| node_account
node_account -->|"hands off"| node_technical
node_account -->|"hands off"| node_billing
node_technical -->|"invokes tools"| node_tech_tools
node_billing -->|"invokes tools"| node_billing_tools
node_account -->|"invokes tools"| node_account_tools
node_technical -->|"shares findings"| node_blackboard
node_billing -->|"shares findings"| node_blackboard
node_account -->|"shares findings"| node_blackboard
node_tech_tools -->|"records findings"| node_blackboard
node_billing_tools -->|"records findings"| node_blackboard
node_account_tools -->|"records findings"| node_blackboard
node_technical -->|"proposes or reviews"| node_consensus
node_billing -->|"proposes or reviews"| node_consensus
node_account -->|"proposes or reviews"| node_consensus
node_consensus -->|"updates proposal"| node_blackboard
node_billing_tools -->|"requires consensus"| node_consensus
node_account_tools -->|"requires consensus"| node_consensus
node_technical -->|"exceeds handoff cap"| node_escalation
node_billing -->|"exceeds handoff cap"| node_escalation
node_account -->|"exceeds handoff cap"| node_escalation
node_escalation -->|"summarizes state"| node_blackboard
node_http_client -->|"calls API"| node_fastapi
node_a2a_client -->|"sends JSON-RPC"| node_a2a_routes
node_fastapi -->|"registers routes"| node_a2a_routes
node_fastapi -->|"loads agent"| node_dispatcher
node_fastapi -->|"configures services"| node_shared_services
node_a2a_routes -->|"executes agent"| node_dispatcher
node_shared_services -->|"provides sessions"| node_session_state
node_feedback_schema -->|"validates payload"| node_feedback
node_http_client -->|"submits feedback"| node_feedback

click node_fastapi "https://github.com/hning86/adk_swarm/blob/main/app/fast_api_app.py"
click node_a2a_routes "https://github.com/hning86/adk_swarm/blob/main/app/app_utils/a2a.py"
click node_feedback "https://github.com/hning86/adk_swarm/blob/main/app/fast_api_app.py"
click node_dispatcher "https://github.com/hning86/adk_swarm/blob/main/app/agent.py"
click node_technical "https://github.com/hning86/adk_swarm/blob/main/app/agent.py"
click node_billing "https://github.com/hning86/adk_swarm/blob/main/app/agent.py"
click node_account "https://github.com/hning86/adk_swarm/blob/main/app/agent.py"
click node_tech_tools "https://github.com/hning86/adk_swarm/blob/main/app/tools.py"
click node_billing_tools "https://github.com/hning86/adk_swarm/blob/main/app/tools.py"
click node_account_tools "https://github.com/hning86/adk_swarm/blob/main/app/tools.py"
click node_blackboard "https://github.com/hning86/adk_swarm/blob/main/app/swarm.py"
click node_consensus "https://github.com/hning86/adk_swarm/blob/main/app/swarm.py"
click node_escalation "https://github.com/hning86/adk_swarm/blob/main/app/swarm.py"
click node_shared_services "https://github.com/hning86/adk_swarm/blob/main/app/app_utils/services.py"
click node_feedback_schema "https://github.com/hning86/adk_swarm/blob/main/app/app_utils/typing.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_fastapi,node_a2a_routes,node_feedback,node_feedback_schema,node_http_client,node_a2a_client toneBlue
class node_dispatcher,node_blackboard,node_consensus,node_escalation toneAmber
class node_technical,node_billing,node_account,node_tech_tools,node_billing_tools,node_account_tools toneMint
class node_shared_services,node_session_state toneRose
class node_customer toneIndigo
```

## Components

### Serving surfaces

- [FastAPI app](https://github.com/hning86/adk_swarm/blob/main/app/fast_api_app.py): `app/fast_api_app.py`
- [A2A routes](https://github.com/hning86/adk_swarm/blob/main/app/app_utils/a2a.py): `app/app_utils/a2a.py`
- [Feedback logging](https://github.com/hning86/adk_swarm/blob/main/app/fast_api_app.py): `app/fast_api_app.py`
- [Feedback schema](https://github.com/hning86/adk_swarm/blob/main/app/app_utils/typing.py): `app/app_utils/typing.py`

### Swarm collaboration

- [Triage dispatcher](https://github.com/hning86/adk_swarm/blob/main/app/agent.py): `app/agent.py`
- [Swarm blackboard](https://github.com/hning86/adk_swarm/blob/main/app/swarm.py): `app/swarm.py`
- [Proposal consensus](https://github.com/hning86/adk_swarm/blob/main/app/swarm.py): `app/swarm.py`
- [Handoff escalation](https://github.com/hning86/adk_swarm/blob/main/app/swarm.py): `app/swarm.py`

### Support domains

- [Technical specialist](https://github.com/hning86/adk_swarm/blob/main/app/agent.py): `app/agent.py`
- [Billing specialist](https://github.com/hning86/adk_swarm/blob/main/app/agent.py): `app/agent.py`
- [Account specialist](https://github.com/hning86/adk_swarm/blob/main/app/agent.py): `app/agent.py`
- [Technical diagnostics](https://github.com/hning86/adk_swarm/blob/main/app/tools.py): `app/tools.py`
- [Billing tools](https://github.com/hning86/adk_swarm/blob/main/app/tools.py): `app/tools.py`
- [Account policy tools](https://github.com/hning86/adk_swarm/blob/main/app/tools.py): `app/tools.py`

### Shared state

- [Shared ADK services](https://github.com/hning86/adk_swarm/blob/main/app/app_utils/services.py): `app/app_utils/services.py`
- **Session state**

### Other components

- **Customer**
- **Web/API client**
- **A2A client**

## Connections

- Customer → Triage dispatcher: sends inquiry (evidence: `README.md`)
- Triage dispatcher → Technical specialist: routes to start (evidence: `README.md`)
- Triage dispatcher → Billing specialist: routes to start (evidence: `README.md`)
- Triage dispatcher → Account specialist: routes to start (evidence: `README.md`)
- Technical specialist → Billing specialist: hands off (evidence: `README.md`)
- Technical specialist → Account specialist: hands off (evidence: `README.md`)
- Billing specialist → Technical specialist: hands off (evidence: `README.md`)
- Billing specialist → Account specialist: hands off (evidence: `README.md`)
- Account specialist → Technical specialist: hands off (evidence: `README.md`)
- Account specialist → Billing specialist: hands off (evidence: `README.md`)
- Technical specialist → Technical diagnostics: invokes tools (evidence: `app/agent.py`)
- Billing specialist → Billing tools: invokes tools (evidence: `app/agent.py`)
- Account specialist → Account policy tools: invokes tools (evidence: `app/agent.py`)
- Technical specialist → Swarm blackboard: shares findings (evidence: `README.md`)
- Billing specialist → Swarm blackboard: shares findings (evidence: `README.md`)
- Account specialist → Swarm blackboard: shares findings (evidence: `README.md`)
- Technical diagnostics → Swarm blackboard: records findings (evidence: `app/tools.py`)
- Billing tools → Swarm blackboard: records findings (evidence: `app/tools.py`)
- Account policy tools → Swarm blackboard: records findings (evidence: `app/tools.py`)
- Technical specialist → Proposal consensus: proposes or reviews (evidence: `app/agent.py`)
- Billing specialist → Proposal consensus: proposes or reviews (evidence: `app/agent.py`)
- Account specialist → Proposal consensus: proposes or reviews (evidence: `app/agent.py`)
- Proposal consensus → Swarm blackboard: updates proposal (evidence: `app/swarm.py`)
- Billing tools → Proposal consensus: requires consensus (evidence: `app/tools.py`)
- Account policy tools → Proposal consensus: requires consensus (evidence: `app/tools.py`)
- Technical specialist → Handoff escalation: exceeds handoff cap (evidence: `README.md`)
- Billing specialist → Handoff escalation: exceeds handoff cap (evidence: `README.md`)
- Account specialist → Handoff escalation: exceeds handoff cap (evidence: `README.md`)
- Handoff escalation → Swarm blackboard: summarizes state (evidence: `app/swarm.py`)
- Web/API client → FastAPI app: calls API (evidence: `app/fast_api_app.py`)
- A2A client → A2A routes: sends JSON-RPC (evidence: `app/app_utils/a2a.py`)
- FastAPI app → A2A routes: registers routes (evidence: `app/fast_api_app.py`)
- FastAPI app → Triage dispatcher: loads agent (evidence: `app/fast_api_app.py`)
- FastAPI app → Shared ADK services: configures services (evidence: `app/fast_api_app.py`)
- A2A routes → Triage dispatcher: executes agent (evidence: `app/app_utils/a2a.py`)
- Shared ADK services → Session state: provides sessions (evidence: `app/app_utils/services.py`)
- Feedback schema → Feedback logging: validates payload (evidence: `app/fast_api_app.py`)
- Web/API client → Feedback logging: submits feedback (evidence: `app/fast_api_app.py`)
