Personalized workout routines, meal plans and sports gear deals β all in one app.
FitPlanner combines web scraping, REST APIs and a Streamlit interface to answer a simple question: "what do I train, what do I eat, and what should I buy?"
A university team project for the Data Science degree at UPV.
The user fills in a form with their goal, experience level, sex, weight, height, age and weekly activity. From there, FitPlanner:
- Calculates their daily calories using the Harris-Benedict equation, adjusted by activity factor and by goal (Β±300 kcal depending on whether they want to build muscle or lose fat).
- Assigns a workout routine from a dataset of 112 routines scraped from Muscle & Strength, filtered by level, goal and sex.
- Generates a weekly menu (breakfast, lunch and dinner Γ 7 days) with ingredients, cooking instructions and macros, via the Spoonacular API.
- Recommends discounted supplements by cross-referencing the supplements suggested by the routine against a catalogue of 5,023 Decathlon products, using fuzzy matching.
Note
The application interface is in Spanish, as it was built for a Spanish-speaking audience. This is a university team project β see Authors and Academic context.
| ποΈ Personalized routines | 112 unique routines filtered by goal, experience level and sex, including duration, days per week and required equipment. |
| π₯ Meal planner | A full weekly menu generated from the calculated calorie target, with ingredients, instructions and macronutrients. |
| π Decathlon deals | 5,023 products (250 brands, 257 product types) pulled from their internal API and matched against recommended supplements using fuzzywuzzy. |
| π Interactive UI | Multipage Streamlit app: form β complete plan. |
| Source | Method | Volume |
|---|---|---|
| Muscle & Strength | Scraping (requests + BeautifulSoup) |
112 routines / 534 detail rows |
| Decathlon | Internal API discovered via DevTools | 5,023 products |
| Spoonacular | Public REST API | Real time |
- Language: Python 3.10β3.11
- Web: Streamlit
- Scraping: Requests, BeautifulSoup, Selenium
- Data: Pandas, CSV/JSON
- Matching: FuzzyWuzzy
- Analysis: Matplotlib, Seaborn, statsmodels (ANOVA on prices/discounts)
- Logging & tests: Loguru, Pytest
# 1. Clone the repository
git clone https://github.com/cofrian/Proyecto_fitplanner.git
cd Proyecto_fitplanner
# 2. Create and activate a virtual environment
python -m venv env
env\Scripts\activate # Windows
source env/bin/activate # Linux / macOS
# 3. Install dependencies
pip install -r requirements.txtThe meal planner needs a free API key from Spoonacular. Copy the template and add your key:
cp .env.example Recetas/.env
cp .env.example App/.envEdit both files and replace the placeholders with your key. MealPlanner uses API_KEY6 by
default; the notebooks use API_KEY1βAPI_KEY5.
Note
Spoonacular's free tier allows 150 points/day, and a single weekly menu consumes a significant
share of that quota. That is why the project spreads the work across several keys.
The .env files are listed in .gitignore: never commit them.
Launch the application from the repository root:
streamlit run App/app.pyIt will open at http://localhost:8501. Fill in the form and click Generar Plan to see your
routine, weekly menu and deals.
The notebooks document how the data was collected and cleaned:
Rutinas/scraping_limpio_v3.ipynbβ scraping Muscle & Strength.Decathlon/decathlon.ipynbβ extraction via Decathlon's internal API, plus statistical analysis of prices and discounts.Recetas/mealplanner_draft.ipynbβ meal planner prototype.
Warning
The scraping notebooks are not reproducible as-is: they depend on HTTP headers and keys that are not published, and on third-party site structures that change over time. The resulting CSVs are committed to the repo, so the app runs without re-executing them.
pytestThe tests cover the API response filtering logic and the MealPlanner (with the API mocked, so
they consume no quota and need no key). They run automatically on GitHub Actions against Python
3.10 and 3.11.
Proyecto_fitplanner/
βββ App/ # Streamlit application
β βββ app.py # Input form (main page)
β βββ pages/output.py # Calorie calculation, routine, diet and deals
β βββ rutinas.csv # Workout dataset used by the app
β βββ productos_paginas.csv # Decathlon product catalogue
βββ Recetas/ # Meal planner module
β βββ mealplanner.py # Spoonacular API client
β βββ filtering.py # JSON response filtering
β βββ mealplanner_draft.ipynb # Prototype
β βββ obsolote_files/ # Earlier explorations
βββ Rutinas/ # Workout scraping and cleaning
β βββ scraping_limpio_v3.ipynb
β βββ csv_rutinas/ # CSV per category (chest, back, cardioβ¦)
β βββ Definitivo.csv
β βββ rutinas_expandidas.csv
βββ Decathlon/ # Product scraping and analysis
β βββ decathlon.ipynb
βββ tests/ # Pytest test suite
βββ .env.example # Configuration template
βββ requirements.txt
- Routine selection falls back to a random pick after filtering; it should always honour the goal/level/sex filters.
- Cache Spoonacular responses (
st.cache_data) to reduce quota usage. - Replace manual key rotation with proper quota handling and retries.
- Deploy to Streamlit Community Cloud with the key stored as a secret.
- Extend test coverage to
calcular_caloriasandbusqueda_ofertas.
- Fork the repository.
- Create a branch (
git checkout -b feature/new-feature). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature/new-feature). - Open a Pull Request.
Built as a team of three by:
| Author | GitHub |
|---|---|
| Imad Rifai | @ImadRifai |
| Fernando MartΓnez GΓ³mez | @Nandirin |
| Sergio Ortiz | @cofrian |
Coursework for ATD β AdquisiciΓ³n y TransmisiΓ³n de Datos (Data Acquisition and Transmission), part of the Bachelor's Degree in Data Science at the Universitat PolitΓ¨cnica de ValΓ¨ncia (UPV), academic year 2024/2025.
The subject's focus explains the shape of the project: the emphasis is on acquiring data from heterogeneous sources β scraping a website, reverse-engineering an internal API, and consuming a public REST API β and on transforming it into a single coherent dataset that feeds the application.
Distributed under the MIT License. See LICENSE for details.
- Summary documentation (in Spanish)
- Project presentation (in Spanish)
