# prrabbhanjon/headroom-telemetry-gui architecture

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

- Interactive diagram: https://gitdiagram.com/prrabbhanjon/headroom-telemetry-gui
- Repository: https://github.com/prrabbhanjon/headroom-telemetry-gui

## Overview

1. **What this repo is**
   This is a two-tier Kubernetes deployment that wraps Headroom’s Anthropic proxy with a live telemetry dashboard. The repo is split between a **proxy service** that compresses LLM requests and a **GUI service** that visualizes savings and request health.

2. **Main runtime boundary**
   There are three distinct environments: the **host machine** (browser, Claude Code, `kubectl`, `setup.sh`), the **Kind cluster inside Podman Desktop**, and the **external Anthropic API**. The host does not talk directly to Anthropic; it talks to the in-cluster proxy.

3. **Request path**
   Claude Code is configured to send API calls to `ANTHROPIC_BASE_URL=http://127.0.0.1:8787`, which is port-forwarded into the proxy pod. The proxy compresses the request, forwards it to Anthropic Cloud, then returns the response back to Claude Code.

4. **Proxy subsystem**
   The `proxy/` image is built from `python:3.12-slim` with `headroom-ai[proxy]`. It is the core data-processing component and contains the compression pipeline: SmartCrusher for JSON, CodeCompressor for AST/code, Kompress-base for text, plus CacheAligner and CCR cache support.

5. **Telemetry produced by the proxy**
   The proxy is responsible for emitting runtime statistics such as tokens saved, savings percentage, request counts, CCR entries, and latency. The README also indicates it exposes operational endpoints like `/livez`, `/stats`, `/health`, and `/metrics`, and persists savings data in `proxy_savings.json`.

6. **Dashboard subsystem**
   The `gui/` image is a static web UI served by `nginx:alpine`. It renders the dashboard with Chart.js and refreshes every second by polling the proxy’s `/stats` endpoint. The UI focuses on live savings metrics, trend charts, pipeline latency, CCR cache stats, and a request log.

7. **In-cluster service-to-service flow**
   The GUI does not compute telemetry itself; it reads it from the proxy over Kubernetes service DNS. That means the proxy is the source of truth for telemetry, while the GUI is a read-only consumer. The cluster boundary is reinforced by separate Deployments and Services for `headroom-proxy` and `headroom-gui`.

8. **Kubernetes packaging**
   The `k8s/` directory defines the namespace, a shared ConfigMap, and separate Deployment/Service manifests for each component. The architecture is intentionally simple: one namespace, two pods, two services, with the GUI exposed for browsing and the proxy exposed for Claude traffic and stats access.

9. **Local access pattern**
   User-facing access is typically done through `kubectl port-forward`: `localhost:3000` maps to the GUI, and `localhost:8787` maps to the proxy. This keeps the cluster internal while still allowing a browser and local Claude Code process to interact with it from the host.

10. **Operational orchestration**
   `setup.sh` is the main lifecycle tool and encodes the repo’s operational workflow: install, start, health checks, forwarding, logs, restart, and launching Claude through the proxy. It also handles practical edge cases like port conflicts, missing Claude binaries, and reboot recovery.

11. **Build and distribution**
   Both images are intended to be built and published independently, with GitHub Actions described as the CI/CD mechanism and GHCR as the image registry. The repo also supports pulling prebuilt images and loading them into the local Kubernetes environment.

12. **Key diagram elements to include**
   If you draw this architecture, show: host-side Claude Code and browser; port-forward links into the cluster; a proxy pod that compresses and forwards API calls to Anthropic; a GUI pod that polls proxy stats; and K8s objects wrapping both services in a dedicated namespace. The most important data flow is: **Claude Code → local proxy → Anthropic → proxy stats → GUI dashboard**.

Main entry points: [`k8s/proxy-deployment.yaml`](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/proxy-deployment.yaml) (Proxy pod), [`k8s/namespace.yaml`](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/namespace.yaml) (Namespace), [`k8s/gui-deployment.yaml`](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/gui-deployment.yaml) (GUI pod), [`proxy/Dockerfile`](https://github.com/prrabbhanjon/headroom-telemetry-gui/tree/main/proxy/Dockerfile) (Proxy runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host machine"]
  node_claude_code(("Claude Code<br/>client"))
  node_browser(("Browser<br/>viewer"))
  node_setup_script["setup.sh<br/>orchestrator<br/>[setup.sh]"]
  node_kubectl(("kubectl port-forward<br/>access path"))
end

subgraph group_cluster["Kubernetes cluster"]
  node_namespace{{"Namespace<br/>[namespace.yaml]"}}
  node_configmap["Shared config<br/>k8s config<br/>[configmap.yaml]"]
  node_proxy_deploy["Proxy pod<br/>k8s deployment"]
  node_proxy_svc["Proxy service<br/>k8s service<br/>[proxy-service.yaml]"]
  node_gui_deploy["GUI pod<br/>k8s deployment"]
  node_gui_svc["GUI service<br/>k8s service<br/>[gui-service.yaml]"]
  node_proxy_runtime["Proxy runtime<br/>python app"]
  node_compressors{{"Compression pipeline<br/>processing"}}
  node_telemetry_state[("Telemetry state")]
  node_telemetry_api(("Telemetry API"))
  node_gui_runtime["Dashboard runtime<br/>web app"]
  node_dashboard["Live dashboard<br/>ui<br/>[index.html]"]
end

subgraph group_external["External services"]
  node_anthropic_api(("Anthropic API<br/>external api"))
end

subgraph group_delivery["Build & delivery"]
  node_build_script["Build script<br/>release"]
end

node_claude_code -->|"API traffic"| node_kubectl
node_browser -->|"open UI"| node_kubectl
node_setup_script -->|"starts tunnels"| node_kubectl
node_setup_script -->|"launches"| node_claude_code
node_build_script -->|"builds"| node_proxy_runtime
node_build_script -->|"builds"| node_gui_runtime
node_namespace -->|"scopes"| node_configmap
node_namespace -->|"contains"| node_proxy_deploy
node_namespace -->|"contains"| node_gui_deploy
node_proxy_deploy -->|"runs"| node_proxy_runtime
node_gui_deploy -->|"runs"| node_gui_runtime
node_proxy_deploy -->|"compresses"| node_compressors
node_compressors -->|"reads/writes"| node_telemetry_state
node_proxy_deploy -->|"publishes"| node_telemetry_api
node_proxy_svc -->|"routes to"| node_proxy_deploy
node_gui_svc -->|"routes to"| node_gui_deploy
node_gui_runtime -->|"polls"| node_telemetry_api
node_telemetry_api -->|"feeds"| node_dashboard
node_proxy_runtime -->|"forwards"| node_anthropic_api

click node_setup_script "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/setup.sh"
click node_build_script "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/build-and-deploy.sh"
click node_namespace "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/namespace.yaml"
click node_configmap "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/configmap.yaml"
click node_proxy_deploy "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/proxy-deployment.yaml"
click node_proxy_svc "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/proxy-service.yaml"
click node_gui_deploy "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/gui-deployment.yaml"
click node_gui_svc "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/gui-service.yaml"
click node_proxy_runtime "https://github.com/prrabbhanjon/headroom-telemetry-gui/tree/main/proxy/Dockerfile"
click node_gui_runtime "https://github.com/prrabbhanjon/headroom-telemetry-gui/tree/main/gui/Dockerfile"
click node_dashboard "https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/gui/index.html"

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_claude_code,node_browser,node_setup_script,node_kubectl toneBlue
class node_namespace,node_configmap,node_proxy_deploy,node_proxy_svc,node_gui_deploy,node_gui_svc,node_proxy_runtime,node_compressors,node_telemetry_state,node_telemetry_api,node_gui_runtime,node_dashboard toneAmber
class node_anthropic_api toneMint
class node_build_script toneRose
```

## Components

### Host machine

Browser, Claude Code, and local orchestration scripts run here.

- **Claude Code**: client · Local LLM client configured to use the in-cluster proxy.
- **Browser**: viewer · Displays the live telemetry dashboard from the GUI service.
- [setup.sh](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/setup.sh): orchestrator · Primary lifecycle script for install, port-forwards, health checks, logs, restart, and Claude launch. · `setup.sh`
- **kubectl port-forward**: access path · Local tunnel into GUI and proxy services from the host.

### Kubernetes cluster

Kind-based in-cluster proxy and dashboard workloads.

- [Namespace](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/namespace.yaml): k8s namespace · Dedicated Kubernetes namespace for the stack. · `k8s/namespace.yaml`
- [Shared config](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/configmap.yaml): k8s config · Common cluster configuration shared by both workloads. · `k8s/configmap.yaml`
- [Proxy pod](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/proxy-deployment.yaml): k8s deployment · Runs the Anthropic proxy and emits telemetry. · `k8s/proxy-deployment.yaml`
- [Proxy service](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/proxy-service.yaml): k8s service · Cluster entrypoint for Claude traffic and proxy stats. · `k8s/proxy-service.yaml`
- [GUI pod](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/gui-deployment.yaml): k8s deployment · Runs the static telemetry dashboard. · `k8s/gui-deployment.yaml`
- [GUI service](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/k8s/gui-service.yaml): k8s service · Exposes the dashboard inside the cluster and for browser access. · `k8s/gui-service.yaml`
- [Proxy runtime](https://github.com/prrabbhanjon/headroom-telemetry-gui/tree/main/proxy/Dockerfile): python app · Headroom proxy image built from python:3.12-slim with proxy features enabled. · `proxy/Dockerfile`
- **Compression pipeline**: processing · SmartCrusher, CodeCompressor, Kompress-base, CacheAligner, and CCR cache logic.
- **Telemetry state**: state · Saved savings data and request-history state used for runtime reporting.
- **Telemetry API**: api · Live stats, health, metrics, and liveness endpoints from the proxy.
- [Dashboard runtime](https://github.com/prrabbhanjon/headroom-telemetry-gui/tree/main/gui/Dockerfile): web app · Static Nginx-served UI built around Chart.js and polling. · `gui/Dockerfile`
- [Live dashboard](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/gui/index.html): ui · Renders savings, latency, CCR stats, trends, and request logs. · `gui/index.html`

### External services

Remote API dependency reached by the proxy.

- **Anthropic API**: external api · Remote model endpoint reached by the proxy after compression.

### Build & delivery

Image build and deployment entry points.

- [Build script](https://github.com/prrabbhanjon/headroom-telemetry-gui/blob/main/build-and-deploy.sh): release · Build and publish workflow for the proxy and GUI images. · `build-and-deploy.sh`

## Connections

- Claude Code → kubectl port-forward: API traffic · Claude Code sends requests to the locally forwarded proxy endpoint.
- Browser → kubectl port-forward: open UI · The browser reaches the dashboard through local port-forwarding.
- setup.sh → kubectl port-forward: starts tunnels · The lifecycle script creates and manages local port-forwards.
- setup.sh → Claude Code: launches · The script can start Claude configured to use the proxy base URL.
- Build script → Proxy runtime: builds · Build-and-deploy packaging produces the proxy image.
- Build script → Dashboard runtime: builds · Build-and-deploy packaging produces the GUI image.
- Namespace → Shared config: scopes · Shared configuration is applied within the dedicated namespace.
- Namespace → Proxy pod: contains · The namespace contains the proxy workload.
- Namespace → GUI pod: contains · The namespace contains the dashboard workload.
- Proxy pod → Proxy runtime: runs · The proxy deployment instantiates the proxy container image.
- GUI pod → Dashboard runtime: runs · The GUI deployment instantiates the Nginx-served UI image.
- Proxy pod → Compression pipeline: compresses · The proxy executes the request compression pipeline.
- Compression pipeline → Telemetry state: reads/writes · Compression and alignment logic update savings and cache state.
- Proxy pod → Telemetry API: publishes · The proxy exposes operational and statistics endpoints.
- Proxy service → Proxy pod: routes to · Service traffic is routed to the proxy pod.
- GUI service → GUI pod: routes to · Service traffic is routed to the GUI pod.
- Dashboard runtime → Telemetry API: polls · The dashboard reads live stats from the proxy over cluster DNS.
- Telemetry API → Live dashboard: feeds · Telemetry values drive the live charts and request log rendering.
- Proxy runtime → Anthropic API: forwards · Compressed requests are sent onward to Anthropic and responses return through the proxy.
