name: fitness-app-tools description: Provides reference GitHub repositories, food nutrition APIs, and fitness calculation formulas for building Qt/QML fitness apps. Use when developing diet logging, exercise tracking, macro calculation, BMR/MET, or integrating Open Food Facts/USDA FoodData Central.
Fitness App Development Tools
Reference repositories, APIs, and formulas for fitness app development with Qt/QML and C++. Apply when implementing nutrition tracking, exercise logging, or calorie/macro calculations.
1. Reference GitHub Repositories
| Repo | Description | Tech |
|---|---|---|
| LiftLog | Gym activity tracking, exercise logging | C++, Qt 5.x, QML, Qt Quick Controls 1 |
| QML-OpenFitnessPal | FOSS MyFitnessPal alternative, diet + macro tracking | QML, Android |
| fitness_planner | Qt-based gym planner | Qt, GPL-2.0 |
| QtHealth | Cross-platform health/fitness data access (HealthKit, etc.) | Qt, plugin system |
| openfoodfacts-server | Open Food Facts backend/API reference | Server-side |
When to reference: Architecture patterns, QML layout for diet/exercise screens, storage models, API client structure.
2. Food & Nutrition APIs
Open Food Facts
- Docs: https://openfoodfacts.github.io/openfoodfacts-server/api/
- Search:
GET https://world.openfoodfacts.org/cgi/search.pl?search_terms={query}&search_simple=1&json=1 - Product by barcode:
GET https://world.openfoodfacts.org/api/v2/product/{barcode}.json - Rate limits: ~10 req/min search, ~100 req/min product; no auth for read.
- Data:
product.nutriments(energy_100g, proteins_100g, carbohydrates_100g, fat_100g), Nutri-Score.
USDA FoodData Central
- Docs: https://fdc.nal.usda.gov/api-guide
- Search:
GET https://api.nal.usda.gov/fdc/v1/foods/search?api_key={key}&query={query} - Food details:
GET https://api.nal.usda.gov/fdc/v1/food/{fdcId}?api_key={key} - Requirements: Free API key from data.gov; 1,000 req/hour per IP.
- Data:
foodNutrientsarray with nutrient IDs (e.g. 1003=protein, 1005=carb, 1004=fat).
3. Fitness Calculation Formulas
Macro & Calorie
calories_per_portion = (energy_100g / 100) × portion_grams
protein_g = (proteins_100g / 100) × portion_grams
carb_g = (carbohydrates_100g / 100) × portion_grams
fat_g = (fat_100g / 100) × portion_grams
BMR (Mifflin-St Jeor)
male: 10 × weight(kg) + 6.25 × height(cm) - 5 × age + 5
female: 10 × weight(kg) + 6.25 × height(cm) - 5 × age - 161
Exercise calories (MET-based)
calories_burned = 0.0175 × MET × weight(kg) × duration_minutes
Common MET values: walking 2.0–3.5, jogging 7.0, running 5mph 8.3, cycling 5.8, swimming 5.8.
Full MET table: Compendium of Physical Activities or see reference.md.
4. Quick Workflow
- Choose data source: Open Food Facts for packaged products; USDA FDC for generic foods.
- Implement API client in
src/services/(e.g.FoodSearchService); useQNetworkAccessManager. - Store locally in SQLite via
StorageService; cache search results and fetched products. - Expose to QML via
Q_PROPERTYor context property; keep UI inqml/pages/,qml/components/. - Follow project conventions: See
qt-code-standardsskill for Qt/QML/C++ structure.
5. Additional Reference
- API response structures, full MET table, and integration examples: reference.md