Smart Diet & Meal Recommendation System
A full-stack AI-powered nutrition platform that provides personalized meal recommendations using machine learning trained on 230K+ real recipes from Kaggle
Features β’ Demo β’ Installation β’ Contributing β’ License
NutriGuide AI is an open-source machine learning web application that provides personalized nutrition recommendations and intelligent meal planning. Built with modern technologies including React, Node.js, Express, MongoDB, and Python ML models, this system demonstrates the integration of AI/ML with web development for solving real-world health and nutrition problems.
Perfect for:
- π Students learning full-stack development with ML
- π¨βπ» Developers building health tech applications
- π¬ Researchers exploring nutrition recommendation systems
- πͺ Anyone interested in personalized nutrition technology
- 99.87% Accurate Predictions: Gradient Boosting model trained on 230K+ real recipes from Kaggle
- Personalized Calorie Targets: ML-powered daily calorie recommendations based on 14 features
- Smart Macronutrient Distribution: Automatic protein, carbs, and fats calculation
- Real Dataset: Trained on Food.com Recipes and Interactions dataset
- Secure Authentication: JWT-based auth with role-based access control (Admin/User)
- Comprehensive Health Profiles: Age, gender, weight, height, activity level, fitness goals
- Goal-Oriented Planning: Lose weight, maintain, or gain muscle mass
- Progress Dashboard: Visual analytics with charts and insights
- Responsive Design: Beautiful UI with animations (Framer Motion) that works on all devices
- 500+ Meal Database: Real nutritional data from Kaggle recipes
- Advanced Search: Filter by calories, protein, dietary preferences (vegan, vegetarian, keto)
- Allergen Filtering: Gluten-free, dairy-free, nut-free options
- Nutritional Breakdown: Complete macros and micronutrients per meal
- Meal Planning: Track daily intake and compare against targets
- Daily Nutrition Logging: Track meals and monitor progress
- Visual Charts: Interactive graphs using Recharts
- Calorie & Macro Tracking: Real-time comparison with AI targets
- Historical Data: View trends over time
- User Management: Admin dashboard with user oversight
- Meal Database Control: Add, edit, or remove meals
- Analytics Overview: System-wide statistics and insights
Note: Add screenshots and demo video here once deployed
- Landing Page
- Dashboard with Analytics
- Meal Search & Filtering
- Progress Tracking
- Admin Panel
π https://nutriguide-five.vercel.app
NutriGuide/
βββ backend/ # Node.js + Express.js Backend API
β βββ controllers/ # Route controllers
β βββ models/ # MongoDB schemas (User, Meal, Progress)
β βββ routes/ # API route definitions
β βββ middleware/ # Auth, validation, error handling
β βββ server.js # Main server entry point
β βββ package.json # Backend dependencies
β
βββ frontend/ # React + Vite Frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ services/ # API service layers
β β βββ store/ # Zustand state management
β β βββ utils/ # Utility functions
β β βββ App.jsx # Main app component
β β βββ main.jsx # Entry point
β βββ index.html
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ package.json # Frontend dependencies
β
βββ ml-service/ # Python ML Service
β βββ app.py # Flask API for ML predictions
β βββ train_model.py # Model training script
β βββ preprocess_data.py # Data preprocessing pipeline
β βββ models/ # Trained model files (.pkl)
β βββ data/ # Training datasets
β βββ requirements.txt # Python dependencies
β
βββ README.md # This file
- React 18 - UI library
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- React Router DOM - Client-side routing
- Zustand - State management
- React Hook Form - Form validation
- Recharts - Data visualization
- Axios - HTTP client
- React Hot Toast - Toast notifications
- Node.js - JavaScript runtime
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- bcryptjs - Password hashing
- Express Validator - Input validation
- Helmet - Security headers
- Morgan - HTTP logging
- CORS - Cross-origin resource sharing
- Python 3.x - Programming language
- Flask - Web framework for ML API
- NumPy - Numerical computations
- Pandas - Data manipulation
- Scikit-learn - ML algorithms (Random Forest, Gradient Boosting)
- Joblib - Model serialization
- Node.js (v18 or higher)
- Python (v3.8 or higher)
- MongoDB (v6 or higher)
- npm or yarn
cd /path/to/your/workspace
# Repository is already in: /Volumes/Apps & Others/Project/NutriGuidecd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Edit .env and update:
# - MONGODB_URI (your MongoDB connection string)
# - JWT_SECRET (random secure string)
# - ML_SERVICE_URL (Python ML service URL)
# Start MongoDB (if not running)
# macOS with Homebrew:
brew services start mongodb-community
# Start backend server
npm run devBackend will run on: http://localhost:5000
cd ml-service
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # macOS/Linux
# OR
venv\Scripts\activate # Windows
# Install Python dependencies
pip install -r requirements.txt
# Train the ML model
python train_model.py
# Start ML service
python app.pyML Service will run on: http://localhost:5001
cd frontend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Start development server
npm run devFrontend will run on: http://localhost:5173
The ML model has been trained using the Food.com Recipes and Interactions dataset from Kaggle with 231,637 real recipes and nutritional data!
Best Model: Gradient Boosting Regressor
βββ Test MAE: 5.62 calories (exceptionally low!)
βββ Test RΒ²: 0.9987 (99.87% accuracy)
βββ CV MAE: 6.42 calories (5-fold)
βββ Status: Production Ready β
Translation: The model predicts daily calorie needs with
an average error of only 5.62 calories - extremely accurate!
- Source: Kaggle Food.com Recipes Dataset
- Total Recipes Processed: 230,286 valid recipes
- Training Samples: 5,000 user profiles
- Meals Extracted: 500 diverse meals for database
- Features Engineered: 14 total features (8 base + 6 engineered)
Base Features (8):
- Age - User's age in years
- Gender - Encoded (Male=1, Female=0)
- Height - In centimeters
- Weight - In kilograms
- BMI - Body Mass Index (calculated)
- BMR - Basal Metabolic Rate (Mifflin-St Jeor equation)
- Activity Level - Encoded (0-4: sedentary to very active)
- Fitness Goal - Encoded (0-2: lose, maintain, gain)
Engineered Features (6): 9. BMI Γ Age interaction 10. Weight/Height ratio 11. BMR Γ Activity interaction 12. Age squared 13. BMI squared 14. Activity Γ Goal interaction
# 1. Load Real Kaggle Dataset
python train_model_with_real_data.py
# Output: Loads 230K+ recipes, generates 5K user profiles, trains 4 models
# 2. Extract Meal Database from Kaggle
python create_meal_database.py
# Output: Creates 500 diverse meals with full nutrition data
# 3. Seed MongoDB Database
cd ../backend
npm run seed
# Output: Populates MongoDB with real meal data
# 4. View Training Results
cat models/model_stats.json
# {
# "best_model": "Gradient Boosting",
# "test_mae": 5.62,
# "test_r2": 0.9987,
# "cv_mae": 6.42
# }| Model | Test MAE | Test RΒ² | Status |
|---|---|---|---|
| Gradient Boosting β | 5.62 cal | 0.9987 | Selected |
| Random Forest | 6.75 cal | 0.9976 | Runner-up |
| Ridge Regression | 47.40 cal | 0.9897 | Good baseline |
| Linear Regression | 47.43 cal | 0.9896 | Baseline |
Test Case 1: 25yo male, 175cm, 70kg, moderate activity, lose weight
β Predicted: 2,094 calories/day β
Test Case 2: 30yo female, 165cm, 60kg, light activity, maintain
β Predicted: 1,800 calories/day β
Test Case 3: 22yo male, 180cm, 75kg, active, gain muscle
β Predicted: 3,377 calories/day β
POST http://localhost:5001/predict
Content-Type: application/json
{
"age": 25,
"gender": "male",
"height": 175,
"weight": 70,
"activity_level": "moderate",
"fitness_goal": "maintain_weight"
}Response:
{
"success": true,
"daily_calories": 2400,
"macronutrients": {
"protein": 180,
"carbs": 240,
"fats": 80
},
"bmi": 22.86,
"bmr": 1680,
"recommendations": [...]
}http://localhost:5000/api
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "SecurePass123",
"age": 25,
"gender": "male",
"height": 175,
"weight": 70,
"activityLevel": "moderate",
"fitnessGoal": "maintain_weight"
}POST /api/auth/login
Content-Type: application/json
{
"email": "john@example.com",
"password": "SecurePass123"
}Response:
{
"success": true,
"data": {
"user": {...},
"token": "jwt_token_here"
}
}GET /api/users/dashboard
Authorization: Bearer <token>PUT /api/users/profile
Authorization: Bearer <token>
Content-Type: application/json
{
"weight": 72,
"activityLevel": "active"
}GET /api/nutrition/recommendations
Authorization: Bearer <token>POST /api/nutrition/meal-plan
Authorization: Bearer <token>
Content-Type: application/json
{
"date": "2026-01-02",
"mealTypes": ["breakfast", "lunch", "dinner", "snack"]
}GET /api/progress/today
Authorization: Bearer <token>POST /api/progress/log-meal
Authorization: Bearer <token>
Content-Type: application/json
{
"mealId": "meal_id_here",
"servings": 1
}PUT /api/progress/update-weight
Authorization: Bearer <token>
Content-Type: application/json
{
"weight": 69.5
}GET /api/meals?category=breakfast&maxCalories=500GET /api/meals/search/recommendations?calorieTarget=400
Authorization: Bearer <token>{
_id: ObjectId,
name: String,
email: String (unique),
password: String (hashed),
age: Number,
gender: String,
height: Number,
weight: Number,
bmi: Number,
activityLevel: String,
fitnessGoal: String,
dailyCalorieTarget: Number,
macronutrients: {
protein: Number,
carbs: Number,
fats: Number
},
dietaryPreferences: [String],
allergies: [String],
role: String,
createdAt: Date,
updatedAt: Date
}{
_id: ObjectId,
name: String,
description: String,
category: String,
nutrition: {
calories: Number,
protein: Number,
carbohydrates: Number,
fats: Number,
fiber: Number,
sugar: Number
},
dietaryTags: [String],
allergens: [String],
ingredients: [Object],
prepTime: Number,
cookTime: Number,
createdAt: Date,
updatedAt: Date
}{
_id: ObjectId,
user: ObjectId (ref: User),
date: Date,
weight: Number,
nutrition: {
calories: Number,
protein: Number,
carbohydrates: Number,
fats: Number
},
meals: [{
mealId: ObjectId (ref: Meal),
mealName: String,
servings: Number,
calories: Number,
consumedAt: Date
}],
compliance: {
calorieCompliance: Number,
macroCompliance: Number
},
createdAt: Date,
updatedAt: Date
}- Landing Page (
/) - Public homepage with features - Login Page (
/login) - User authentication - Register Page (
/register) - New user registration - Dashboard (
/dashboard) - Main user dashboard with health overview - Meals Page (
/meals) - Browse and search meal database - Progress Page (
/progress) - Track nutrition with charts - Profile Page (
/profile) - Update user settings - Admin Dashboard (
/admin) - Admin panel (admin only)
- Layout - Main layout with sidebar navigation
- PrivateRoute - Protected route wrapper
- AdminRoute - Admin-only route wrapper
- StatsCard - Reusable stat display card
- MacroCard - Macronutrient progress card
# Register via UI at http://localhost:5173/register
# Or use API:
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Test User",
"email": "test@example.com",
"password": "Test123",
"age": 25,
"gender": "male",
"height": 175,
"weight": 70,
"activityLevel": "moderate",
"fitnessGoal": "maintain_weight"
}'curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "test@example.com",
"password": "Test123"
}'curl -X POST http://localhost:5001/predict \
-H "Content-Type: application/json" \
-d '{
"age": 25,
"gender": "male",
"height": 175,
"weight": 70,
"activity_level": "moderate",
"fitness_goal": "maintain_weight"
}'We love contributions! Whether you're fixing bugs, adding features, or improving documentation, your help is welcome.
Our main branch is protected! This means:
- β All changes go through Pull Requests
- β Code reviews are required before merging
- β Automated tests must pass
- β No direct pushes to main (keeps code safe!)
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: add some amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request (auto-assigned reviewers will review)
- Wait for approval and tests to pass
- Merge! π
- π Read First Time Contributors Guide - Complete beginner's guide
- π Read Contributing Guidelines - Detailed contribution guide
- π Look for issues labeled
good first issueorhelp wanted - π¬ Ask questions in Discussions
- BRANCH_PROTECTION.md - How branch protection works
- START_HERE.md - Complete setup guide (for maintainers)
See our ROADMAP.md for planned features and upcoming enhancements.
Upcoming Features:
- π₯ Recipe recommendation system using collaborative filtering
- πΈ Meal photo recognition with computer vision
- π Gamification with achievements and challenges
- π± Mobile app (React Native)
- π Multi-language support
Found a bug or have a feature request? Please check our issue tracker and create a new issue if needed.
- Bug Reports: Use the bug report template
- Feature Requests: Use the feature request template
- Security Issues: See SECURITY.md
This project is licensed under the MIT License - see the LICENSE file for details.
TL;DR: You can use this project for personal and commercial purposes, modify it, and distribute it. Just include the original license and copyright notice.
- Kaggle Food.com Dataset: For providing 230K+ real recipes for ML training
- Open Source Community: For the amazing tools and libraries
- Contributors: Everyone who has contributed to this project
- React - Frontend framework
- Node.js - Backend runtime
- MongoDB - Database
- Scikit-learn - Machine learning
- Tailwind CSS - Styling
- And many more awesome open-source projects!
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: Create an issue for support
If you find this project useful, please consider giving it a star! It helps others discover the project.
Made with β€οΈ by the NutriGuide Team
- Conclusion & Future Work
- Frontend: Vercel (free unlimited hosting, auto-deploy)
- Backend: Render Web Service (free tier available)
- Database: MongoDB Atlas (free M0 cluster)
- ML Service: Not required (app uses formula fallback)
π Complete Guide: See DEPLOYMENT_VERCEL_RENDER.md for step-by-step deployment instructions.
β±οΈ Deploy Time: ~15 minutes total
Alternative Options:
- Render Blueprint (all services): DEPLOYMENT_GUIDE.md
- Custom setup: Deploy backend anywhere that runs Node.js
This is an academic project. For educational purposes, feel free to:
- Fork the repository
- Experiment with different ML models
- Add new features
- Improve UI/UX
This project is created for academic purposes. Feel free to use it for learning and reference.
- Kaggle - For nutrition datasets
- USDA - Food composition database
- Open Source Community - For amazing libraries and tools
For questions or issues:
- Create an issue in the repository
- Contact project maintainer
- Refer to documentation
Built with β€οΈ for academic excellence
NutriGuide AI - Empowering healthier lives through AI and technology