How zr-jb/graphite-meter works
Purpose and Entry Points
Graphite Meter is a self-hosted internet speed-test system: a static Go server embeds a Svelte browser client, while a separate Go terminal client runs the same measurement protocol. Server entry point: go/cmd/graphite-meter/main.go; TUI entry point: go/cmd/graphite-meter-client/main.go; browser bootstrap: client/src/main.ts and client/src/App.svelte.
Server Composition and Admission
The Go server configures native HTTP/1.1, HTTP/2, HTTP/3/QUIC listeners, routing, TLS, connection admission, and protocol-aware access control. It is the authoritative boundary for advertised endpoint capabilities and load limits.
• go/internal/server/listeners.go
• go/internal/server/admission.go
• go/internal/config/config.go
Measurement Endpoint Layer
Server endpoints implement preflight/probe discovery, download byte production, upload receipt/progress accounting, ping, and WebTransport sessions. Upload results deliberately originate from server-observed bytes rather than client-side sent-byte estimates.
• go/internal/endpoint/registry.go
• go/internal/endpoint/meter.go
• go/internal/endpoint/upload.go
Transport and Wire-Protocol Boundary
HTTP streaming, WebSocket, QUIC, and WebTransport are normalized behind session/transport abstractions. A shared framed wire protocol supports transport-independent control and measurement traffic, particularly WebTransport operation.
• go/internal/transport/session.go
• go/internal/transport/webtransport_session.go
• go/internal/wire/frame.go
The contract is externally specified under api/, including route and preflight/probe schemas: api/wire.md, api/preflight.schema.json, api/routes.txt.
Authentication and Static Delivery
Optional password and OIDC authentication wraps assets and all measurement transports, with sessions, authorization policy, device/CLI approval flows, and WebTransport-specific enforcement. The browser distribution is built separately then embedded in the server binary.
• go/internal/auth/service.go
• go/internal/auth/oidc.go
• go/internal/static/embed.go
Browser Measurement Engine
The Svelte client owns setup, stage state, persistence, adaptive stopping, rate/latency aggregation, and presentation state. engine.svelte.ts coordinates the runner lifecycle; real and dummy runners satisfy the runner contract. Workers isolate concurrent download/upload/ping operations and provide rolling progress/RTT estimates.
• client/src/lib/runner/engine.svelte.ts
• client/src/lib/runner/RealRunner.ts
• client/src/lib/runner/workers/download-worker.ts
Flow: UI settings and selected paths → preflight/probe APIs → runner schedules latency, download, upload, and bidirectional stages → transport workers emit samples/progress → stats/evaluation decide stability/completion → state and visualization update. Browser API adapters live at client/src/lib/api/preflight.ts and client/src/lib/api/probe.ts.
Client UI and Visualization
The application presents endpoint/path availability, live transport status, results, latency-under-load, and canvas-based throughput/gauge rendering. UI components consume runner/state outputs rather than owning transport logic.
• client/src/lib/state/store.svelte.ts
• client/src/lib/canvas/ChartEngine.ts
• client/src/lib/components/ThroughputChart.svelte
Native TUI and Deployment
The native client uses go/internal/goclient to execute the same server contract and transports, then renders an interactive terminal lifecycle. Builds target a static binary and scratch OCI image; Compose and Quadlet support direct, TLS, authenticated, Let’s Encrypt/Cloudflare, and Tailscale deployments.
• go/internal/goclient/runner.go
• go/cmd/graphite-meter-client/runlifecycle.go
• container/Dockerfile
Main entry points: registry.go Measurement endpoints · listeners.go Listeners and admission · runner.go Native measurement runner · wire.md Public API contract
Components 21
Go Server
Authoritative endpoint, transport, and admission boundary.
- Server entry point
go/cmd/graphite-meter/main.go - Listeners and admission · Configures HTTP/1.1, HTTP/2, HTTP/3, TLS, limits, and access policy.
go/internal/server/listeners.go - Connection admission
go/internal/server/admission.go - Server configuration
go/internal/config/config.go - Measurement endpoints · Exposes preflight, probe, download, upload, ping, and WebTransport operations.
go/internal/endpoint/registry.go - Meter handlers
go/internal/endpoint/meter.go - Upload accounting · Reports server-observed received bytes and progress.
go/internal/endpoint/upload.go - Transport sessions · Normalizes streaming HTTP, WebSocket, QUIC, and WebTransport.
go/internal/transport/session.go - Framed wire protocol · Shared transport-independent control and measurement frames.
go/internal/wire/frame.go - Authentication service · Optional password/OIDC sessions, policy, device approval, and transport enforcement.
go/internal/auth/service.go - Embedded browser assets
go/internal/static/embed.go
Browser Client
Embedded Svelte measurement application.
- Svelte application
client/src/main.ts - Measurement engine · Schedules stages and decides stability and completion.
client/src/lib/runner/engine.svelte.ts - Real browser runner
client/src/lib/runner/RealRunner.ts - Transport workers · Run concurrent download, upload, and ping with rolling estimates.
client/src/lib/runner/workers/download-worker.ts - State and visualization · Renders availability, live status, results, and charts from runner outputs.
client/src/lib/state/store.svelte.ts
Native Client
Terminal implementation of the shared measurement contract.
- TUI entry point
go/cmd/graphite-meter-client/main.go - Native measurement runner · Executes the same server contract and transports.
go/internal/goclient/runner.go - Terminal lifecycle
go/cmd/graphite-meter-client/runlifecycle.go
Other components
- Public API contract · Routes plus preflight, probe, and wire schemas.
api/wire.md - Static OCI image · Builds a static binary for scratch-based deployment.
container/Dockerfile
Connections 24
- Server entry point → Listeners and admission: starts
- Server configuration → Listeners and admission: configures
- Connection admission → Listeners and admission: limits connections
- Listeners and admission → Measurement endpoints: routes requests
- Measurement endpoints → Meter handlers: serves measurement stages
- Measurement endpoints → Upload accounting: receives uploads
- Measurement endpoints → Transport sessions: uses transports
- Transport sessions → Framed wire protocol: exchanges frames
- Authentication service → Listeners and admission: protects assets and transports
- Embedded browser assets → Listeners and admission: serves browser app
- Svelte application → Measurement engine: initializes
- Measurement engine → Real browser runner: controls
- Real browser runner → Transport workers: runs stages
- Transport workers → Measurement endpoints: preflight, probe, and measurement
- Measurement engine → State and visualization: publishes state
- State and visualization → Svelte application: renders in app
- TUI entry point → Native measurement runner: starts
- Native measurement runner → Terminal lifecycle: reports lifecycle
- Native measurement runner → Measurement endpoints: uses shared API
- Native measurement runner → Transport sessions: uses shared transports
- Public API contract → Measurement endpoints: specifies
- Public API contract → Real browser runner: implements
- Public API contract → Native measurement runner: implements
- Static OCI image → Server entry point: packages