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.
- RunViz shifts API rate limits from the developer to the individual user through a "Bring Your Own Keys" architecture.
- The application secures user credentials at the edge using Cloudflare Workers and the Web Crypto API.
- Advanced physiological metrics like Grade Adjusted Pace are calculated locally using the Minetti 5th-degree polynomial formula.
- A local-first IndexedDB strategy enables instant rendering of massive fitness datasets without network latency.
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.
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.
| Feature | Strava (Free) | Strava (Subscription) | RunViz |
|---|---|---|---|
| Cost | Free | $79.99 / year | Free (Self-Hosted) |
| Data Ownership | Centralized | Centralized | Local IndexedDB |
| Advanced Metrics (GAP, VDOT) | No | Yes | Yes |
| API Rate Limits | N/A | N/A | Personal Quota |
The Physics of the Long Run
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.