Skip to content

cofrian/Proyecto_fitplanner

Β 
Β 

Repository files navigation

πŸ‹οΈ FitPlanner

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.

CI Python Streamlit License: MIT


πŸ“– About the project

The user fills in a form with their goal, experience level, sex, weight, height, age and weekly activity. From there, FitPlanner:

  1. 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).
  2. Assigns a workout routine from a dataset of 112 routines scraped from Muscle & Strength, filtered by level, goal and sex.
  3. Generates a weekly menu (breakfast, lunch and dinner Γ— 7 days) with ingredients, cooking instructions and macros, via the Spoonacular API.
  4. 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.

πŸ”„ Project flow

Project flow

✨ Features

πŸ‹οΈ 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.

πŸ—‚οΈ Datasets

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

πŸ› οΈ Tech stack

  • 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

πŸš€ Installation

# 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.txt

πŸ”‘ API key setup

The 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/.env

Edit 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.

πŸ§‘β€πŸ’» Usage

Launch the application from the repository root:

streamlit run App/app.py

It will open at http://localhost:8501. Fill in the form and click Generar Plan to see your routine, weekly menu and deals.

Notebooks

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.

πŸ§ͺ Tests

pytest

The 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.


πŸ“‚ Project structure

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

πŸ—ΊοΈ Limitations and next steps

  • 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_calorias and busqueda_ofertas.

🀝 Contributing

  1. Fork the repository.
  2. Create a branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Open a Pull Request.

πŸ‘₯ Authors

Built as a team of three by:

Author GitHub
Imad Rifai @ImadRifai
Fernando MartΓ­nez GΓ³mez @Nandirin
Sergio Ortiz @cofrian

πŸŽ“ Academic context

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.

πŸ“ License

Distributed under the MIT License. See LICENSE for details.

πŸ“š Additional documentation

About

πŸ‹οΈ Streamlit app that builds personalized workout routines, calorie-based meal plans and matching sports gear deals β€” powered by web scraping, REST APIs and fuzzy matching.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 93.7%
  • Python 6.3%