# liaohch3/claude-tap architecture

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

- Interactive diagram: https://gitdiagram.com/liaohch3/claude-tap
- Repository: https://github.com/liaohch3/claude-tap
- Video tour (about a minute): https://gitdiagram.com/liaohch3/claude-tap/video

## Overview

claude-tap captures AI coding-agent API traffic or local transcripts, stores trace sessions locally, and presents them for inspection and export. The main workflow is to launch or watch a client, proxy or ingest its activity, persist records, and review them in the dashboard or a portable HTML viewer. The README documents broad client support, request diffs, prompt capture, usage inspection, and privacy protections. Some subsystems are represented from README claims and the source index; edges are limited to documented or indexed relationships.

Main entry points: [`claude_tap/cli.py`](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cli.py) (CLI orchestration), [`claude_tap/proxy.py`](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/proxy.py) (API proxy), [`claude_tap/forward_proxy.py`](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/forward_proxy.py) (Forward proxy), [`claude_tap/trace.py`](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace.py) (Trace writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Client entry"]
  node_cli["CLI orchestration<br/>[cli.py]"]
  node_client["Client launchers<br/>[cli_clients.py]"]
end

subgraph group_capture["Traffic capture"]
  node_transcript["Transcript watcher"]
  node_http_proxy["API proxy<br/>[proxy.py]"]
  node_forward_proxy["Forward proxy<br/>[forward_proxy.py]"]
  node_ws_proxy["WebSocket proxy<br/>[ws_proxy.py]"]
  node_upstream["Upstream routing<br/>[upstream.py]"]
  node_bedrock["Bedrock support<br/>[bedrock.py]"]
  node_sse["Stream reconstruction<br/>[sse.py]"]
  node_prompt["Prompt snapshots<br/>[prompt_snapshot.py]"]
end

subgraph group_records["Trace records"]
  node_writer["Trace writer<br/>[trace.py]"]
  node_store[("SQLite trace store<br/>[trace_store.py]")]
  node_log_handler["Trace log handler"]
  node_usage["Usage normalization<br/>[usage.py]"]
end

subgraph group_review["Trace review"]
  node_dashboard_data["Dashboard summaries<br/>[dashboard.py]"]
  node_live["Live updates<br/>[live.py]"]
  node_shared_dashboard["Shared dashboard"]
  node_viewer["Trace viewer<br/>[viewer.py]"]
  node_export["HTML export<br/>[export.py]"]
  node_compact["Compact trace format<br/>[compact_trace.py]"]
end

node_user(("Engineer"))
node_agent(("AI coding agent"))
node_api(("Model API"))

node_user -->|"runs"| node_cli
node_cli -->|"launches"| node_client
node_client -->|"starts"| node_agent
node_agent -->|"sends API traffic"| node_http_proxy
node_cli -->|"configures"| node_http_proxy
node_cli -->|"configures"| node_forward_proxy
node_forward_proxy -->|"forwards requests"| node_api
node_http_proxy -->|"forwards requests"| node_api
node_http_proxy -->|"dispatches"| node_ws_proxy
node_http_proxy -->|"uses routing"| node_upstream
node_forward_proxy -->|"uses routing"| node_upstream
node_forward_proxy -->|"handles Bedrock"| node_bedrock
node_http_proxy -->|"handles Bedrock"| node_bedrock
node_forward_proxy -->|"reconstructs streams"| node_sse
node_http_proxy -->|"reconstructs streams"| node_sse
node_forward_proxy -->|"normalizes usage"| node_usage
node_http_proxy -->|"normalizes usage"| node_usage
node_transcript -->|"records transcripts"| node_writer
node_http_proxy -.->|"records traffic"| node_writer
node_forward_proxy -.->|"records traffic"| node_writer
node_writer -->|"appends records"| node_store
node_writer -->|"normalizes usage"| node_usage
node_log_handler -->|"appends logs"| node_store
node_cli -->|"configures"| node_log_handler
node_cli -->|"captures prompts"| node_prompt
node_cli -->|"starts live updates"| node_live
node_dashboard_data -->|"reads sessions"| node_store
node_dashboard_data -->|"summarizes tokens"| node_usage
node_dashboard_data -->|"uses viewer"| node_viewer
node_shared_dashboard -->|"reads sessions"| node_store
node_cli -->|"starts dashboard"| node_shared_dashboard
node_cli -->|"prepares dashboard"| node_dashboard_data
node_export -->|"loads traces"| node_store
node_export -->|"includes snapshots"| node_prompt
node_export -->|"encodes traces"| node_compact
node_export -->|"generates HTML"| node_viewer
node_viewer -->|"renders usage"| node_usage

click node_cli "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cli.py"
click node_client "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cli_clients.py"
click node_transcript "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cursor_transcript.py"
click node_http_proxy "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/proxy.py"
click node_forward_proxy "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/forward_proxy.py"
click node_ws_proxy "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/ws_proxy.py"
click node_upstream "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/upstream.py"
click node_bedrock "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/bedrock.py"
click node_sse "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/sse.py"
click node_prompt "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/prompt_snapshot.py"
click node_writer "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace.py"
click node_store "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace_store.py"
click node_log_handler "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace_log_handler.py"
click node_usage "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/usage.py"
click node_dashboard_data "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/dashboard.py"
click node_live "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/live.py"
click node_shared_dashboard "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/shared_dashboard.py"
click node_viewer "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/viewer.py"
click node_export "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/export.py"
click node_compact "https://github.com/liaohch3/claude-tap/blob/main/claude_tap/compact_trace.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_client toneBlue
class node_transcript,node_http_proxy,node_forward_proxy,node_ws_proxy,node_upstream,node_bedrock,node_sse,node_prompt toneAmber
class node_writer,node_store,node_log_handler,node_usage,node_api toneMint
class node_dashboard_data,node_live,node_shared_dashboard,node_viewer,node_export,node_compact toneRose
class node_user,node_agent toneIndigo
```

## Components

### Client entry

- [CLI orchestration](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cli.py): `claude_tap/cli.py`
- [Client launchers](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cli_clients.py): `claude_tap/cli_clients.py`

### Traffic capture

- [Transcript watcher](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/cursor_transcript.py): `claude_tap/cursor_transcript.py`
- [API proxy](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/proxy.py): `claude_tap/proxy.py`
- [Forward proxy](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/forward_proxy.py): `claude_tap/forward_proxy.py`
- [WebSocket proxy](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/ws_proxy.py): `claude_tap/ws_proxy.py`
- [Upstream routing](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/upstream.py): `claude_tap/upstream.py`
- [Bedrock support](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/bedrock.py): `claude_tap/bedrock.py`
- [Stream reconstruction](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/sse.py): `claude_tap/sse.py`
- [Prompt snapshots](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/prompt_snapshot.py): `claude_tap/prompt_snapshot.py`

### Trace records

- [Trace writer](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace.py): `claude_tap/trace.py`
- [SQLite trace store](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace_store.py): `claude_tap/trace_store.py`
- [Trace log handler](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/trace_log_handler.py): `claude_tap/trace_log_handler.py`
- [Usage normalization](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/usage.py): `claude_tap/usage.py`

### Trace review

- [Dashboard summaries](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/dashboard.py): `claude_tap/dashboard.py`
- [Live updates](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/live.py): `claude_tap/live.py`
- [Shared dashboard](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/shared_dashboard.py): `claude_tap/shared_dashboard.py`
- [Trace viewer](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/viewer.py): `claude_tap/viewer.py`
- [HTML export](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/export.py): `claude_tap/export.py`
- [Compact trace format](https://github.com/liaohch3/claude-tap/blob/main/claude_tap/compact_trace.py): `claude_tap/compact_trace.py`

### Other components

- **Engineer**
- **AI coding agent**
- **Model API**

## Connections

- Engineer → CLI orchestration: runs (evidence: `README.md`)
- CLI orchestration → Client launchers: launches (evidence: `claude_tap/cli.py`)
- Client launchers → AI coding agent: starts (evidence: `README.md`)
- AI coding agent → API proxy: sends API traffic (evidence: `README.md`)
- CLI orchestration → API proxy: configures (evidence: `claude_tap/cli.py`)
- CLI orchestration → Forward proxy: configures (evidence: `claude_tap/cli.py`)
- Forward proxy → Model API: forwards requests (evidence: `README.md`)
- API proxy → Model API: forwards requests (evidence: `README.md`)
- API proxy → WebSocket proxy: dispatches (evidence: `claude_tap/proxy.py`)
- API proxy → Upstream routing: uses routing (evidence: `claude_tap/proxy.py`)
- Forward proxy → Upstream routing: uses routing (evidence: `claude_tap/forward_proxy.py`)
- Forward proxy → Bedrock support: handles Bedrock (evidence: `claude_tap/forward_proxy.py`)
- API proxy → Bedrock support: handles Bedrock (evidence: `claude_tap/proxy.py`)
- Forward proxy → Stream reconstruction: reconstructs streams (evidence: `claude_tap/forward_proxy.py`)
- API proxy → Stream reconstruction: reconstructs streams (evidence: `claude_tap/proxy.py`)
- Forward proxy → Usage normalization: normalizes usage (evidence: `claude_tap/forward_proxy.py`)
- API proxy → Usage normalization: normalizes usage (evidence: `claude_tap/proxy.py`)
- Transcript watcher → Trace writer: records transcripts (evidence: `claude_tap/cursor_transcript.py`)
- API proxy → Trace writer: records traffic (evidence: `claude_tap/proxy.py`)
- Forward proxy → Trace writer: records traffic (evidence: `claude_tap/forward_proxy.py`)
- Trace writer → SQLite trace store: appends records (evidence: `claude_tap/trace.py`)
- Trace writer → Usage normalization: normalizes usage (evidence: `claude_tap/trace.py`)
- Trace log handler → SQLite trace store: appends logs (evidence: `claude_tap/trace_log_handler.py`)
- CLI orchestration → Trace log handler: configures (evidence: `claude_tap/cli.py`)
- CLI orchestration → Prompt snapshots: captures prompts (evidence: `claude_tap/cli.py`)
- CLI orchestration → Live updates: starts live updates (evidence: `claude_tap/cli.py`)
- Dashboard summaries → SQLite trace store: reads sessions (evidence: `claude_tap/dashboard.py`)
- Dashboard summaries → Usage normalization: summarizes tokens (evidence: `claude_tap/dashboard.py`)
- Dashboard summaries → Trace viewer: uses viewer (evidence: `claude_tap/dashboard.py`)
- Shared dashboard → SQLite trace store: reads sessions (evidence: `claude_tap/shared_dashboard.py`)
- CLI orchestration → Shared dashboard: starts dashboard (evidence: `claude_tap/cli.py`)
- CLI orchestration → Dashboard summaries: prepares dashboard (evidence: `claude_tap/cli.py`)
- HTML export → SQLite trace store: loads traces (evidence: `claude_tap/export.py`)
- HTML export → Prompt snapshots: includes snapshots (evidence: `claude_tap/export.py`)
- HTML export → Compact trace format: encodes traces (evidence: `claude_tap/export.py`)
- HTML export → Trace viewer: generates HTML (evidence: `claude_tap/export.py`)
- Trace viewer → Usage normalization: renders usage (evidence: `claude_tap/viewer.py`)
