A full-stack diet recommendation system that generates personalized meal plans based on user health data (age, weight, height, activity level) or custom nutritional targets. The recommendation engine uses a content-based approach with cosine similarity over nutritional vectors to find the closest matching recipes from a dataset of 500,000+ Food.com recipes.
Key features:
- Automatic meal plan generation from personal health metrics (BMI, BMR, TDEE)
- Custom food search by nutritional values and ingredients
- Configurable weight loss plans (maintain, mild, moderate, extreme)
- Interactive nutritional breakdown charts
Recipes are embedded as 9-dimensional nutritional vectors (Calories, Fat, Saturated Fat, Cholesterol, Sodium, Carbohydrates, Fiber, Sugar, Protein). A NearestNeighbors model with cosine similarity finds the closest recipes to a given target vector.
- BMI — weight(kg) / height(m)²
- BMR — Mifflin-St Jeor equation
- TDEE — BMR × activity multiplier
- Target calories — TDEE × weight-loss factor
- Calories are distributed across meals (35/40/25% for 3 meals, etc.)
- Per-meal nutrition vectors are sampled from physiologically appropriate ranges and passed to the nearest-neighbor model
At startup, each recipe's ingredient list is pre-parsed into a frozenset of lowercase strings. Filtering then uses set-based substring matching — no regex scanning on every request.
| Advantage | Note |
|---|---|
| No cold-start problem | Works without any user history |
| Transparent recommendations | Results are directly tied to nutritional targets |
| No inter-user data needed | Fully self-contained per request |
| Component | Technology |
|---|---|
| Backend API | FastAPI 0.115, Python 3.12 |
| ML / Recommendation | scikit-learn 1.4 (NearestNeighbors, cosine) |
| Data processing | pandas 2.2, numpy 1.26 |
| Frontend | Streamlit 1.35 |
| Charts | streamlit-echarts 0.4 |
| Containerization | Docker, Docker Compose |
- Docker and Docker Compose
Option A — Use pre-built images (fastest, no build step):
git clone https://github.com/zakaria-narjis/nutrimind
cd nutrimind
docker compose pull
docker compose up -dOption B — Build from source:
git clone https://github.com/zakaria-narjis/nutrimind
cd nutrimind
docker compose up --build -dOpen http://localhost:8501 in your browser.
The frontend waits for the backend health check to pass before starting. The backend loads the ~95MB dataset at startup, so the first boot takes ~30–60 seconds.
https://diet-recommendation-system.streamlit.app/
Interactive docs are available at http://localhost:8080/docs when the backend is running.
Generates a full daily meal plan from personal health data.
Request body:
{
"age": 28,
"height": 175,
"weight": 70,
"gender": "Male",
"activity": "Moderate exercise (3-5 days/wk)",
"number_of_meals": 3,
"weight_loss": "Maintain weight"
}Response: BMI, BMR, daily calorie targets, and recommended recipes per meal.
Finds recipes matching a custom 9-value nutrition vector with optional ingredient filtering.
Request body:
{
"nutrition_input": [500, 20, 3, 50, 800, 60, 8, 5, 30],
"ingredients": ["chicken", "garlic"],
"params": {"n_neighbors": 5, "return_distance": false}
}Food.com recipes dataset — 500,000+ recipes from Kaggle.
@software{narjis_2024_12507829,
author = {Narjis, Zakaria},
title = {Diet recommendation system},
month = jun,
year = 2024,
publisher = {Zenodo},
version = {v1.0.1},
doi = {10.5281/zenodo.12507829},
url = {https://doi.org/10.5281/zenodo.12507829}
}
