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:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- A Strava API application
- A Strava account with activity history
- Basic familiarity with Docker
Strava API Setup
Before deploying, create a Strava API application:
- Go to Strava API Settings
- Create a new application
- Fill in required fields:
- Application Name: Statistics Dashboard
- Category: Data Analysis
- Website: Your deployment URL
- Authorization Callback Domain: your-app-name.klutch.sh
- Note your Client ID and Client Secret
Deploying Statistics for Strava on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 3000
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 applicationRUN 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 ./.nextCOPY --from=builder /app/node_modules ./node_modulesCOPY --from=builder /app/package.json ./package.jsonCOPY --from=builder /app/public ./public
# Create data directoryRUN mkdir -p /data
ENV NODE_ENV=productionENV 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:
Set Environment Variables
Configure the following environment variables:
| Variable | Value |
|---|---|
STRAVA_CLIENT_ID | Your Strava API Client ID |
STRAVA_CLIENT_SECRET | Your Strava API Client Secret |
STRAVA_REDIRECT_URI | https://your-app-name.klutch.sh/callback |
SESSION_SECRET | A random string for session security |
Attach Persistent Volumes
Add the following volumes:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/data | 10 GB | Database 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
- Navigate to your deployment URL
- Click Connect with Strava
- Authorize the application on Strava
- 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:
| Metric | Description |
|---|---|
| Total Distance | Cumulative distance across all activities |
| Total Time | Total moving time |
| Activities Count | Number of activities by type |
| Elevation Gain | Total climbing |
| Calories Burned | Estimated 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:
| Zone | Description |
|---|---|
| Zone 1 | Recovery/easy |
| Zone 2 | Aerobic base |
| Zone 3 | Tempo |
| Zone 4 | Threshold |
| Zone 5 | VO2max/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.