A Python toolkit for analyzing and visualizing your Strava activities without paying for Strava Premium. Sync your activities, generate cool visualizations, and track your performance metrics over time. This repository is conceived as a starting point for building more advanced Strava data analysis tools. I will keep adding features and visualizations over time.
β οΈ Disclaimer: This project stores Strava data locally on your machine. It is the responsibility of each user to comply with Strava's API Agreement and their terms regarding data storage and usage. Please review Strava's policies before using this tool.
- Web Dashboard: Full-featured React frontend with FastAPI backend:
- π Calendar: Monthly calendar with activity overlay, training session planning, weekly report, goal progress, streaks, and race countdowns
- π Activities: Browsable activity list with detail views, stream charts, splits, segments, and map visualization
- π Aggregations: Interactive Leaflet map with all your routes, filterable by sport and year, plus heatmap export
- β‘ Dashboard: Yearly stats with goal ring, monthly charts, records, and sport breakdowns
- π Personal Records: Best efforts at standard distances with sport-category totals
- π Analytics: Race-time predictor with per-distance cards (central estimate + IQR band) using a weighted blend of VDOT (target-specific) and the Riegel family (fixed 1.06 + personalized fit), plus an evolution chart of predicted times across 12/16/24/52-week windows
- ποΈ Workouts: Structured workout templates with segments (warmup / work / recovery / cooldown)
- β Races: Race calendar with day-countdowns, past-race activity linking, and notes
- π€ Profile: Athlete profile, HR zones, goals management, cache completeness, and API rate limits
- πΈ PNG Exports: Preview-first export dialog for every visualization (quality, color, filename)
- π Dark/Light Mode: Full theme toggle with persistent preference
- Activity Sync: Automatically sync and cache your Strava activities locally using Parquet files
- Cool Visualizations: Generate visualizations including:
- β‘ Thunderstorm Heatmap: Neon-style activity route visualization on dark backgrounds
- π Activity Clock: Polar scatter plot showing when you train (time vs distance)
- ποΈ HUD Dashboard: Cyberpunk-style histograms for distance, heart rate, and pace
- π Efficiency Factor: Track your aerobic efficiency (speed/HR) over time
- π Performance Frontier: Pareto frontier with Riegel's fatigue model fitting
- π Weekly Report: Instagram Story-sized weekly training summary with HR zones, sports breakdown, and accumulated training time
- π― Year in Sport: Instagram Story-sized summaries of your yearly training (main sport & totals)
- π Activity Plots: Neon-style individual activity visualization with elevation profile
- Map Matching: Match GPS tracks to OpenStreetMap road networks using HMM-based matching:
- πΊοΈ Street Coverage Map: Neon-glow visualization of all streets you've traversed in a city
- π Activity Match Plot: Per-activity visualization showing GPS track, matched OSM edges, and snap points
- π Coverage Stats: Track how many km of a city's street network you've covered
- Analytics: Race-time predictions using a top-K (fastest efforts per standard distance) model with recency decay and per-target VDOT. Exposed at
/analyticsin the web app with an evolution chart so you can track how each predicted race time has moved across the year. - GeoJSON Export: Export your activities as GeoJSON for use in mapping applications such as QGIS
- Telegram Bot: Automated scheduled delivery of weekly and monthly reports to your Telegram chat
- Smart Caching: Efficient local caching with incremental sync support to avoid redundant API calls
- Python 3.12+
- A Strava FREE account with API access
- Strava API credentials (Client ID and Client Secret)
# Clone the repository
git clone https://github.com/rsanchezmo/strava-intelligence.git
cd strava-intelligence
# Install dependencies with Poetry
poetry install
# Activate the virtual environment
poetry env activate# Clone the repository
git clone https://github.com/rsanchezmo/strava-intelligence.git
cd strava-intelligence
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the package
pip install -e .- Go to Strava API Settings
- Create a new application to get your Client ID and Client Secret
- Create a
.envfile in the project root:
STRAVA_CLIENT_ID=your_client_id
STRAVA_CLIENT_SECRET=your_client_secret- On first run, the app will open a browser for OAuth authorization. Follow the prompts to grant access.
You can optionally set up a Telegram bot to receive automated weekly reports (Sundays at 21:00) and monthly Year in Sport summaries (last day of month at 21:00).
- Create a Telegram bot via @BotFather and get your bot token
- Get your Telegram chat ID (send a message to your bot, then visit
https://api.telegram.org/bot<YourBOTToken>/getUpdates) - Add these to your
.envfile:
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id- Run the bot:
python telegram_bot.pyThe bot supports manual commands:
/weekly- Generate and send current week's report/monthly- Generate and send current year's report
Run the full web app (FastAPI backend + React frontend):
# Install dependencies
poetry install
cd frontend && npm install && cd ..
# Run both backend and frontend in development mode
python run_dev.pyThe app will be available at http://localhost:5173. The backend API runs on http://localhost:8000.
To run the web app on a home server (Raspberry Pi, small VPS, etc.) behind a Cloudflare Tunnel with Cloudflare Access authentication, see DEPLOY.md. It covers:
- Cloudflare Tunnel + Access setup
- Docker Compose on ARM64
- Seeding the activity cache to skip the interactive OAuth on a headless box
- SSH over the same tunnel
- Automated redeploys on push via a systemd timer (see
deploy/README.md)
from strava.strava_intelligence import StravaIntelligence
from pathlib import Path
# Initialize (auto-syncs activities if cache is older than 12 hours)
strava = StravaIntelligence(workdir=Path("./strava_intelligence_workdir"))
# Generate a thunderstorm heatmap for your runs in Amsterdam
strava.strava_visualizer.thunderstorm_heatmap(
sport_types=['Run'],
location="amsterdam",
radius_km=20.0,
add_basemap=False
)
# Create an activity clock visualization
strava.strava_visualizer.activity_clock(sport_types=['Run'])
# Generate a HUD-style dashboard
strava.strava_visualizer.hud_dashboard(sport_types=['Run'])
# Plot efficiency factor trend
strava.strava_visualizer.plot_efficiency_factor(sport_types=['Run'])
# Plot performance frontier with fatigue model
strava.strava_visualizer.plot_performance_frontier(sport_types=['Run'])
# Generate Year in Sport summary (Instagram Story format)
strava.get_year_in_sport(year=2025, main_sport="Run", neon_color="#fc0101")
# Generate Year in Sport with comparison to previous year
strava.get_year_in_sport(
year=2025,
main_sport="Run",
neon_color="#fc0101",
comparison_year=2024,
comparison_neon_color="#00aaff"
)
# Generate Weekly Report (Instagram Story format)
strava.get_weekly_report(week_start_date="2026-01-12", neon_color="#fc0101")
# Export activities as GeoJSON
strava.save_geojson_activities()
# --- Map Matching & Street Coverage ---
from strava.strava_map_matching import StravaMapMatcher
from strava.strava_utils import get_activities_as_gdf_from_streams
# Initialize the map matcher for a city
map_matcher = StravaMapMatcher(
city_name="Amsterdam, Netherlands",
workdir=Path("./strava_intelligence_workdir"),
force_reload=False,
)
# Build a GeoDataFrame from high-res GPS streams
activities_gdf = get_activities_as_gdf_from_streams(
strava.strava_activities_cache.activities
)
# Match all activities to the OSM road network
matched_gdf, match_details = map_matcher.match(activities_gdf)
# Plot individual activity match results
for activity_id, result in match_details.items():
result.plot(save_path=f"map_match_{activity_id}.png")
# Generate a city-wide street coverage map
map_matcher.plot_coverage(match_details, save_path="amsterdam_coverage.png")A stunning neon visualization of your activity routes on a dark canvas. Perfect for showcasing your training coverage in a specific area.
| Thunderstorm Heatmap | Activity Clock |
|---|---|
![]() |
![]() |
| Neon-style route visualization on dark backgrounds | Polar plot showing training patterns by time of day |
| HUD Dashboard | Efficiency Factor | Performance Frontier |
|---|---|---|
![]() |
![]() |
![]() |
| Distance, HR & Pace distributions | Aerobic efficiency over time | Best performances with Riegel's model |
| Weekly Report | Bubble Map |
|---|---|
![]() |
![]() |
| Instagram Story-sized weekly summary with HR zones, sport breakdowns, and training progression | Geographic bubble visualization of activity locations |
Generate Instagram Story-sized (9:16) summaries of your yearly training with optional year comparison.
| Main Sport | All Sports | Activity Plot |
|---|---|---|
![]() |
![]() |
![]() |
| Stats, monthly chart & personal bests | Aggregated stats across all sports | Route map with elevation profile |
| Year Comparison β Run | Year Comparison β Totals |
|---|---|
![]() |
![]() |
| Side-by-side stats with grouped bar charts | Cross-sport comparison with highlighted differences |
Match your Strava activities to the OpenStreetMap road network using HMM-based map matching.
| Street Coverage Map | Activity Match Plot |
|---|---|
![]() |
![]() |
| Traversed streets glow in neon against the dim untraversed network | GPS track (red), matched OSM edges (blue), snap connections (white) |
Export your activities as GeoJSON for advanced spatial analysis in QGIS.
| All Activities | Activity Info |
|---|---|
![]() |
![]() |
strava-intelligence/
βββ main.py # Example usage (Python API)
βββ telegram_bot.py # Scheduled Telegram reports
βββ run_dev.py # Dev launcher (backend + frontend)
βββ pyproject.toml # Poetry configuration
βββ Dockerfile # Multi-stage build (Node β Python)
βββ docker-compose.yml # App + Cloudflare Tunnel
βββ README.md
βββ DEPLOY.md # Raspberry Pi / production guide
βββ backend/ # FastAPI backend
β βββ app.py # FastAPI application + lifespan
β βββ config.py # Pydantic settings
β βββ db.py # SQLite (calendar / goals / workouts)
β βββ dependencies.py # DI for the StravaIntelligence singleton
β βββ export_cache.py # In-memory TTL cache for PNG exports
β βββ scoring.py # Session execution scoring
β βββ _serialize.py # numpy/pandas β JSON sanitizer
β βββ _ttl_cache.py # Thread-safe TTL cache primitive
β βββ routers/ # API route handlers
β βββ activities.py
β βββ athlete.py
β βββ calendar.py
β βββ exports.py
β βββ goals.py
β βββ health.py
β βββ races.py
β βββ stats.py
β βββ sync.py
β βββ workouts.py
βββ frontend/ # React + Vite (TypeScript) SPA
β βββ src/
β β βββ App.tsx # Routes + lazy pages + ErrorBoundary
β β βββ main.tsx # Entry point + QueryClient defaults
β β βββ index.css # Tailwind v4 tokens + primitives
β β βββ api/ # Axios client + React Query hooks
β β βββ components/
β β β βββ icons.tsx # Inline SVG icon set
β β β βββ layout/ # AppShell, RootErrorBoundary
β β β βββ shared/ # ChartPanel, GoalRing, StatCard, β¦
β β βββ hooks/ # Theme + toast
β β βββ pages/ # Dashboard, Calendar, Activities, β¦
β βββ vite.config.ts
βββ deploy/ # systemd units for auto-deploy
β βββ strava-deploy.service
β βββ strava-deploy.timer
β βββ README.md
βββ scripts/ # Deploy + dev scripts
β βββ auto-deploy.sh # prod-branch poller (run by systemd)
β βββ install-hooks.sh # one-shot git hooks installer
β βββ hooks/pre-commit # secret-scanning pre-commit hook
βββ strava/ # Core Python library
βββ constants.py # CRS constants
βββ strava_activities_cache.py # Parquet-backed cache w/ cache_version
βββ strava_analytics.py # Year-in-sport, weekly report, PRs, PMC
βββ strava_endpoint.py # Strava API client w/ rate-limit pre-check
βββ strava_intelligence.py # Main orchestrator class
βββ strava_map_matching.py # OSM map matching & coverage
βββ strava_user_cache.py # User data caching
βββ strava_utils.py # Utility functions
βββ strava_visualizer.py # Visualization generators
The library is organized around one orchestrator (StravaIntelligence) that
wires together four focused components. All Python methods listed below are
the public surface; the web API exposes the same functionality via
/api/* routes (see backend/routers/).
The main class that orchestrates all functionality.
StravaIntelligence(
workdir: Path, # Working directory for generated outputs
auto_sync: bool = True, # Auto-sync on initialization
sync_max_age_hours: int = 12, # Cache age threshold for auto-sync
)Methods:
sync_activities(full_sync=False, include_streams=False)β pull new activities from Stravaensure_activities_with_streams()β backfill streams / photos / detail for cached activitiessave_geojson_activities()/save_gpkg_activities()β export the full cache to GeoJSON or GeoPackageplot_last_activity(sport_type)β render the most recent activity of the given sportget_year_in_sport(year, main_sport, neon_color, comparison_year=None, comparison_neon_color="#00aaff")β Year-in-Sport visualizations with optional year comparisonget_weekly_report(week_start_date=None, neon_color="#fc0101")β weekly training summary (current week by default)
Generates all matplotlib visualizations. Every rendering method supports
return_buffer=True (returns a PNG BytesIO β used by the web /api/exports
endpoints) and dpi=<int> (override quality).
Methods:
thunderstorm_heatmap(location, sport_types, radius_km, neon_color, show_title, year, return_buffer, dpi)β neon route overlayactivity_bubble_map(region, sport_types, min_radius_scale, grid_density, neon_color, show_title, return_buffer, dpi)β bubble aggregation per grid cellactivity_clock(sport_types, neon_color, return_buffer, dpi)β polar plot (time-of-day Γ distance)plot_activity(activity_id, strava_endpoint, folder, title, neon_color, return_buffer, dpi)β single-activity neon plotplot_year_in_sport_main(year, year_in_sport, main_sport, folder, neon_color, comparison_year, comparison_data, comparison_neon_color, return_buffer, dpi)plot_year_in_sport_totals(year, year_in_sport, folder, neon_color, comparison_year, comparison_data, comparison_neon_color, return_buffer, dpi)hud_dashboard(sport_type, neon_color, return_buffer, dpi)β cyberpunk histogramsplot_efficiency_factor(sport_type, window=14, return_buffer, dpi)β aerobic efficiency over timeplot_performance_frontier(sport_types, return_buffer, dpi)β Pareto frontier + Riegel fitplot_weekly_report(weekly_report, folder, neon_color, last_week_report, return_buffer, dpi)β Instagram-Story sized weekly summary
Pure-Python analytics over the activity cache. All methods are memoized and
invalidate on sync via a cache_version token.
Methods:
get_weekly_report(week_start_date=None, cutoff_date=None)β weekly totals, HR zones, sport breakdownget_year_in_sport(year, main_sport, cutoff_month_day=None)β yearly aggregates for one sportget_all_year_in_sport(year, cutoff_month_day=None)β cross-sport yearly aggregatesget_personal_records()β best efforts at standard distances per sport categoryget_race_predictions(sport_category="running")β VDOT/Riegel-based predicted race timesget_daily_training_load()β per-day TRIMP (zone-weighted when streams available, Banister fallback)get_pmc_chart(start_date=None, end_date=None)β Performance Management Chart (CTL / ATL / TSB)get_fitness_trend(sport_type="Run", start_date=None, end_date=None)β VDOT trend with rolling averageget_hr_zones()/get_max_heart_rate()/get_rest_heart_rate()β HR zone configurationget_current_vo2_max()β VOβmax estimate from recent effortsinvalidate_caches()β clear all memoized analytics (called on sync)
HMM-based map matching of GPS tracks to OSM road networks.
StravaMapMatcher(
city_name: str, # City name for OSM network download
workdir: Path, # Working directory for cached maps
force_reload: bool = False, # Force re-download of OSM data
)Methods:
match(activities)β map-match a GeoDataFrame of activities; returns matched GeoDataFrame + per-activityMatchResultdictcoverage_stats(match_results)β city-wide coverage (km traversed, % covered, unique roads)plot_coverage(match_results, save_path, neon_color, figsize)β neon-glow coverage map
- Telegram bot for automated weekly and monthly reports
- Web dashboard with React frontend and FastAPI backend
- Dark/light mode support
- Athlete profile page with HR zones
- Extend the analytics, use ML models to provide deeper insights, such as training load, fatigue estimation, and performance prediction
- Add more visualizations
- Create an mcp server to expose Strava data so you can access it from your LLM based agents
Contributions are welcome! Please feel free to submit a Pull Request.
After cloning, install the local git hooks once so the pre-commit check can
catch accidentally-staged secrets (.env, tokens, etc.) before they reach
GitHub:
./scripts/install-hooks.shHooks live in scripts/hooks/ (version-controlled) and are symlinked into
your local .git/hooks/ β edit once, they update everywhere.
MIT β free to use, modify, and distribute. If you build something neat on top of this, I'd love to hear about it.


















