RunViz: The Serverless Blueprint for Data-Sovereign Athletes

How a "Bring Your Own Keys" architecture turns Cloudflare Workers into a private, pro-tier fitness laboratory.

hwong103/runviz

A lone runner crossing an edge boundary, bypassing a monolithic cloud tower.
By shifting API requests to the edge, RunViz bypasses the centralized constraints of traditional fitness platforms.

Key Takeaways

The Edge-Side Escape Pod

Most open-source fitness dashboards die a quiet death against the wall of API rate limits. When a centralized service like Strava restricts global API calls, hobbyist projects cannot scale to support thousands of users without passing on exorbitant enterprise costs.

RunViz sidesteps this entirely by acting as a "Full-Stack Serverless" application. Leveraging Cloudflare Workers, D1 (SQL), and KV (Key-Value storage), it deploys both the React frontend and the routing API to the edge. There is no traditional backend server to maintain, and no central API bottleneck.

The BYOK architecture ensures every user authenticates against Strava with their own credentials, eliminating global rate-limit bottlenecks.

Bypassing the Rate-Limit Wall

The brilliance of RunViz lies in its "Bring Your Own Keys" (BYOK) model. Instead of the application holding a single master key to the Strava kingdom, each user inputs their own Strava Client ID and Secret during setup.

This shifts the API quota from the application developer to the individual user. To secure this, RunViz uses the Web Crypto API (AES-GCM with PBKDF2 key derivation) on the Worker side to encrypt the credentials before storing them in the D1 database. A database leak would not immediately compromise users' Strava accounts.

FeatureStrava (Free)Strava (Subscription)RunViz
CostFree$79.99 / yearFree (Self-Hosted)
Data OwnershipCentralizedCentralizedLocal IndexedDB
Advanced Metrics (GAP, VDOT)NoYesYes
API Rate LimitsN/AN/APersonal Quota

The Physics of the Long Run

A close-up of a running shoe mid-stride, casting a shadow that forms a complex polynomial curve.
RunViz abstracts complex physiological formulas into pure TypeScript functions, running advanced analytics entirely on the client.

Beyond simple visualizations, RunViz implements a formidable physics engine in its src/analytics directory. It replicates features typically locked behind the Strava paywall, such as Grade Adjusted Pace (GAP) and Chronic Training Load (CTL).

Instead of basic linear hill adjustments, the application uses the Minetti Formula—a 5th-degree polynomial—to accurately model the metabolic cost of running on inclines. It also implements Jack Daniels’ VDOT tables to estimate VO2 Max and predict race times, applying a 90-day recency bias to ensure training zones reflect current fitness, not stale personal records.

Local-First, Cloud-Optional

To maintain a snappy, "pro-tool" feel, RunViz relies heavily on IndexedDB. When a user logs in, the app performs an incremental sync, fetching only new activities from the Strava API and merging them with the local cache.

Raw GPS streams and heart rate data are stored in specialized IndexedDB stores separate from the main activity list. This ensures that even a user with ten years of running history can render a 365-day calendar heatmap instantly, without waiting on network round-trips.