← All Case Studies

Personal project2025 – Present · Full-Stack Builder

AI Marathon Coach Grounded in 28 Days of Actual Training Data

Built a marathon coach whose daily recommendation comes from a rules engine reading 28 days of activity and recent recovery signals, with a language model that explains the call but never makes it.

About this artifact

case-studyproductionmaintained

automation · part of Marathon Coach · since 2026

The Problem

Generic marathon training plans are static and do not adapt to current readiness, recovery, or long-run recency.

Data-heavy platforms can show ATL, CTL, and TSB trends, but athletes still need to interpret those signals and translate them into concrete next-step training decisions.

For marathon preparation, the daily recommendation had to reflect recent workload and recovery, with an explicit decision from rules that could be inspected. Conversational coaching needed grounded context without being confused with that deterministic daily decision.

The Approach

Integrated Garmin Connect to ingest activity history, heart rate, and daily wellness (sleep, HRV, resting HR, body battery, stress, readiness), starting with a 90-day activity backfill. A scheduled poller plus an on-demand "force sync" keeps the data current, with a sync-status panel surfacing freshness and failures.

Made the typed daily recommendation deterministic: the pipeline computes metrics from a 28-day activity window and combines them with recovery signals. Fourteen guardrail rules feed a decision engine that returns one of seven typed calls (PROCEED_AS_PLANNED, REDUCE_INTENSITY, SHORTEN_WORKOUT, SUBSTITUTE_RECOVERY_RUN, CROSS_TRAIN_OR_REST, FULL_REST, NEEDS_MORE_DATA), and the LLM narrates that decision.

Built a Whoop/Oura-style dashboard around endurance-critical signals: 12-week weekly volume and training load with an acute:chronic workload (ACWR) status pill, aerobic-efficiency drift, a training-consistency calendar heatmap with run-log drill-down, and recovery trends for sleep, HRV/resting HR, and readiness.

Computed training load (TRIMP) at read time so CSV imports and Garmin-polled activities share one formula, with no source-dependent drift, and no silently-zeroed load.

Implemented a separate multi-turn AI coaching interface using metrics derived from a 28-day activity window, the latest ten activities, and current recovery data. Chat calls the model directly on that constructed context; its conversational answers do not carry the daily recommendation's deterministic guarantee.

Exposed the public demo with the same safety controls as the finance tool: a hard daily cost ceiling, per-session rate caps, and a default-off kill switch.

The Impact

  • Each production recommendation is written to an audit record with its inputs, the guardrails that fired, and the call, so a day's training decision traces to the rule that produced it: an active pain flag, for example, returns FULL_REST whatever the training load says
  • The production coach reads real Garmin data through a 90-day initial activity backfill, scheduled polling, and on-demand sync; daily recommendations and chat metrics use a 28-day activity window
  • A wellness metric that fails to load stays empty instead of becoming a zero, so a sync failure cannot pass as a recovery reading in the recommendation
  • A glanceable dashboard turns raw history into trends (weekly load with an ACWR pill, aerobic-efficiency drift, a consistency heatmap, and recovery panels), each degrading gracefully when a signal is missing
  • Anyone can try the coaching interface without connecting an account: the public demo uses a fixed sample athlete with a right-calf pain flag. The demo does not run the rules engine; it returns a fixed REDUCE_INTENSITY call that the model narrates against the sample's data

Evidence

AI/MLHealth TechAPI IntegrationFull-StackAWS

Related