A comprehensive AI-powered health data platform that integrates WHOOP and Withings devices with a conversational agent interface. Chat with your health data using natural language queries!
- π€ AI Health Data Agent - Chat with your data using natural language
- π Comprehensive Data Integration - WHOOP + Withings APIs
- πΎ Sport-Specific Analysis - Tennis, running, and general workout tracking
- π Trend Analysis - Weight, recovery, sleep patterns over time
- π REST API - Complete FastAPI backend with documentation
- π¬ Web Chat Interface - Beautiful Gradio-powered chat UI
whoop-data/
βββ whoopdata/ # Main package directory
β βββ __init__.py
β βββ start.py # Main application launcher
β βββ etl.py # ETL pipeline logic
β βββ database.py # Database setup utilities
β βββ utils.py # Database loading utilities
β βββ model_transformation.py # Data transformation functions
β βββ agent/ # π€ AI Agent System
β β βββ __init__.py
β β βββ graph.py # LangGraph agent orchestration
β β βββ nodes.py # Agent nodes (supervisor, tools)
β β βββ tools.py # Health data tools for agent
β β βββ schemas.py # Agent state and configuration
β β βββ settings.py # Agent configuration
β βββ api/ # FastAPI routes
β β βββ __init__.py
β β βββ recovery_routes.py
β β βββ sleep_routes.py
β β βββ workout_routes.py
β β βββ withings_routes.py
β βββ models/ # SQLAlchemy ORM models
β β βββ __init__.py
β β βββ models.py
β βββ clients/ # API clients for WHOOP and Withings
β β βββ __init__.py
β β βββ whoop_client.py
β β βββ withings_client.py
β βββ schemas/ # Pydantic schemas
β β βββ __init__.py
β β βββ recovery.py
β β βββ sleep.py
β β βββ workout.py
β βββ crud/ # Database CRUD operations
β β βββ __init__.py
β β βββ recovery.py
β β βββ sleep.py
β β βββ workout.py
β βββ utils/ # Utility functions
β β βββ __init__.py
β β βββ db_loader.py # Database loading utilities
β β βββ date_filters.py # Date filtering utilities
β β βββ matplotlib_config.py # Chart configuration
β βββ tests/ # Test files
β β βββ __init__.py
β β βββ test_withings.py
β βββ analysis/ # Analysis scripts and notebooks
β βββ __init__.py
β βββ ...
βββ scripts/ # Helper scripts
β βββ create_tables.py # Database table creation
β βββ run_etl.py # Standalone ETL runner
βββ chat_app.py # π¬ Gradio chat interface
βββ start_health_chat.py # π Complete system launcher
βββ main.py # FastAPI application entry point
βββ run_app.py # Complete data pipeline + API server
βββ app.py # Main FastAPI application
βββ setup.py # Package configuration
βββ requirements.txt # Python dependencies
βββ .env # Environment variables
βββ AGENT_PERSONALITY_GUIDE.md # AI agent coaching style guide
βββ README.md
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install required packages
pip install -r requirements.txtCreate a .env file with your API credentials:
# WHOOP OAuth 2.0 (Browser-based authentication - no username/password needed!)
WHOOP_CLIENT_ID=your_whoop_client_id
WHOOP_CLIENT_SECRET=your_whoop_client_secret
# Withings OAuth credentials
WITHINGS_CLIENT_ID=your_withings_client_id
WITHINGS_CLIENT_SECRET=your_withings_client_secret
WITHINGS_CALLBACK_URL=http://localhost:8766/callback
# OpenAI API for AI agent functionality
OPENAI_API_KEY=your_openai_api_keyπ Note: WHOOP uses OAuth 2.0 browser authentication - you'll be redirected to login through their website when needed.
The system automatically creates the database and loads your health data:
# Complete setup: Creates database + Loads fresh data + Starts API server
python run_app.pyThis will:
- π¦ Create database tables (SQLite in
./db/whoop.db) - π Authenticate with WHOOP (browser popup for OAuth)
- π Authenticate with Withings (browser popup for OAuth)
- π Load your health data (recovery, workouts, sleep, weight, etc.)
- π Start the API server (http://localhost:8000)
π― Option A: Complete System (Recommended)
# Launches both API server (8000) + Chat interface (7860)
python start_health_chat.py㪠Option B: Chat Interface Only
# Just the chat interface (requires API server running separately)
python chat_app.pyπ€ AI Chat Interface: http://localhost:7860
Example Questions to Try:
- "Show me my tennis workouts from 2025"
- "What's my weight trend over the last 30 days?"
- "How has my recovery been this month?"
- "Get my latest sleep data and analyze my patterns"
- "Show me my running performance with TRIMP scores"
π REST API Access:
- Interactive API Docs: http://localhost:8000/docs
- Alternative Docs: http://localhost:8000/redoc
- Sample Endpoint: http://localhost:8000/recovery/latest
When you run python run_app.py, the system loads:
WHOOP Data:
- π Recovery scores (HRV, RHR, sleep quality)
- ποΈ Workout data (strain, heart rate zones, sports)
- π΄ Sleep tracking (stages, efficiency, duration)
Withings Data:
- βοΈ Weight & body composition (BMI, fat ratio, muscle mass)
- π Heart rate & blood pressure (systolic, diastolic)
The system automatically:
- Creates SQLite database at
./db/whoop.db - Sets up all required tables
- Handles data transformations and relationships
- Manages duplicate prevention
- WHOOP: OAuth tokens auto-refresh, occasional re-authentication needed
- Withings: Long-lived tokens with automatic refresh (rarely need to re-login)
- Tokens stored securely in hidden files with proper permissions
GET /recovery- Recovery scores and metricsGET /recovery/latest- Most recent recoveryGET /workout- Workout data and strainGET /workout/latest- Most recent workoutGET /sleep- Sleep performance dataGET /sleep/latest- Most recent sleep
GET /withings/weight- Weight and body compositionGET /withings/weight/latest- Most recent weightGET /withings/weight/stats- Weight statisticsGET /withings/heart-rate- Heart rate and blood pressureGET /withings/heart-rate/latest- Most recent heart rateGET /withings/summary- Withings data summary
python whoopdata/tests/test_withings.pypython scripts/run_etl.pypython scripts/create_tables.py- Activity is referenced in the context of a Physiological Cycle (Cycle for short).
- Current Cycle: Only has a Start Time. Past Cycles have both start and end times.
- A physiological day on WHOOP begins when you fall asleep one night and ends when you fall asleep the following night.
- Daily measure of body preparedness to perform.
- Recovery score: Percentage between 0 - 100% calculated in the morning.
- Calculated using previous day's data including RHR, HRV, respiratory rate, sleep quality, etc.
- GREEN (67-100%): Well recovered and primed to perform.
- YELLOW (34-66%): Maintaining and ready for moderate strain.
- RED (0-33%): Indicates the need for rest.
- Tracks sleep duration and stages: Light, REM, and Deep sleep.
- Calculates sleep need based on Sleep Debt and previous day's activity.
- Measurement of stress on the body, scored on a 0 to 21 scale.
- Based on Strain Borg Scale of Perceived Exertion.
- Strain scores tracked continuously throughout the day and during workouts.
- WHOOP tracks workouts and measures accumulated Strain over each workout.
Comprehensive documentation is available in the docs/ directory:
- Technical Documentation - Development logs, API changes, and troubleshooting
- Features Documentation - Feature specifications and configurations
For API documentation, visit http://localhost:8000/docs after starting the application.
This project is licensed under the MIT License - see the LICENSE file for details.