Thanks to visit codestin.com
Credit goes to github.com

Skip to content

henkburgstra/garmin-ai-coach

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŠโ€โ™‚๏ธ๐Ÿšดโ€โ™‚๏ธ๐Ÿƒโ€โ™‚๏ธ Your AI Endurance Coach

Transform your Garmin Connect data into personalized insights, training plans, and race prep strategies using a sophisticated multi-agent AI system.

Made with Python Powered by LangGraph License: MIT

Provider-agnostic: OpenAI (incl. GPT-5), Anthropic, and OpenRouter are supported.


โœจ What Makes This Special

  • Parallel analysis across specialized agents (load, physiology, execution)
  • Interactive reports with evidence and actionable next steps
  • CLI-first, config-driven headless runs
  • Telegram bot interface (deprecated) โ€” see Deprecated section below
  • Privacy-first: local encrypted credentials; no cloud storage of personal data
  • Built-in observability and cost tracking (LangSmith)

๐ŸŽฏ See It In Action

Your Personal AI Coaching Team

flowchart LR
    subgraph Analysis Team
        A[๐Ÿ“Š Dr. Aiden<br/>Metrics] --> E[๐Ÿง  Maya<br/>Synthesis]
        B[๐Ÿƒโ€โ™‚๏ธ Marcus<br/>Activity Data] --> C[๐Ÿ” Elena<br/>Interpreter]
        D[โค๏ธ Dr. Helena<br/>Physiology] --> E
        C --> E
        E --> F[๐Ÿ“‹ James<br/>Analysis Formatter]
        F --> PR[๐Ÿ–ผ๏ธ Plot Resolution]
    end

    subgraph Planning Team
        S[๐Ÿงญ Coach Magnus<br/>Season Planner] --> DI[๐Ÿงฉ Data Integration]
        DI --> W[๐Ÿ“… Coach Magnus<br/>Weekly Planner]
        W --> PXF[๐ŸŽจ Pixel<br/>Plan Formatter]
    end

    %% Integrated flow from analysis to planning
    PR --> S

    %% Weekly planner consumes analysis results directly (kept simple)
    A -. signals .-> W
    C -. patterns .-> W
    D -. physiology .-> W

    %% Outputs
    F --> G1[๐Ÿ“Š Analysis HTML]
    PXF --> G2[๐Ÿ“„ Planning HTML]
Loading

Each agent brings specialized expertise:

  • Dr. Aiden Nakamura (Metrics) - Training load, VOโ‚‚ max trends, performance metrics
  • Marcus Chen (Activity Data) - Raw training data processing and pattern recognition
  • Elena Rodriguez (Activity Interpreter) - Training pattern analysis and execution insights
  • Dr. Helena Virtanen (Physiology) - Recovery, stress, and physiological markers
  • Maya Lindholm (Synthesis) - Combines insights into comprehensive analysis
  • James Morrison (Analysis Formatter) - Creates analysis HTML and handoff artifacts
  • Coach Magnus Thorsson (Season Planner) - Long-term periodization frameworks and peak timing
  • Coach Magnus Thorsson (Weekly Planner) - Practical 14โ€‘day training plans with zones and adaptations
  • Data Integration (Planning) - Integrates analysis, plots, and competitions to contextualize planning
  • Pixel (Plan Formatter) - Produces professional planning HTML with interactive checklists

๐Ÿ“Š Beautiful Analysis Reports

Analysis Dashboard Executive summary and key performance indicators with readiness signals

Activity Analysis Execution patterns and coaching notes derived from recent runs and rides

Load Balance Plot (ACWR vs Chronic) Bubble map of ACWR versus chronic load (marker size = acute load) with annotated highโ€‘risk exposures

Analysis Report Features:

  • ๐ŸŽฏ Executive Summary with key findings and readiness scores
  • ๐Ÿ“ˆ Interactive Training Load Charts with ACWR analysis
  • โค๏ธ Physiological Adaptation Tracking (HRV, stress patterns, VOโ‚‚ max)
  • โš ๏ธ Critical Pattern Analysis identifying training inconsistencies
  • ๐Ÿ Competition Readiness Assessment with timeline planning
  • ๐Ÿ’ก Actionable Recommendations prioritized by urgency

๐Ÿ“… Detailed Training Plans

