NudgeBite is a lightweight, context-aware smart nutrition assistant web application that helps users make better food decisions through contextual logic and behavioral nudges.
- Smart Recommendations: Suggests food based on your goal (Weight Loss, Muscle Gain, Balanced Health) and hunger level.
- Context Awareness: Automatically detects the time of day and recommends appropriate meals (Breakfast, Lunch, Dinner, Snack).
- Behavioral Nudges: Each recommendation comes with a smart, actionable nudge to improve your eating habits.
- Smart Swaps: Analyzes available ingredients (e.g., rice, eggs) to recommend optimal healthy pairings.
- Habit Tracking: Tracks your recent choices and provides insights on your eating patterns.
- Premium UI: Features a vibrant, modern glassmorphism design with a responsive layout.
The recommendation engine uses a 0-100 "Health Score" system.
- Filtering: Foods are first filtered by the time of day (e.g., Breakfast items in the morning).
- Scoring:
- Goal based: Low-calorie foods score higher for "Weight Loss", high-protein foods score higher for "Muscle Gain".
- Hunger based: If hunger is high, lighter meals are penalized to ensure the user gets a filling recommendation.
- Swaps: If the user inputs an ingredient like "rice", meals containing rice or pairings (like Dal) receive a massive score boost.
- Nudging: Nudge messages are appended dynamically based on the food's nutritional profile and the user's goal.
- Sorting: The top 4 highest scoring foods are displayed to the user.
app.py: Flask backend, dummy dataset, and recommendation logic.templates/index.html: Main HTML layout.static/css/style.css: Modern CSS styling.static/js/app.js: Frontend logic for fetching API and DOM updates.Dockerfile: Containerization setup for deployment.
- Ensure Python 3.9+ is installed.
- Install dependencies:
pip install -r requirements.txt
- Run the Flask server:
python app.py
- Access the app at
http://localhost:8080(orhttp://127.0.0.1:8080).
- Build the Docker image:
docker build -t nudgebite . - Run the container:
docker run -p 8080:8080 nudgebite
- Authenticate with Google Cloud:
gcloud auth login gcloud config set project [YOUR_PROJECT_ID] - Build and deploy using
gcloud run deploy:Or using a pre-built image:gcloud run deploy nudgebite --source . --region us-central1 --allow-unauthenticatedgcloud builds submit --tag gcr.io/[YOUR_PROJECT_ID]/nudgebite gcloud run deploy nudgebite --image gcr.io/[YOUR_PROJECT_ID]/nudgebite --region us-central1 --allow-unauthenticated
The dataset is an in-memory Python list located at the top of app.py.
To add new foods, simply append a new dictionary to the FOODS list:
{
"id": 15,
"name": "New Food",
"calories": 300,
"protein": 15,
"category": "Lunch",
"description": "Short description."
}Restart the server for the changes to take effect.