Skip to content

Snahab/nudgebite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NudgeBite

NudgeBite is a lightweight, context-aware smart nutrition assistant web application that helps users make better food decisions through contextual logic and behavioral nudges.

Features

  • 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.

How Recommendation Logic Works

The recommendation engine uses a 0-100 "Health Score" system.

  1. Filtering: Foods are first filtered by the time of day (e.g., Breakfast items in the morning).
  2. 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.
  3. Nudging: Nudge messages are appended dynamically based on the food's nutritional profile and the user's goal.
  4. Sorting: The top 4 highest scoring foods are displayed to the user.

Project Structure

  • 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.

Setup Instructions

Run Locally (Python)

  1. Ensure Python 3.9+ is installed.
  2. Install dependencies:
    pip install -r requirements.txt
  3. Run the Flask server:
    python app.py
  4. Access the app at http://localhost:8080 (or http://127.0.0.1:8080).

Run Locally (Docker)

  1. Build the Docker image:
    docker build -t nudgebite .
  2. Run the container:
    docker run -p 8080:8080 nudgebite

Deploy to Google Cloud Run

  1. Authenticate with Google Cloud:
    gcloud auth login
    gcloud config set project [YOUR_PROJECT_ID]
  2. Build and deploy using gcloud run deploy:
    gcloud run deploy nudgebite --source . --region us-central1 --allow-unauthenticated
    Or using a pre-built image:
    gcloud 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

How to Modify the Dataset

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors