Inspiration

Every year, a third of all food for human consumption goes to waste despite the current scarcity of global resources. In the fast-paced modern world, it's easy to overlook the ticking shelf life of products.

Waste2Taste aims to facilitate the busy lives of students, workers and families through giving every ingredient a second chance.

What it does

Users can input purchased food items and their respective shelf life into an editable table. Added ingredients are stored in the "fridge", with the days till expiration shown in red if the food expires within five days. With a press of the "Generate Recipes" button, Waste2Taste then suggests the top 10 recipes that put nearly expired ingredients to use. The list is ranked using a smart algorithm that balances usage of expiring food items and existing items in your fridge to minimize additional costs! Not a fan of the recipes? No worries, simply regenerate and Waste2Taste will generate another batch of ingredients for your enjoyment!

Once these factors are taken into account, the user can browse through generated recipes. If unhappy with the generated recipes, the user is able to regenerate which will prompt Waste2Taste to generate 10 new recipes. Finally, the user can check off ingredients that are used, and the remaining ingredients will be saved in the fridge for future recipes!

How we built it

Flask web application connected to an SQLite database. API calls to TheMealDb to grab recipes. Smart algorithm to insensitively match ingredients accounting for user error and keyword permutations.

Front-end We wanted users to be able to have an "all in one" hub to organize their ingredients in a way that reflects the utilities of a real kitchen. The user is able to add and remove items from a digital fridge, as they would in real life. This was implemented using a dynamic table in html, where rows are able to be added and deleted using the input data. Multiple tables were implemented to keep track of ingredients, and recipes are displayed with the click of a mouse. Elements such as an opening fridge door, the moving title text and the embedded Spotify widget enhance the user's experience.

Back-end Back end was built using Flask in order to communicate with the interface. Retrieves information posted by the interface and calls TheMealDb api using a free developer key. Information from the api is read in JSON file format. After querying meals by expiring ingredients, the application applies a ranking algorithm in order to identify the best dishes to present to the user. The ranking algorithm makes use of a formula that applies a weighted average to the ratio of ingredients in fridge to ingredients in recipe and the ratio of expiring ingredients in fridge to those same ingredients in recipes. The closer an ingredient is to expiry, the higher impact it has on the ranking of the proposed recipe. Calling the api with a list of ingredients is locked behind a paywall, so a substitute algorithm was used to find the top meals who's main ingredient matches one that is expiring in the fridge and are presented instead.

Stack: HTML, CSS, JavaScript, Flask, Python, SQL Libraries of interest: sqlite3, requests, fuzzywuzzy/Levenshtein, TheMealDb*

Challenges we ran into

Implementing logical solutions to multi-faceted problem Largest challenge was finding a workaround to the paywalled multi ingredient API endpoint. Without the ability to query multiple ingredients simultaneously, we had to devise methods to increase the efficiency of our code while iterating through large amounts of data multiple times.

One of our biggest challenges was deciding how to weigh different factors in the algorithm through consideration of the user's interests. Such decisions involved deciding what numbers we would use to measure the suitability of a recipe, which we eventually decided to prioritize the percentage of expired items used while also considering what the user already had in their fridge. We also needed to find a readily available library of recipes which we'd be able to parse through, which we settled with the API TheMealDB.

Performance optimization Due to the size of the database we we're pulling recipes from, we had to find a way to reduce execution time despite iterating through big database while also producing the best results. A lost of testing was done with different ingredients, different ingredient quantities, and different search ranges from the database.

Learning from scratch as beginners More than half our team were beginner's to web development, and were only seeing HTML, CSS, and SQL for the first time. There was a lot of learning through trial and error, and the learning curve was steep. By the end of the process, we felt comfortable with things that were initially a challenge.

Accomplishments that we are proud of

Coming up with a solution for the long run-time Instead of iterating through 300+ recipes with multiple nested loops, we chose to limit the search to a range of 13 to then display the most optimal recipes out of this range. This change turned out to not only fix our run-time issue, but also ensures recipe randomization even for the same ingredients. This randomization added an unexpected but welcomed feature, which allowed users more freedom of choice if they didn't like the current recipes generated.

Choosing the weight of the different factors appropriately While we want the algorithm to push the recipes that utilize as many expiring food items as possible, we want to minimize the amount of missing items that the user would have to purchase in order to cook the recipe. However, we outlined the most important factor to be to prioritize using the items that are nearest to their expiration dates.

What's next for Waste2Taste

Implementing a filter to allow the user to pick a food category to further customize their experience. Allowing the user to add quantities of ingredients as well that they have, which would introduce the challenge of implementing all the different possibilities of units of measurements.

Built With

Share this project:

Updates