# fengjunchengcode/cc-relay-hub architecture

> Architecture diagram of the GitHub repository fengjunchengcode/cc-relay-hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fengjunchengcode/cc-relay-hub
- Repository: https://github.com/fengjunchengcode/cc-relay-hub

## Overview

cc-relay-hub is a local relay for private agent-to-agent tasks and replies, with CLI discovery, cc-connect and Electron IDE routes, and a hook server that returns marked replies to their origin conversation. The graph follows the documented send-and-reply workflow and includes durable state/outbox handling, agent registry and IDE self-healing. README statements support the CLI and hook-server roles; source excerpts and the index support the shown provider, protocol, matching, state, and CDP relationships. Other documented capabilities are included, but unsampled implementations and links are not inferred.

Main entry points: [`hub.py`](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py) (Relay CLI), [`cdp/backends/base.py`](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/base.py) (CDP Backend), [`providers/cc_connect.py`](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cc_connect.py) (cc-connect Provider), [`providers/cdp_provider.py`](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cdp_provider.py) (CDP Provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dispatch["CLI and Discovery"]
  node_cli["Relay CLI<br/>[hub.py]"]
  node_registry["Agent Registry<br/>[hub.py]"]
  node_instructions["Generated Instructions<br/>[hub.py]"]
  node_feishu["Feishu Sender<br/>[feishu-send.py]"]
end

subgraph group_relay["Relay Core"]
  node_envelope["Relay Envelope<br/>[envelope.py]"]
  node_protocol["Relay Protocol<br/>[relay_protocol.py]"]
  node_matcher["Reply Matcher<br/>[match.py]"]
  node_state[("Relay State<br/>[state.py]")]
end

subgraph group_delivery["Agent Delivery"]
  node_ccconnect["cc-connect Provider<br/>[cc_connect.py]"]
  node_cdpprovider["CDP Provider<br/>[cdp_provider.py]"]
end

subgraph group_replies["Reply Handling"]
  node_hook["Hook Server<br/>[hook-server.mjs]"]
end

subgraph group_ide["IDE Automation"]
  node_cdpbase["CDP Backend<br/>[base.py]"]
  node_antigravity["Antigravity Backend<br/>[antigravity.py]"]
  node_cursor["Cursor Backend<br/>[cursor.py]"]
  node_autoheal["Selector Self-Healing<br/>[auto_heal.py]"]
end

node_user(("Human or Agent"))
node_ccconnect_service["cc-connect"]
node_origin(("Origin Conversation"))
node_electron["Electron IDE"]

node_user -->|"commands"| node_cli
node_cli -->|"lists peers"| node_registry
node_cli -->|"generates guidance"| node_instructions
node_cli -->|"creates task"| node_envelope
node_cli -->|"records relay"| node_state
node_cli -->|"dispatches task"| node_ccconnect
node_cli -->|"dispatches task"| node_cdpprovider
node_ccconnect -->|"formats prompt"| node_protocol
node_cdpprovider -->|"formats prompt"| node_protocol
node_ccconnect -->|"posts webhook"| node_ccconnect_service
node_cdpprovider -->|"uses backend"| node_cdpbase
node_cdpbase -->|"specialized by"| node_antigravity
node_cdpbase -->|"specialized by"| node_cursor
node_cdpbase -->|"controls via CDP"| node_electron
node_cdpbase -->|"delegates healing"| node_autoheal
node_autoheal -->|"probes backend"| node_cdpbase
node_ccconnect -.->|"emits reply events"| node_matcher
node_cdpprovider -->|"emits reply events"| node_matcher
node_cli -->|"matches replies"| node_matcher
node_matcher -->|"stores reply"| node_state
node_ccconnect_service -.->|"sends hook event"| node_hook
node_hook -.->|"queues busy reply"| node_state
node_hook -->|"forwards reply"| node_origin
node_cli -.->|"supports messaging"| node_feishu

click node_cli "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py"
click node_registry "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py"
click node_instructions "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py"
click node_envelope "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/envelope.py"
click node_protocol "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/relay_protocol.py"
click node_matcher "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/match.py"
click node_state "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/state.py"
click node_ccconnect "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cc_connect.py"
click node_cdpprovider "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cdp_provider.py"
click node_hook "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hook-server.mjs"
click node_cdpbase "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/base.py"
click node_antigravity "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/antigravity.py"
click node_cursor "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/cursor.py"
click node_autoheal "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/auto_heal.py"
click node_feishu "https://github.com/fengjunchengcode/cc-relay-hub/blob/main/bin/feishu-send.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_cli,node_registry,node_instructions,node_feishu toneBlue
class node_envelope,node_protocol,node_matcher,node_state toneAmber
class node_ccconnect,node_cdpprovider toneMint
class node_hook toneRose
class node_cdpbase,node_antigravity,node_cursor,node_autoheal,node_user,node_ccconnect_service,node_origin,node_electron toneIndigo
```

## Components

### CLI and Discovery

- [Relay CLI](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py): `hub.py`
- [Agent Registry](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py): `hub.py`
- [Generated Instructions](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hub.py): `hub.py`
- [Feishu Sender](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/bin/feishu-send.py): `bin/feishu-send.py`

### Relay Core

- [Relay Envelope](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/envelope.py): `core/envelope.py`
- [Relay Protocol](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/relay_protocol.py): `core/relay_protocol.py`
- [Reply Matcher](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/match.py): `core/match.py`
- [Relay State](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/core/state.py): `core/state.py`

### Agent Delivery

- [cc-connect Provider](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cc_connect.py): `providers/cc_connect.py`
- [CDP Provider](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/providers/cdp_provider.py): `providers/cdp_provider.py`

### Reply Handling

- [Hook Server](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/hook-server.mjs): `hook-server.mjs`

### IDE Automation

- [CDP Backend](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/base.py): `cdp/backends/base.py`
- [Antigravity Backend](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/antigravity.py): `cdp/backends/antigravity.py`
- [Cursor Backend](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/backends/cursor.py): `cdp/backends/cursor.py`
- [Selector Self-Healing](https://github.com/fengjunchengcode/cc-relay-hub/blob/main/cdp/auto_heal.py): `cdp/auto_heal.py`

### Other components

- **Human or Agent**
- **cc-connect**
- **Origin Conversation**
- **Electron IDE**

## Connections

- Human or Agent → Relay CLI: commands (evidence: `README.md`)
- Relay CLI → Agent Registry: lists peers (evidence: `README.md`)
- Relay CLI → Generated Instructions: generates guidance (evidence: `README.md`)
- Relay CLI → Relay Envelope: creates task (evidence: `hub.py`)
- Relay CLI → Relay State: records relay (evidence: `hub.py`)
- Relay CLI → cc-connect Provider: dispatches task (evidence: `hub.py`)
- Relay CLI → CDP Provider: dispatches task (evidence: `hub.py`)
- cc-connect Provider → Relay Protocol: formats prompt (evidence: `providers/cc_connect.py`)
- CDP Provider → Relay Protocol: formats prompt (evidence: `providers/cdp_provider.py`)
- cc-connect Provider → cc-connect: posts webhook (evidence: `providers/cc_connect.py`)
- CDP Provider → CDP Backend: uses backend (evidence: `providers/cdp_provider.py`)
- CDP Backend → Antigravity Backend: specialized by (evidence: `cdp/backends/antigravity.py`)
- CDP Backend → Cursor Backend: specialized by (evidence: `cdp/backends/cursor.py`)
- CDP Backend → Electron IDE: controls via CDP (evidence: `cdp/backends/base.py`)
- CDP Backend → Selector Self-Healing: delegates healing (evidence: `cdp/backends/base.py`)
- Selector Self-Healing → CDP Backend: probes backend (evidence: `cdp/auto_heal.py`)
- cc-connect Provider → Reply Matcher: emits reply events
- CDP Provider → Reply Matcher: emits reply events (evidence: `providers/cdp_provider.py`)
- Relay CLI → Reply Matcher: matches replies (evidence: `hub.py`)
- Reply Matcher → Relay State: stores reply (evidence: `core/match.py`)
- cc-connect → Hook Server: sends hook event (evidence: `README.md`)
- Hook Server → Relay State: queues busy reply
- Hook Server → Origin Conversation: forwards reply (evidence: `README.md`)
- Relay CLI → Feishu Sender: supports messaging (evidence: `README.md`)