Season Planning Phases Periodized macrocycle with phase-specific goals, timeline, and progression guardrails

Daily Workout Details Structured day plan with intensity zones, adaptations, and monitoring cues

Planning Report Features:

  • ๐Ÿ—๏ธ Season-Long Periodization with phase-specific goals
  • ๐Ÿ“‹ Day-by-Day Workout Details with intensity zones and adaptations
  • ๐ŸŽฏ Training Zone References for running, cycling, and swimming
  • ๐Ÿ“Š Volume and Intensity Monitoring with built-in flexibility
  • ๐Ÿ”„ Adaptive Workout Options based on readiness and fatigue

๐Ÿš€ Quick Start (CLI-first)

# 1) Create your configuration
pixi run coach-init my_training_config.yaml

# 2) Edit the config with your details, then run
pixi run coach-cli --config my_training_config.yaml

CLI command reference

# Run with an existing config
python cli/garmin_ai_coach_cli.py --config my_training_config.yaml [--output-dir ./data]

# Generate a new config template
python cli/garmin_ai_coach_cli.py --init-config my_training_config.yaml

Options:

  • --config PATH โ€” Path to YAML or JSON config
  • --init-config PATH โ€” Create a template config at PATH
  • --output-dir PATH โ€” Override output directory from config

Outputs:

  • analysis.html - Comprehensive performance analysis
  • planning.html - Detailed weekly training plan
  • metrics_result.md, activity_result.md, physiology_result.md, season_plan.md - Intermediate artifacts
  • summary.json - Metadata and cost tracking with keys:
    • total_cost_usd, total_tokens, execution_id, trace_id, root_run_id, files_generated, competitions

Legacy: Telegram Bot (Deprecated)

The Telegram chat interface is deprecated and will be removed in a future release. Prefer the CLI. If you still need to use it temporarily:

pixi run start-dev

Requires TELE_BOT_KEY in your environment. See the โ€œProject Structureโ€ section for legacy notes.

๐Ÿ’ป Installation & Setup

Prerequisites

  • Garmin Connect account (your training data source)
  • LLM API key for your chosen provider (OpenAI, Anthropic, or OpenRouter)
  • Optional: LANGSMITH_API_KEY for observability
  • Legacy Telegram bot requires TELE_BOT_KEY โ€” see โ€œLegacy: Telegram Bot (Deprecated)โ€ above

Using Pixi (Recommended)

  1. Create your environment file:
# .env (or .env.dev)

# Choose at least one provider
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
OPENROUTER_API_KEY=...
LANGSMITH_API_KEY=lsv2_...  # Optional: professional observability

# AI mode default (overridden by config's extraction.ai_mode)
AI_MODE=development

Important: Provider mapping and AI mode

  1. Install and run (CLI):
pixi run coach-init my_training_config.yaml
pixi run coach-cli --config my_training_config.yaml

Alternative Installation (CLI without Pixi)

pip install -r requirements.txt
python cli/garmin_ai_coach_cli.py --init-config my_training_config.yaml
python cli/garmin_ai_coach_cli.py --config my_training_config.yaml

๐ŸŽ›๏ธ AI Configuration & Models

AI Modes

Choose your analysis depth and cost balance:

  • development - Fast iterations, cost-effective (7-14 days data)
  • standard - Comprehensive analysis (21-56 days data)
  • cost_effective - Balanced approach for budget-conscious users

Supported LLM Providers

  • ๐Ÿค– OpenAI

    • gpt-5, gpt-5-mini
    • gpt-4.5, gpt-4.1, gpt-4o, gpt-4o-mini
    • o1, o1-mini, o3, o3-mini, o4-mini
  • ๐Ÿง  Anthropic Claude

    • claude-4, claude-4-thinking
    • claude-opus, claude-opus-thinking
    • claude-3-haiku
  • ๐Ÿš€ OpenRouter/DeepSeek

    • deepseek-chat, deepseek-reasoner

Configure in services/ai/ai_settings.py by updating the stage_models mapping in python.AISettings().

