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.
The application consists of two main components:
- Backend (Spring Boot): Handles weather data and meal predictions
- Frontend (React): Provides the user interface and displays recommendations
The prediction system uses a content-based filtering approach with rule-based scoring. Here's how it works:
- Temperature
- Humidity
- Weather description (rain, sun, clouds, etc.)
- Wind speed
- Pressure
Each meal is scored based on three main factors:
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- Rain/Storm: Boosts comfort food (1.2x)
- Sunny/Clear: Prefers light meals (0.8x)
- Cloudy: Slight boost for comfort food (1.1x)
Additional scoring based on meal tags:
- Comfort food boost during bad weather
- Light food boost during good weather
- Spicy food boost in cold weather
- Favorite meals get a 1.5x boost in scoring
- Preferences are stored in localStorage
- Influence future recommendations
// 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"
}// 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
]For a rainy day in London (15°C, 65% humidity):
-
Initial Category Score (Chicken category):
- Temperature score: 0.5
- Humidity score: 0.5
- Weather score: 0.5
-
Weather Adjustments:
- Rain condition: 1.2x boost
- Temperature match: 0.9 (close to ideal)
- Humidity match: 0.85 (close to ideal)
-
Tag-Based Adjustments:
- "ComfortFood" tag: 1.2x boost
- "Chicken" tag: neutral
-
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
- Backend (Spring Boot):
cd back/weather
mvn spring-boot:run- Frontend (React):
cd web
npm install
npm run devGET /api/weather?location={city}- Returns current weather data for the specified location
POST /api/predict/meals- Accepts weather data in the request body
- Returns top 5 recommended meals
-
Backend:
- Spring Boot
- Spring Web
- RestTemplate
- MealsDB API integration
-
Frontend:
- React
- Vite
- CSS Modules
- Fetch API
-
Enhanced Scoring System:
- Machine learning for personalized preferences
- Seasonal ingredient availability
- Cultural preferences
-
User Features:
- User accounts and profiles
- Meal history and preferences
- Dietary restrictions
-
Integration:
- Recipe scaling
- Grocery list generation
- Nutritional information
Feel free to submit issues and enhancement requests!