A comprehensive training analytics platform that combines DuckDB for data processing with Metabase for visualization. This project helps athletes track and analyze their training stress, readiness, and performance metrics.
This project provides:
- Data Processing: DuckDB-based data pipeline for TrainingPeaks exports
- Analytics: Automated calculation of training stress ratios and readiness metrics
- Visualization: Metabase dashboard for interactive data exploration
- Export Capabilities: Standardized CSV exports for further analysis
TrainingReadiness/
├── src/training_readiness/etl/ # ETL pipeline
│ ├── extract_data/ # Data extraction scripts
│ │ ├── trainingpeaks/
│ │ │ ├── load_trainingpeaks_data.py
│ │ │ └── load_trainingpeaks_data.sql
│ │ └── hevy/
│ │ ├── extract_hevy_data.py
│ │ └── master_workout_processor.py
│ ├── transform_data/ # Data transformation scripts
│ │ ├── trainingpeaks/
│ │ │ └── clean_trainingpeaks_data.py
│ │ ├── hevy/
│ │ │ ├── hevy_pipeline.py
│ │ │ └── transform_hevy_data.py
│ └── stage_data/ # Data staging scripts
│ ├── apple_health/
│ │ ├── load_sleep_data.py
│ │ └── load_resting_hr_data.py
│ └── trainingpeaks/
│ ├── calculate_1wk_4wk_ratio_training_stress.py
│ ├── calculate_1wk_training_stress.py
│ └── calculate_48hr_training_stress.py
├── data/ # Generated data files
├── scripts/
│ └── manage_deps.py # Dependency management automation
├── docker/ # Metabase Docker setup
│ ├── docker-compose.yaml
│ ├── run_docker.sh
│ ├── metabase-setup.sh
│ ├── env.template
│ └── init-training.sql
├── docs/ # Project documentation
├── tests/ # Test suite
├── pyproject.toml # Project dependencies and configuration
└── Makefile # Build and management commands
-
Python Environment:
python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]"
The project uses modern Python packaging with
pyproject.toml. All dependencies are managed automatically. -
DuckDB CLI (optional but recommended):
brew install duckdb
-
Install DuckDB Extensions:
duckdb INSTALL excel; LOAD excel; .quit
The project includes automated scripts for loading TrainingPeaks export data:
cd src/training_readiness/etl/extract_data/trainingpeaks
python3 load_trainingpeaks_data.py <path/to/your/data.xlsx>Supported Formats:
- Excel files (
.xlsx,.xls) - CSV files (
.csv)
Loading Modes:
- Append (default): Adds new data to existing database
- Replace: Replaces all existing data with new data
python3 load_trainingpeaks_data.py <path/to/your/data.xlsx> -r
Before loading, you may need to clean your TrainingPeaks data:
cd src/training_readiness/etl/transform_data/trainingpeaks
python3 clean_trainingpeaks_data.pyNote: This tool requires standardized RPE (Rate of Perceived Exertion) tracking over time to create actionable reports.
The project includes several automated export scripts for common training metrics:
cd src/training_readiness/etl/stage_data/trainingpeaks
python3 calculate_1wk_4wk_ratio_training_stress.pyOutput: rolling_1wk_4wk_stress_ratio_YYYYMMDD_HHMMSS.csv
Metrics:
- Daily training stress
- 7-day rolling average stress
- 28-day rolling average stress
- Stress ratio (7-day / 28-day)
cd src/training_readiness/etl/stage_data/trainingpeaks
python3 calculate_1wk_training_stress.pyOutput: rolling_1wk_stress_YYYYMMDD_HHMMSS.csv
cd src/training_readiness/etl/stage_data/trainingpeaks
python3 calculate_48hr_training_stress.pyOutput: rolling_48hr_stress_YYYYMMDD_HHMMSS.csv
- Docker Desktop: Install from Docker Desktop
- Docker Login: May require
docker logoutfollowed bydocker loginto resolve 401 errors
-
Configure Environment:
- Copy
docker/env.templatetodocker/.env - Update the
.envfile with your configuration:# Metabase admin credentials MB_SETUP_EMAIL=your-email@example.com MB_SETUP_PASSWORD=your-password MB_SETUP_FIRST_NAME=Your MB_SETUP_LAST_NAME=Name MB_SITE_NAME=Training Readiness # Path configuration ICLOUD_DIR=/path/to/your/iCloud/project/directory LOCAL_DIR=/Users/yourusername/Docker/Training_Readiness
- Copy
-
Setup Local Directory:
mkdir -p /Users/yourusername/Docker/Training_Readiness cp docker/run_docker.sh /Users/yourusername/Docker/Training_Readiness/ cp docker/.env /Users/yourusername/Docker/Training_Readiness/
-
Start Metabase:
cd /Users/yourusername/Docker/Training_Readiness ./run_docker.sh up -d -
Access Metabase:
- Open browser to
http://localhost:3000 - Login with your configured credentials
- The external database connection will be automatically configured
- Open browser to
- Start in background:
./run_docker.sh up -d - Start with logs:
./run_docker.sh up - Stop containers:
./run_docker.sh down - Stop and remove volumes:
./run_docker.sh down -v
The setup automatically captures logs to the logs/ directory:
docker-compose.log: Overall Docker Compose logspostgres_db.log: PostgreSQL database logsmetabase.log: Metabase application logsmetabase_setup.log: Setup script logs
View logs in real-time:
tail -f logs/metabase_setup.log- Export training data from TrainingPeaks
- Load data into DuckDB using the provided scripts
- Calculate training metrics using the export queries
- Visualize results in Metabase dashboard
- Export standardized CSV files for further analysis
- Automated Data Processing: Streamlined pipeline from TrainingPeaks to analytics
- Training Stress Analysis: Rolling averages and stress ratios for readiness assessment
- Interactive Dashboards: Metabase-based visualization with drill-down capabilities
- Standardized Exports: Consistent CSV format for external analysis
- Docker-Based Deployment: Easy setup and management of the visualization layer
The project includes a comprehensive test framework to ensure code quality and reliability. See the Tests README for detailed information about:
- Running tests
- Test structure and organization
- Writing new tests
- Coverage reporting
- Troubleshooting test issues
# Run all tests
pytest
# Run with coverage
pytest --cov=src/training_readiness
# Run specific test categories
pytest tests/unit/datasources/apple_health/The project includes automated tools for dependency management. See docs/dependency-management.md for comprehensive guidance.
Quick reference:
# Before commits
make deps-check
# When adding new dependencies
# 1. Add to pyproject.toml
# 2. Install and validate
pip install -e .
make deps-validate
make deps-security
# For maintenance
make deps-upgradeable
make deps-update- Docker 401 Error: Run
docker logoutthendocker login - Metabase Not Starting: Check logs with
docker logs metabase - Data Loading Errors: Ensure Excel extension is installed in DuckDB
- Permission Issues: Make sure log files are writable
- Check the
project_docs/directory for detailed setup guides - Review container logs in the
logs/directory - Ensure all prerequisites are installed and configured
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the terms specified in the LICENSE file.