Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoodMeals - Weather-Based Meal Prediction System

MoodMeals is a web application that suggests meals based on the current weather conditions in your location. It combines weather data with meal preferences to provide personalized food recommendations.

System Architecture

The application consists of two main components:

  1. Backend (Spring Boot): Handles weather data and meal predictions
  2. Frontend (React): Provides the user interface and displays recommendations

Weather-Based Meal Prediction System

The prediction system uses a content-based filtering approach with rule-based scoring. Here's how it works:

1. Weather Data Collection

  • Temperature
  • Humidity
  • Weather description (rain, sun, clouds, etc.)
  • Wind speed
  • Pressure

2. Meal Scoring System

Each meal is scored based on three main factors:

a. Category-Based Scoring

Different meal categories have predefined preferences for weather conditions:

// Example category scores
mealScores.put("Beef", new MealScore(0.6, 0.4, 0.5));      // Better in moderate temperatures
mealScores.put("Dessert", new MealScore(0.3, 0.7, 0.4));   // Better in humid conditions
mealScores.put("Vegan", new MealScore(0.3, 0.7, 0.4));     // Better in warmer weather
b. Weather Condition Adjustments
  • Rain/Storm: Boosts comfort food (1.2x)
  • Sunny/Clear: Prefers light meals (0.8x)
  • Cloudy: Slight boost for comfort food (1.1x)
c. Tag-Based Scoring

Additional scoring based on meal tags:

  • Comfort food boost during bad weather
  • Light food boost during good weather
  • Spicy food boost in cold weather

3. User Preferences

  • Favorite meals get a 1.5x boost in scoring
  • Preferences are stored in localStorage
  • Influence future recommendations

Example Usage

1. Getting Weather Data

// Frontend API call
const response = await fetch(`/api/weather?location=London`);
const weatherData = await response.json();

// Example response
{
  "location": "London",
  "temperature": 15.5,
  "humidity": 65,
  "description": "light rain",
  "feelsLike": 14.2,
  "windSpeed": 3.5,
  "pressure": 1012,
  "icon": "10d"
}

2. Getting Meal Predictions

// Frontend API call
const response = await fetch('/api/predict/meals', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(weatherData)
});
const predictedMeals = await response.json();

// Example response
[
  {
    "idMeal": "52772",
    "strMeal": "Teriyaki Chicken Casserole",
    "strCategory": "Chicken",
    "strArea": "Japanese",
    "strMealThumb": "https://www.themealdb.com/images/media/meals/wvpsxx1468256321.jpg",
    "strTags": "Casserole,ComfortFood,Chicken",
    "strInstructions": "Preheat oven to 350° F...",
    "ingredients": {
      "chicken": "2 cups",
      "rice": "1 cup",
      // ... more ingredients
    }
  },
  // ... more meals
]

3. Scoring Example

For a rainy day in London (15°C, 65% humidity):

  1. Initial Category Score (Chicken category):

    • Temperature score: 0.5
    • Humidity score: 0.5
    • Weather score: 0.5
  2. Weather Adjustments:

    • Rain condition: 1.2x boost
    • Temperature match: 0.9 (close to ideal)
    • Humidity match: 0.85 (close to ideal)
  3. Tag-Based Adjustments:

    • "ComfortFood" tag: 1.2x boost
    • "Chicken" tag: neutral
  4. Final Score Calculation:

    Base score = (0.5 + 0.5 + 0.5) / 3 = 0.5
    Weather adjusted = 0.5 * 1.2 = 0.6
    Tag adjusted = 0.6 * 1.2 = 0.72
    Final score = 0.72
    

Running the Application

  1. Backend (Spring Boot):
cd back/weather
mvn spring-boot:run
  1. Frontend (React):
cd web
npm install
npm run dev

API Endpoints

Weather Endpoint

  • GET /api/weather?location={city}
  • Returns current weather data for the specified location

Meal Prediction Endpoint

  • POST /api/predict/meals
  • Accepts weather data in the request body
  • Returns top 5 recommended meals

Technologies Used

  • Backend:

    • Spring Boot
    • Spring Web
    • RestTemplate
    • MealsDB API integration
  • Frontend:

    • React
    • Vite
    • CSS Modules
    • Fetch API

Future Improvements

  1. Enhanced Scoring System:

    • Machine learning for personalized preferences
    • Seasonal ingredient availability
    • Cultural preferences
  2. User Features:

    • User accounts and profiles
    • Meal history and preferences
    • Dietary restrictions
  3. Integration:

    • Recipe scaling
    • Grocery list generation
    • Nutritional information

Contributing

Feel free to submit issues and enhancement requests!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages