How prrabbhanjon/headroom-telemetry-gui works
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: proxy-deployment.yaml Proxy pod · namespace.yaml Namespace · gui-deployment.yaml GUI pod · Dockerfile Proxy runtime
Components 18
Host machine
Browser, Claude Code, and local orchestration scripts run here.
- Claude Code · Local LLM client configured to use the in-cluster proxy.
- Browser · Displays the live telemetry dashboard from the GUI service.
- setup.sh · Primary lifecycle script for install, port-forwards, health checks, logs, restart, and Claude launch.
setup.sh - kubectl port-forward · Local tunnel into GUI and proxy services from the host.
Kubernetes cluster
Kind-based in-cluster proxy and dashboard workloads.
- Namespace · Dedicated Kubernetes namespace for the stack.
k8s/namespace.yaml - Shared config · Common cluster configuration shared by both workloads.
k8s/configmap.yaml - Proxy pod · Runs the Anthropic proxy and emits telemetry.
k8s/proxy-deployment.yaml - Proxy service · Cluster entrypoint for Claude traffic and proxy stats.
k8s/proxy-service.yaml - GUI pod · Runs the static telemetry dashboard.
k8s/gui-deployment.yaml - GUI service · Exposes the dashboard inside the cluster and for browser access.
k8s/gui-service.yaml - Proxy runtime · Headroom proxy image built from python:3.12-slim with proxy features enabled.
proxy/Dockerfile - Compression pipeline · SmartCrusher, CodeCompressor, Kompress-base, CacheAligner, and CCR cache logic.
- Telemetry state · Saved savings data and request-history state used for runtime reporting.
- Telemetry API · Live stats, health, metrics, and liveness endpoints from the proxy.
- Dashboard runtime · Static Nginx-served UI built around Chart.js and polling.
gui/Dockerfile - Live dashboard · Renders savings, latency, CCR stats, trends, and request logs.
gui/index.html
External services
Remote API dependency reached by the proxy.
- Anthropic API · Remote model endpoint reached by the proxy after compression.
Build & delivery
Image build and deployment entry points.
- Build script · Build and publish workflow for the proxy and GUI images.
build-and-deploy.sh
Connections 19
- 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.