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.
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.
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.
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:
- Fetch current date/time context
- Pull 21-day wellness and activity history
- Check today's TDEE, HRV trend, ATL/CTL balance
- Compute target calories based on deficit rules and fatigue signals
- Return specific pre/intra/post fueling recommendations with gram targets
- Flag any cortisol or recovery concerns
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
What This Demonstrates
This project shows how powerful AI tooling can be when it has access to the right data and domain knowledge:
- Real-time data integration - Connecting LLMs to live wellness and training APIs transforms generic advice into actionable, personalized guidance
- Domain knowledge encoding - The system prompt captures complex sports science rules that adapt recommendations to physiological context
- Explainable recommendations - Every suggestion includes reasoning tied to specific data points, building trust and transferring knowledge
- 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 |