← Back to blog
Case Study

July 1, 2025

Custom GPTPHPGCP Cloud Functionsintervals.icu APIOpenAIRAG

AI Nutrition Coach for Endurance Athletes

Building a personal AI assistant that synthesizes training load, wellness metrics, and sports science to deliver evidence-based daily nutrition guidance for endurance athletes.

The Challenge

As an endurance cyclist preparing for competition, I was meticulously tracking wellness data – HRV, resting heart rate, training load (ATL/CTL), weight, and calorie intake. Despite years of structured training and a lean baseline, I struggled to optimize nutrition around training blocks and break through a stubborn fat-loss plateau.

The core questions I needed answered daily:

  • How many carbs do I need today given my VO2max intervals tomorrow?
  • Should I adjust my deficit based on my current fatigue (ATL) and HRV trends?
  • Am I under-fueling or over-fueling around my key sessions?

What I wanted to build:

  • An AI assistant that could access my real-time training and wellness data
  • Evidence-based recommendations grounded in sports nutrition science
  • Personalized fueling strategies adapted to my training periodization
  • Clear reasoning so I could learn the principles, not just follow instructions

The Approach

1. Evidence Synthesis with LLMs

Started by leveraging advanced LLMs (particularly the o3 reasoning model) to systematically search, summarize, and critically appraise scientific literature in exercise physiology and sports nutrition. This built an evidence base grounded in current meta-analyses and best practices.

2. Building RAG with Personal Knowledge

Incorporated my personal library into the system:

  • Training logs and structured workout templates
  • Research PDFs on endurance nutrition and periodization
  • Notes from key resources like Andy Galpin's "Perform" podcast series

Used Google's NotebookLM to unify diverse sources and generate accessible summaries, improving both depth and accessibility of the knowledge base.

NotebookLM UI
NotebookLM UI with all related media about nutrition and sport performance already fed in

3. Crafting the System Prompt

Developed a comprehensive system prompt that encoded:

  • Athlete profile: Height, weight, max HR, threshold zones, FTP, BMR
  • Energy targeting: Daily kcal = Garmin TDEE minus deficit, with automatic adjustments for fatigue/HRV
  • Macro rules: Protein floors, fat minimums, carb periodization
  • Session fueling tables: Specific CHO/protein targets by workout type and duration
  • Cortisol management: Rules for when to ease deficit based on wellness signals
  • Sanity checks: Cross-validation of Garmin data against power meter readings

4. Real-Time Data Integration

Built a PHP API that aggregates metrics from multiple sources:

  • intervals.icu: Training load, HR, power, calories, ATL/CTL, TSB (unified API pulling from Garmin, Apple Health, Oura)
  • Wellness tracking: HRV, resting HR, weight trends
  • Activity data: Recent workouts, planned sessions, training stress scores

The API merges relevant endpoints into a single feed optimized for LLM consumption, including current date/time context to prevent temporal hallucinations.

Intervals.icu interface
Intervals.icu user interface with history view of previous activities
API response
Example of custom actions response with wellness data

5. Cloud Deployment

Migrated from initial PHP hosting to GCP for reliability:

  • Used Terraform for infrastructure-as-code deployment
  • Started with Google Cloud Run, optimized to Cloud Functions for cost efficiency under free tier
  • Achieved continuous, secure, low-latency access to all backend services

6. Custom GPT with Live Actions

Created a custom GPT on ChatGPT.com integrating:

  • The curated system prompt
  • Document library (research, training templates)
  • Live API endpoints for real-time data access

The assistant can fetch my current wellness state, recent activities, and training trends before generating recommendations.

Custom GPT interface
OpenAI custom GPT interface with knowledge base and live API actions

Daily Usage

The system became part of my daily routine. Typical interactions:

"How should I fuel today? I have threshold intervals planned."

The assistant would:

  1. Fetch current date/time context
  2. Pull 21-day wellness and activity history
  3. Check today's TDEE, HRV trend, ATL/CTL balance
  4. Compute target calories based on deficit rules and fatigue signals
  5. Return specific pre/intra/post fueling recommendations with gram targets
  6. Flag any cortisol or recovery concerns
ChatGPT conversation
21-day fat loss analysis with interpretation and daily recommendations
ChatGPT fueling plan
Personalized fueling plan based on current wellness context and planned training

Results

Performance outcomes:

  • Lost 1.2kg of fat over three weeks without negative effects on training quality
  • Sustained 0.4kg/week fat loss during competition preparation
  • Broke through a plateau that had persisted despite years of structured training

Knowledge outcomes:

  • Uncovered hidden problems in pre- and post-ride fueling habits
  • Understood my patterns of over-fueling on rest days and under-fueling around key sessions
  • Learned nutrition periodization principles through the assistant's explanations

Technical validation:

  • Cross-validated AI recommendations with independent Jupyter Notebook calculations
  • Confirmed calorie/deficit analysis matched weight trend predictions
Calories analysis
Analysis of calorie deficit/surplus vs. weight trends over time

What This Demonstrates

This project shows how powerful AI tooling can be when it has access to the right data and domain knowledge:

  1. Real-time data integration - Connecting LLMs to live wellness and training APIs transforms generic advice into actionable, personalized guidance
  2. Domain knowledge encoding - The system prompt captures complex sports science rules that adapt recommendations to physiological context
  3. Explainable recommendations - Every suggestion includes reasoning tied to specific data points, building trust and transferring knowledge
  4. Practical validation - Real results on a real athlete, not just a proof of concept

Tech Stack Details

Component Technology
AI Interface OpenAI Custom GPT with Actions
Knowledge Base RAG with NotebookLM, research documents
Data API PHP, migrated to GCP Cloud Functions
Data Sources intervals.icu (Garmin, Apple Health, Oura)
Infrastructure GCP Cloud Run/Functions, Terraform
Analysis Python, Jupyter Notebooks for validation
BG

Bruno Gardlo

Fractional AI Product Partner

Have a similar project in mind?

Let's discuss how I can help you build your AI product.

Book a 30-min intro call