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

Skip to content

leonzzz435/garmin-ai-coach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 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.


๐Ÿ”— Quick Links


โœจ What Makes This Special

  • ๐Ÿ’ฌ Conversational AI agents โ€” Agents can ask clarifying questions during analysis and planning (HITL)
  • Parallel analysis across specialized agents (load, physiology, execution)
  • Interactive reports with evidence and actionable next steps
  • CLI-first, config-driven headless runs
  • Outside AthleteReg integration: optional auto-import of competitions (BikeReg, RunReg, TriReg, SkiReg)
  • โšก CLI interface for headless operation and automation
  • Privacy-first: local 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 28โ€‘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) Install dependencies
pixi install

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

# 3) 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

๐Ÿ’ป 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

Installing Pixi

Pixi is a fast, modern package manager for Python projects that simplifies dependency management.

Install pixi:

# macOS/Linux
curl -fsSL https://pixi.sh/install.sh | bash

# Windows (PowerShell)
iwr -useb https://pixi.sh/install.ps1 | iex

For alternative installation methods (Homebrew, Conda, manual), visit the official installation guide.

Verify installation:

pixi --version

Set up the project environment:

git clone https://github.com/leonzzz435/garmin-ai-coach.git
cd garmin-ai-coach

pixi install

This will automatically install all dependencies specified in pixi.toml and pixi.lock.

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"
  hitl_enabled: true       # Enable conversational agents (default: true)
  skip_synthesis: false    # Skip synthesis stage to save tokens (default: false)

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"
  hitl_enabled: true       # Enable human-in-the-loop interactions (default: true)

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.

Human-in-the-Loop (HITL) Mode

What is HITL?

When enabled (default), AI agents can pause during analysis or planning to ask you clarifying questions. This ensures the coaching advice addresses your specific situation, preferences, and constraints that might not be captured in your config file.

Example Interaction:

๐Ÿค– I noticed your last bike ran hot on HR compared to your norm. Any context I should know?

๐Ÿ‘ค Your answer: Yeah, I had terrible nutrition beforehand and just wasn't in good form that day.

๐Ÿ—๏ธ Architecture Deep Dive

LangGraph Workflow System

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

# Orchestrated Workflow
START โ†’ Master Orchestrator โ†’ [Metrics, Physiology, Activity Data]
              โ†“
        Synthesis Agent (Optional)
              โ†“
        Season Planner (Persisted)
              โ†“
        Weekly Planner (28 Days)
              โ†“
             END

Key Benefits:

  • โœ… Conversational Agents โ€” AI can ask for clarification during analysis (HITL)
  • โœ… 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 & Privacy

  • Local Credentials โ€” Stored securely in configuration files
  • Local Data Storage โ€” No cloud persistence of personal data
  • Direct API Calls โ€” Secure communication with LLM providers
  • Usage Tracking โ€” Transparent cost monitoring

๐Ÿ“Š Project Structure

garmin-ai-coach/
โ”œโ”€โ”€ ๐Ÿ”’ core/                     # Configuration management
โ”œโ”€โ”€ ๐Ÿ”ง 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)
โ””โ”€โ”€ โš™๏ธ 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)

๐ŸŽฏ 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 install
pixi run coach-init my_training_config.yaml
pixi run coach-cli --config my_training_config.yaml

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