Skip to content

Lucs1590/strava-to-trainingpeaks

Repository files navigation

Strava to TrainingPeaks

strava-to-tp-logo

Tweet codecov Python Coverage CodeFactor

A powerful tool that simplifies downloading activities from Strava and uploading them to TrainingPeaks, with optional AI-powered training analysis and multi-athlete coach mode.

Overview

Originally created to sync triathlon training data from Samsung Watch to TrainingPeaks (via Strava as an intermediary), this tool has evolved to include:

  • Personal Mode: Individual athletes can download and process their own activities
  • Coach Mode: Coaches can manage and sync activities for multiple athletes via OAuth
  • AI Analysis: Optional LLM-powered training insights and performance feedback
  • Audio Summaries: Generate spoken analysis of your training sessions

Features

Core Functionality

  • πŸƒ Download activities from Strava (running, cycling, swimming, and more)
  • πŸ“Š Format TCX files for TrainingPeaks compatibility
  • βœ… Validate and optimize TCX data for different sports
  • 🎯 Interactive CLI with guided workflows

AI-Powered Analysis

  • πŸ€– Intelligent training analysis using OpenAI's GPT models
  • πŸ“ˆ Performance metrics evaluation (pace, heart rate, power, cadence)
  • πŸ’ͺ Identify strengths and areas for improvement
  • 🎧 Generate audio summaries of your training sessions

Coach Mode (OAuth)

  • πŸ‘₯ Manage multiple athletes from a single interface
  • πŸ” Secure OAuth 2.0 authorization
  • πŸ”„ Automatic token refresh
  • πŸ“₯ Batch download activities for your athletes

Documentation

For detailed guides and tutorials, check out these articles:

Watch the video guide on exporting from Strava to TrainingPeaks manually

Quick Start

Personal Mode

# Install the package
pip install .

# Run the interactive CLI
strava-to-trainingpeaks

The CLI will guide you through:

  1. Selecting your sport (running, cycling, swimming, other)
  2. Downloading from Strava or providing a local TCX file
  3. Optional AI analysis of your training session
  4. Optional audio summary generation
  5. Formatted TCX file ready for TrainingPeaks upload

Coach Mode

# Set up OAuth credentials (one-time setup)
export STRAVA_CLIENT_ID=your_client_id
export STRAVA_CLIENT_SECRET=your_client_secret

# Run coach mode
strava-coach-mode

See Coach Mode Documentation for complete setup instructions.

Installation

Prerequisites

  • Python 3.12 or higher
  • pip package manager
  • Strava account (logged in on your browser for downloads)
  • Optional: OpenAI API key (for AI analysis features)

Standard Installation

# Clone the repository
git clone https://github.com/Lucs1590/strava-to-trainingpeaks
cd strava-to-trainingpeaks

# Install dependencies
pip install -r requirements.txt

# Install the package
pip install .

Alternative Installation Methods

Using Interactive Setup Script

python interactive_setup.py

Follow the prompts to choose between:

  • Global installation
  • Virtual environment
  • Docker container

Docker Installation

# Build the image
docker build -t strava-to-trainingpeaks .

# Run the container
docker run -it --rm strava-to-trainingpeaks

Configuration

AI Analysis Setup (Optional)

To enable AI-powered training analysis:

  1. Get an OpenAI API key from OpenAI Platform
  2. Set the environment variable:
export OPENAI_API_KEY=your_api_key_here

Or create a .env file:

OPENAI_API_KEY=your_api_key_here

Coach Mode Setup

See the Coach Mode Documentation for detailed OAuth setup instructions.

Advanced Features

AI Training Analysis

The tool can analyze your training sessions using advanced language models:

  • Performance Metrics: Detailed analysis of pace, heart rate zones, power output, and cadence
  • Physiological Analysis: Insights into cardiovascular efficiency and energy systems
  • Strengths & Weaknesses: Identify what you're doing well and areas for improvement
  • Training Plan Comparison: Compare actual performance against planned workouts

Example workflow:

strava-to-trainingpeaks
# Select sport β†’ Download activity β†’ Enable AI analysis β†’ Answer prompts

Audio Summaries

Generate spoken summaries of your training analysis:

  • Uses OpenAI's text-to-speech technology
  • Automatically removes markdown formatting
  • Saves MP3 files to your Downloads folder
  • Perfect for reviewing while cooling down or commuting

Building an Executable

Package the application into a standalone executable:

python exec_setup.py build

The executable will be created in the build/ directory.

How It Works

Personal Mode Workflow

  1. Sport Selection: Choose your activity type (running, cycling, swimming, or other)
  2. Data Source: Download from Strava (by activity ID) or provide a local TCX file
  3. Processing: The tool formats and validates the TCX file for TrainingPeaks
  4. AI Analysis (optional): Get detailed performance insights
  5. Audio Summary (optional): Generate a spoken analysis
  6. Output: Receive a formatted TCX file ready for TrainingPeaks upload

Coach Mode Workflow

  1. Setup: Configure Strava OAuth credentials (one-time)
  2. Athlete Authorization: Athletes grant access through secure OAuth flow
  3. Manage Athletes: View all authorized athletes and their token status
  4. Sync Activities: Download any athlete's activities using their tokens
  5. Batch Processing: Process multiple athletes' data efficiently

Resources & Links

Articles & Tutorials

Documentation

Project Information

Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Install development dependencies
pip install -r requirements.txt

# Run tests
python -m unittest discover -s tests -v

# Run with coverage
pytest --cov --junitxml=junit.xml

Support

If you find this project helpful, please consider:

  • ⭐ Starring the repository
  • πŸ“’ Sharing it with your training community
  • πŸ› Reporting bugs or suggesting features via Issues
  • πŸ’‘ Contributing code improvements

Acknowledgments

Special thanks to the open-source community and all contributors who have helped improve this project.

About

This is a simple script that will download your activities from Strava and upload them to TrainingPeaks in assisted mode.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages