--- title: AI Diet Planner & Nutrition Assistant emoji: 🍽️ colorFrom: green colorTo: blue sdk: gradio sdk_version: 4.44.0 app_file: app.py pinned: false license: mit short_description: AI-powered diet planning with nutrition analysis --- # 🍽️ AI Diet Planner & Nutrition Assistant An intelligent diet planning application that uses RAG (Retrieval-Augmented Generation) technology to provide personalized nutrition advice, meal planning, and dietary recommendations. ## ✨ Features ### 🎯 **Personalized Diet Planning** - **Weekly Meal Plans**: Complete 7-day diet plans with detailed meal breakdowns - **Daily Nutrition**: Individual day meal planning with macro and micronutrient analysis - **Customizable Parameters**: Age, weight, height, activity level, and dietary preferences ### 📊 **Nutrition Analysis** - **Comprehensive Nutrition Facts**: Detailed breakdown of calories, macronutrients, vitamins, and minerals - **USDA Food Database**: Access to extensive food nutrition information - **BMR & TDEE Calculations**: Accurate metabolic rate calculations using Mifflin-St Jeor formula ### 🤖 **AI-Powered Recommendations** - **Smart Suggestions**: Personalized dietary recommendations based on your profile - **Goal-Oriented Planning**: Weight loss, muscle gain, or maintenance-focused plans - **Interactive Chat**: Natural language interface for easy interaction ### 📋 **Advanced Features** - **JSON Export**: All plans and analyses saved as structured JSON files - **Table Formatting**: Beautiful markdown tables for easy reading - **Multi-language Support**: English interface with comprehensive food database ## 🚀 How to Use ### 1. **Create a Diet Plan** ``` "Create a weekly diet plan for a 25-year-old male, 70kg, 175cm, moderate activity" ``` ### 2. **Calculate Nutrition** ``` "Calculate nutrition for 200g chicken breast and 150g rice" ``` ### 3. **Get Recommendations** ``` "Get diet recommendations for weight loss" ``` ### 4. **Vegetarian Options** ``` "Create a vegetarian meal plan for 7 days" ``` ## 🔧 Technical Details ### **Architecture** - **RAG System**: Retrieval-Augmented Generation for intelligent responses - **Groq API**: Fast LLM inference for real-time responses - **Sentence Transformers**: Semantic search for relevant nutrition data - **Gradio**: Modern web interface for easy interaction ### **Data Sources** - **USDA FoodData Central**: Comprehensive nutrition database - **Custom Food Database**: Curated collection of common foods - **Nutritional Algorithms**: BMR, TDEE, and macro distribution calculations ### **Output Formats** - **JSON Files**: Structured data for all plans and analyses - **Markdown Tables**: Human-readable formatted output - **Interactive Chat**: Real-time conversation interface ## 📁 File Structure ``` ├── app.py # Main Gradio application ├── main3.py # RAG system and tool router ├── diet_tool.py # Diet planning algorithms ├── usda_provider.py # USDA API integration ├── requirements.txt # Python dependencies ├── README.md # This file └── outputs/ # Generated JSON files ├── diet_plan_weekly_*.json ├── diet_plan_daily_*.json └── diet_recommendations_*.json ``` ## 🛠️ Setup Instructions ### **For Hugging Face Spaces** 1. **Create a new Space** on Hugging Face 2. **Upload all files** to your Space repository 3. **Set Environment Variables**: - Go to Settings → Secrets - Add `GROQ_API_KEY` with your Groq API key 4. **Deploy** - The Space will automatically build and deploy ### **For Local Development** 1. **Install Dependencies**: ```bash pip install -r requirements.txt ``` 2. **Set Environment Variable**: ```bash export GROQ_API_KEY="your_groq_api_key_here" ``` 3. **Run the Application**: ```bash python app.py ``` ## 🔑 API Keys Required - **Groq API Key**: Get your free API key from [console.groq.com](https://console.groq.com) ## 📊 Example Outputs ### **Weekly Diet Plan** - 7-day meal breakdown - Daily calorie and macro targets - Detailed food lists with portions - Nutritional analysis per meal ### **Nutrition Analysis** - Complete macronutrient breakdown - Vitamin and mineral content - Calorie calculations - Serving size recommendations ### **Dietary Recommendations** - Personalized advice based on profile - Goal-specific suggestions - Macro distribution guidance - Lifestyle integration tips ## 🤝 Contributing Feel free to contribute to this project by: - Adding new food items to the database - Improving nutrition calculation algorithms - Enhancing the user interface - Adding new dietary patterns (keto, paleo, etc.) ## 📄 License This project is licensed under the MIT License - see the LICENSE file for details. ## 🙏 Acknowledgments - **USDA FoodData Central** for comprehensive nutrition data - **Groq** for fast LLM inference - **Gradio** for the beautiful web interface - **Sentence Transformers** for semantic search capabilities --- **Made with ❤️ for better nutrition and healthier living!**