Important โ€” provider selection depends on your AI mode:

  • Default mapping in services/ai/ai_settings.py:
    • standard โ†’ gpt-5 (OpenAI)
    • development โ†’ claude-4 (Anthropic)
    • cost_effective โ†’ claude-3-haiku (Anthropic)
  • The CLI exports AI_MODE from your configโ€™s extraction.ai_mode at cli/garmin_ai_coach_cli.py.
  • If you only set OPENAI_API_KEY, use ai_mode: "standard" (default maps to an OpenAI model) or update stage_models to point your chosen mode to an OpenAI model (e.g., gpt-4o, gpt-5-mini) in services/ai/ai_settings.py. Available model IDs are defined in python.ModelSelector.CONFIGURATIONS, and the provider is auto-selected in python.ModelSelector.get_llm().
  • If you only set ANTHROPIC_API_KEY, keep ai_mode: "development" or "cost_effective" (both map to Anthropic by default) or change the mapping.
  • If you use OpenRouter (e.g., DeepSeek), map your mode to an OpenRouter model key from python.ModelSelector.CONFIGURATIONS.

๐Ÿ“‹ Configuration

Analysis vs Planning context:

  • Analysis context: how to interpret past data (e.g., risk tolerance, injury notes, priorities)
  • Planning context: how to plan future training (e.g., emphasis, constraints, races). This is freeform text interpreted by the AI.

Minimal config

athlete:
  name: "Your Name"
  email: "[email protected]"

context:
  analysis: "Recovering from injury; focus on base building"
  planning: "Olympic triathlon in 12 weeks; build aerobic base"

extraction:
  activities_days: 7
  metrics_days: 14
  ai_mode: "development"   # or "standard" or "cost_effective"

competitions:
  - name: "Target Race"
    date: "2026-04-15"
    race_type: "Olympic"
    priority: "A"

output:
  directory: "./data"

credentials:
  password: ""   # Leave empty to be prompted securely at runtime

Advanced config (derived from real usage)

athlete:
  name: "Athlete Name"
  email: "[email protected]"

context:
  analysis: |
    Completed my first 70.3 recently. Great result but exposed durability gaps
    due to last-minute shoe change. Analyze this multisport activity in detail.

  planning: |
    ## Start Date
    Plan should start on **Monday, xxxx-xx-xx**.

    ## Important Needs
    - Functional Strength, Durability & Triathlon Transfer
      Integrate explicit daily micro-workouts (5โ€“10 min).
      Goals: run economy & lower-leg robustness; bike posture & core transfer; durability & recovery.

    - Shoe Adaptation & Running Technique
      Get used to carbon plate shoes (front-foot style) with targeted technique/strength.

    ## Session Constraints (Shoes)
    - Per-session shoe exclusivity: every run is tagged either `carbon` or `non-carbon`.

    ## Training Preferences
    - No indoor bike trainer available.
    - No swimming for now.

    ## Training Zones
    | Discipline | Base Metric                  |
    |------------|------------------------------|
    | Running    | LTHR โ‰ˆ 173 bpm / 4:35 min/km |
    | Cycling    | FTP โ‰ˆ 271W                   |
    | Heart Rate | Max HR โ‰ˆ 193 bpm             |

    ## Closing
    Provide structured daily checklists to support both athletic and personal goals.

extraction:
  activities_days: 21
  metrics_days: 56
  ai_mode: "standard"

competitions:
  - name: "Franklin Meilenlauf"
    date: "2025-10-12"
    race_type: "Half Marathon"
    priority: "A"
    target_time: "01:40:00"

output:
  directory: "./data"

credentials:
  password: ""  # leave empty for secure interactive input

Tip: The advanced details live inside the context.planning text; the system is instruction-following and will respect these constraints.

๐Ÿ—๏ธ Architecture Deep Dive

LangGraph Workflow System

Modern state-based AI orchestration with built-in observability:

# Parallel Analysis Phase
START โ†’ [Metrics, Physiology, Activity Data] โ†’ Activity Interpreter
                โ†“                โ†“                    โ†“
            Synthesis Agent โ† โ† โ† โ† โ† โ† โ† โ† โ† โ† โ† โ† โ†
                โ†“
         HTML Formatter โ†’ Plot Resolution โ†’ END

Key Benefits:

  • โœ… Built-in Observability - Professional LangSmith monitoring
  • โœ… Parallel Execution - Metrics + Physiology agents run simultaneously
  • โœ… Automatic State Management - Typed state with reducers
  • โœ… Error Recovery - Node-level handling and retries

Security Architecture

