Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥗 Hybrid Diet Recommendation Engine

A locally hosted, hybrid diet recommendation system that generates realistic Indian weekly meal plans using a combination of Content-Based Filtering (CBF) and Collaborative Filtering (CF).

The system calculates BMI, considers dietary goals and activity levels, and produces a 7-day meal plan (2000–2600 kcal/day) tailored to the user.


🚀 Project Overview

This application:

  • ✅ Runs entirely on localhost
  • ✅ Uses Java + Spring Boot (backend)
  • ✅ Uses HTML / CSS / JavaScript (frontend)
  • ✅ Uses static Indian food datasets
  • ✅ Generates weekly diet plans with calendar toggle UI
  • ✅ Works fully offline

🎯 Core Features

✅ User Inputs (Mandatory)

Input Options
Height cm
Weight kg
Dietary Goal Weight Loss, Maintenance, Muscle Gain
Dietary Type Vegetarian, Non-Vegetarian
Activity Level Sedentary, Moderate, Active

✅ Optional Inputs

  • Preferred foods
  • Disliked foods

🧠 Intelligent Logic

1️⃣ BMI Calculation

BMI is calculated using:

BMI = weight (kg) / (height in meters)²

The system categorizes the user into:

  • Underweight (BMI < 18.5)
  • Normal (18.5 ≤ BMI < 25)
  • Overweight (25 ≤ BMI < 30)
  • Obese (BMI ≥ 30)

2️⃣ Calorie Target (Realistic Indian Range)

The daily calorie intake is constrained between 2000 kcal – 2600 kcal.

It varies depending on:

  • Dietary goal
  • Activity level
  • BMI category

Example:

Goal Calorie Range
Weight Loss ~2000–2200 kcal
Maintenance ~2200–2400 kcal
Muscle Gain ~2400–2600 kcal

All recommendations reflect realistic Indian eating habits.

3️⃣ Hybrid Recommendation Model

🔹 Content-Based Filtering (CBF)

Matches foods based on:

  • Calories
  • Protein
  • Carbs
  • Fat
  • Dietary type
  • Meal type (breakfast/lunch/dinner)

Filters only Indian foods and respects veg/non-veg constraints.

🔹 Collaborative Filtering (CF)

  • Uses static user_interaction.csv
  • Identifies similar user preferences
  • Adjusts ranking scores

🔹 Hybrid Output

Final recommendation score:

Final Score = α × (CBF Score) + (1 - α) × (CF Score)

Where α is configurable (e.g., 0.7), ensuring personalization + nutritional accuracy.


📅 Weekly Plan Generation

The system generates a 7-day meal plan, with each day including:

  • 🌅 Breakfast
  • 🍛 Lunch
  • 🌙 Dinner

🔄 Calendar Toggle UI

Frontend includes:

  • Day-based navigation (Mon–Sun)
  • Simple clickable tabs
  • Dynamically loads meals for selected day
  • No page reload required

🏗️ System Architecture

Backend (Java + Spring Boot)

src/main/java/com/dietapp/
│
├── controller/
│   ├── UserController.java
│   ├── FoodController.java
│   └── RecommendationController.java
│
├── service/
│   ├── RecommendationService.java
│   ├── ContentBasedFilter.java
│   ├── CollaborativeFilter.java
│   └── MealPlanGenerator.java
│
├── model/
│   ├── UserPreference.java
│   ├── Food.java
│   ├── Meal.java
│   ├── MealPlan.java
│   └── DailyMealPlan.java
│
└── util/
    └── DataLoader.java

Frontend (HTML/CSS/JS)

src/main/resources/static/
│
├── index.html
├── css/
│   └── styles.css
└── js/
    └── script.js

📊 Dataset Structure

food_data.json

{
  "id": 101,
  "name": "Rajma Chawal",
  "calories": 520,
  "protein": 18,
  "carbs": 85,
  "fat": 8,
  "dietary_type": "vegetarian",
  "meal_type": "lunch"
}

user_interaction.csv

user_id,food_id,rating
1,101,5
1,205,4
2,101,3

🔧 Installation & Setup

1️⃣ Prerequisites

  • Java 11+
  • Maven
  • Web browser

2️⃣ Clone Repository

git clone <repository-url>
cd DietRecommendationEngine

3️⃣ Build Project

mvn clean install

4️⃣ Run Application

mvn spring-boot:run

5️⃣ Open in Browser

http://localhost:8080

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages