Skip to content

Deploying Statistics for Strava

Introduction

Statistics for Strava is a self-hosted web application that provides enhanced analytics and visualizations for your Strava activities. While Strava offers basic statistics, this application unlocks deeper insights through custom charts, comparisons, and historical analysis.

By connecting to the Strava API, Statistics for Strava imports your activity data and presents it through various visualizations that help you understand your training patterns, progress, and performance over time.

Key highlights of Statistics for Strava:

  • Activity Analytics: Detailed breakdown of all your activities
  • Custom Charts: Visualize data beyond Strava’s offerings
  • Historical Comparison: Compare performance across time periods
  • Training Insights: Identify patterns in your training
  • Personal Records: Track PRs across different metrics
  • Segment Analysis: Deep dive into segment performance
  • Heart Rate Zones: Analyze training intensity distribution
  • Distance Trends: Weekly, monthly, yearly comparisons
  • Ride/Run Summaries: Sport-specific statistics
  • Privacy-Focused: Your data stays on your server
  • Open Source: Customize and extend as needed

This guide walks through deploying Statistics for Strava on Klutch.sh using Docker for enhanced athletic analytics.

Why Deploy Statistics for Strava on Klutch.sh

Deploying Statistics for Strava on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh handles the container deployment automatically.

Persistent Storage: Your imported activity data persists across deployments.

HTTPS by Default: Required for Strava OAuth, provided automatically.

GitHub Integration: Version control your configuration and deploy updates automatically.

Custom Domains: Use a professional URL for your analytics dashboard.

Privacy: Your activity data stays on your infrastructure.

Always Available: Access your statistics from anywhere.

Prerequisites

Before deploying Statistics for Strava on Klutch.sh, ensure you have:

Strava API Setup

Before deploying, create a Strava API application:

  1. Go to Strava API Settings
  2. Create a new application
  3. Fill in required fields:
    • Application Name: Statistics Dashboard
    • Category: Data Analysis
    • Website: Your deployment URL
    • Authorization Callback Domain: your-app-name.klutch.sh
  4. Note your Client ID and Client Secret

Deploying Statistics for Strava on Klutch.sh

    Create a GitHub Repository

    Create a new GitHub repository for your deployment.

    Create Your Dockerfile

    Create a Dockerfile in your repository:

    FROM node:18-alpine AS builder
    WORKDIR /app
    # Clone and build the application
    RUN apk add --no-cache git && \
    git clone https://github.com/your-strava-stats-repo/strava-statistics.git . && \
    npm ci && \
    npm run build
    FROM node:18-alpine
    WORKDIR /app
    COPY --from=builder /app/.next ./.next
    COPY --from=builder /app/node_modules ./node_modules
    COPY --from=builder /app/package.json ./package.json
    COPY --from=builder /app/public ./public
    # Create data directory
    RUN mkdir -p /data
    ENV NODE_ENV=production
    ENV DATA_DIR=/data
    EXPOSE 3000
    HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
    CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
    CMD ["npm", "start"]

    Push Your Repository to GitHub

    Commit and push your Dockerfile.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project.

    Create a New App

    Within your project, create a new app and connect your GitHub repository.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 3000

    Set Environment Variables

    Configure the following environment variables:

    VariableValue
    STRAVA_CLIENT_IDYour Strava API Client ID
    STRAVA_CLIENT_SECRETYour Strava API Client Secret
    STRAVA_REDIRECT_URIhttps://your-app-name.klutch.sh/callback
    SESSION_SECRETA random string for session security

    Attach Persistent Volumes

    Add the following volumes:

    Mount PathRecommended SizePurpose
    /data10 GBDatabase and cached activity data

    Deploy Your Application

    Click Deploy to build and start the application.

    Update Strava Callback URL

    In your Strava API settings, update the callback domain to match your deployment URL.

    Access Your Dashboard

    Once deployment completes, access your statistics at https://your-app-name.klutch.sh.

Connecting to Strava

Initial Authorization

  1. Navigate to your deployment URL
  2. Click Connect with Strava
  3. Authorize the application on Strava
  4. Wait for initial data import

Data Synchronization

After initial import:

  • New activities sync automatically
  • Manual sync available in settings
  • Historical data loads progressively

Dashboard Features

Activity Overview

View all-time statistics:

MetricDescription
Total DistanceCumulative distance across all activities
Total TimeTotal moving time
Activities CountNumber of activities by type
Elevation GainTotal climbing
Calories BurnedEstimated energy expenditure

Temporal Analysis

Analyze trends over time:

  • Weekly mileage trends
  • Monthly activity counts
  • Year-over-year comparisons
  • Training volume progression

Sport-Specific Stats

Detailed metrics per sport:

Running:

  • Average pace trends
  • Distance distribution
  • Longest runs
  • Cadence analysis

Cycling:

  • Average speed trends
  • Elevation profiles
  • Power analysis (if available)
  • Ride type breakdown

Performance Charts

Visual representations:

  • Pace/speed over time
  • Heart rate zone distribution
  • Training load graphs
  • Personal record progression

Advanced Features

Segment Analysis

Deep dive into segment performance:

  • PR history
  • Comparison across attempts
  • Time of day analysis
  • Weather correlation (if available)

Training Zones

Analyze intensity distribution:

ZoneDescription
Zone 1Recovery/easy
Zone 2Aerobic base
Zone 3Tempo
Zone 4Threshold
Zone 5VO2max/anaerobic

Goals and Progress

Track progress toward goals:

  • Weekly/monthly distance targets
  • Activity frequency goals
  • Personal records to beat

Data Privacy

Your Data

  • All data stored on your server
  • No sharing with third parties
  • Full control over retention
  • Export options available

Strava Permissions

The application requests:

  • Read access to activities
  • Read access to profile
  • No write access needed

Troubleshooting

OAuth Errors

  • Verify callback URL matches exactly
  • Check Client ID and Secret are correct
  • Ensure HTTPS is working

Data Not Loading

  • Check Strava API rate limits
  • Verify authorization is complete
  • Review application logs

Incorrect Statistics

  • Trigger manual data resync
  • Check activity privacy settings on Strava
  • Verify all activity types are included

Additional Resources

Conclusion

Deploying Statistics for Strava on Klutch.sh gives you enhanced analytics for your athletic activities. Go beyond Strava’s built-in statistics with custom visualizations, historical comparisons, and detailed performance analysis. With your data stored on your own infrastructure, you maintain complete control while gaining deeper insights into your training.