๐Ÿ” Local Encryption โ†’ ๐Ÿ“Š Data Processing โ†’ ๐Ÿค– AI Analysis โ†’ ๐Ÿ“‹ Report Generation
     (Per-user keys)      (In-memory)        (API calls)      (Local storage)
  • Encrypted Credentials - AES-256 encryption with per-user keys
  • Local Data Storage - No cloud persistence of personal data
  • Secure API Calls - Direct LLM provider communication
  • Usage Tracking - Transparent cost monitoring

๐Ÿ“Š Project Structure

garmin-ai-coach/
โ”œโ”€โ”€ ๐Ÿค– bot/                     # Telegram interface & handlers (deprecated)
โ”œโ”€โ”€ ๐Ÿ”’ core/security/           # Encryption & usage limits
โ”œโ”€โ”€ ๐Ÿ”ง services/
โ”‚   โ”œโ”€โ”€ ๐Ÿƒโ€โ™‚๏ธ garmin/              # Data extraction & models
โ”‚   โ”œโ”€โ”€ ๐Ÿง  ai/langgraph/        # Modern AI workflow system
โ”‚   โ””โ”€โ”€ ๐ŸŽจ ai/tools/plotting/   # Secure visualization tools
โ”œโ”€โ”€ ๐Ÿ“š agents_docs/             # Architecture & planning docs
โ”œโ”€โ”€ โšก cli/                     # CLI (primary interface)
โ”œโ”€โ”€ ๐Ÿš€ main.py                  # Legacy Telegram bot entry point (deprecated)
โ””โ”€โ”€ โš™๏ธ pixi.toml                # Dependencies & tasks

๐Ÿ”ง Development Commands

# Code Quality
pixi run lint-ruff              # Linting
pixi run ruff-fix              # Auto-fix issues  
pixi run format                # Black + isort formatting
pixi run type-check            # MyPy type checking

# Testing & Analysis
pixi run test                  # Run test suite
pixi run dead-code             # Find unused code (Vulture)

# Utilities  
pixi run list-users            # User management

๐ŸŽฏ What's Next

๐Ÿ”ฎ Roadmap

  • ๐Ÿ”— Platform Integration - Wahoo Integration

๐Ÿ† Success Stories

"The AI coaching insights helped me identify training inconsistencies I never would have caught myself. My Olympic distance time dropped by 14 minutes!"


๐Ÿ’ก Why garmin-ai-coach?

For Athletes:

  • ๐ŸŽฏ Get personalized insights your Garmin doesn't provide
  • ๐Ÿ“ˆ Understand your training patterns and physiological adaptations
  • ๐Ÿƒโ€โ™‚๏ธ Receive science-backed recommendations for improvement
  • โฐ Save hours of manual data analysis

For Coaches:

  • ๐Ÿ“Š Comprehensive athlete analysis in minutes, not hours
  • ๐Ÿง  AI-powered pattern recognition across multiple data streams
  • ๐Ÿ“‹ Professional reports to share with athletes
  • ๐Ÿ” Identify training issues before they become problems

For Developers:

  • ๐Ÿ—๏ธ Modern LangGraph architecture with professional observability
  • ๐Ÿ”’ Security-first design with comprehensive encryption
  • ๐Ÿ“ˆ Scalable multi-agent system with parallel processing
  • ๐ŸŽจ Beautiful visualization tools and report generation

๐Ÿ“„ License

MIT License - see LICENSE for details.


๐Ÿค Contributing

We welcome contributions! The codebase uses modern Python practices with:

  • LangGraph for AI workflow orchestration
  • Pydantic v2 for data validation
  • Pixi for dependency management
  • Ruff + Black for code formatting

Built with โค๏ธ for the triathlon community


Ready to transform your training data into actionable insights?

git clone https://github.com/your-username/garmin-ai-coach.git
cd garmin-ai-coach
pixi run coach-init my_training_config.yaml
pixi run coach-cli --config my_training_config.yaml

Your AI triathlon coach awaits! ๐ŸŠโ€โ™‚๏ธ๐Ÿšดโ€โ™‚๏ธ๐Ÿƒโ€โ™‚๏ธ

About

AI-powered Garmin training insights & coaching

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 94.6%
  • Jupyter Notebook 4.2%
  • Other 1.2%