A full-stack web application that helps patients modify their recipes based on their medical conditions. The app automatically detects harmful ingredients and suggests healthy alternatives, generating personalized recipes tailored to specific health needs.
- Ingredient Analysis: Automatically detects harmful ingredients based on medical conditions
- Smart Replacements: Suggests healthy alternatives for harmful ingredients
- AI-Powered Recipe Generation: Uses Gemini API to create detailed, personalized recipes
- Enhanced PDF Reports: Professional, well-formatted reports with summary statistics
- User Authentication: Secure registration, login, and profile management
- Individual Data Storage: Each user's data is stored separately and securely
- Session Logging: Stores all food entries in MongoDB for tracking
- View & Download Reports: Both view in browser and download functionality
- Diabetes
- Hypertension
- Heart Disease
- Celiac Disease
- Gluten Intolerance
- Lactose Intolerance
- Egg Allergy
- Peanut Allergy
- Soy Allergy
- Corn Allergy
- Obesity
- High Cholesterol
The app includes a comprehensive database of ingredients with their health implications:
- Sugar β Stevia (for diabetes/obesity)
- Salt β Low-sodium salt (for hypertension/heart disease)
- Flour β Almond flour (for celiac/gluten intolerance)
- Butter β Olive oil (for cholesterol/heart disease)
- Milk β Almond milk (for lactose intolerance)
- And many more...
- Frontend: HTML, CSS, JavaScript, Bootstrap 5
- Backend: Python Flask
- Database: MongoDB with PyMongo
- PDF Generation: ReportLab with improved formatting
- AI Integration: Google Gemini API for recipe generation
- Authentication: Flask-Login with secure password hashing
- Forms: Flask-WTF with validation
- Styling: Custom CSS with Font Awesome icons
project/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ templates/
β βββ index.html # Main ingredient submission page
β βββ result.html # Results display page
βββ static/
β βββ styles.css # Custom CSS styles
βββ reports/ # Generated PDF reports
βββ database/ # MongoDB setup and data
- Python 3.7 or higher
- MongoDB (local installation or MongoDB Atlas)
- pip (Python package manager)
# If using git
git clone <repository-url>
cd Recipe-Modifier
# Or download and extract the project filespip install -r requirements.txt- Download and install MongoDB Community Server from mongodb.com
- Start MongoDB service:
# Windows net start MongoDB # macOS/Linux sudo systemctl start mongod
- Create a free account at mongodb.com/atlas
- Create a new cluster
- Get your connection string
- Update the connection string in
app.py:client = MongoClient('your-mongodb-atlas-connection-string')
python app.pyThe application will be available at: http://localhost:5000
- Click "Register" in the top navigation
- Fill in your username, email, and password
- Optionally select your medical condition for better recommendations
- Click "Create Account" to register
- Click "Login" in the top navigation
- Enter your username/email and password
- Check "Remember Me" to stay logged in
- Click "Sign In"
- Navigate to the main page
- Enter your ingredients separated by commas (e.g., "sugar, flour, butter, banana")
- Select your medical condition from the dropdown
- Click "Check Ingredients & Generate Recipe"
The app will display:
- Original Ingredients: What you entered
- Harmful Ingredients: Ingredients that may be problematic for your condition
- Safe Alternatives: Healthy replacements for harmful ingredients
- Modified Recipe: Your personalized recipe with safe ingredients
- Click "Profile" in the top navigation when logged in
- View your account information and activity statistics
- Update your email and medical condition
- Change your password
- View your recipe history
- Click "Download Health Report" to generate a PDF
- The PDF includes all your food entries with analysis
- Perfect for sharing with healthcare providers
Input: sugar, butter, flour, banana Expected Output:
- β Harmful: sugar, flour
- β Replaced with: stevia, almond flour
- β Safe: banana, butter (or olive oil)
- Final Recipe: "Mix almond flour, banana, stevia, olive oil. Cook in a pan until golden brown."
Input: salt, butter, flour, eggs Expected Output:
- β Harmful: salt, butter
- β Replaced with: low-sodium salt, olive oil
- β Safe: flour, eggs
- Final Recipe: "Combine flour, eggs, low-sodium salt, olive oil. Mix well and cook until golden brown."
The app automatically initializes the database with sample data on first run:
- Ingredient rules collection
- Sample patient data
- Food entries collection
To add new ingredients or modify existing rules, edit the initialize_database() function in app.py:
{
"ingredient": "new_ingredient",
"harmful_for": ["condition1", "condition2"],
"alternative": "healthy_alternative",
"category": "category_name"
}Returns all available ingredients in the database.
Returns all supported medical conditions.
Processes ingredient submission and returns analysis results.
Generates and downloads PDF report for a specific patient.
python app.py- Create a
Procfile:web: python app.py - Set environment variables for MongoDB connection
- Deploy to Heroku
- Connect your repository to Render
- Set build command:
pip install -r requirements.txt - Set start command:
python app.py - Configure environment variables
- This is a demonstration application
- No authentication system implemented
- Uses hardcoded patient ID for simplicity
- Always consult healthcare providers for medical advice
- The app is for educational purposes only
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is for educational purposes. Please consult healthcare professionals for medical advice.
MongoDB Connection Error
- Ensure MongoDB is running
- Check connection string
- Verify network connectivity
Port Already in Use
- Change port in
app.py:app.run(debug=True, host='0.0.0.0', port=5001)
PDF Generation Fails
- Ensure
reports/directory exists - Check write permissions
- Verify ReportLab installation
- Check the console output for error messages
- Verify all dependencies are installed
- Ensure MongoDB is properly configured
- User authentication system β
- Multiple patient support β
- Recipe sharing functionality
- Nutritional information
- Mobile app version
- Integration with health APIs
- Advanced recipe generation AI