I initially got the idea from my brother when he started trying to figure out what foods from the grocery store he could eat to get as much protein as possible. He had done some research and listed out combinations of foods he could eat so he could maximize his protein intake while still meet the rest of his macro and micronutrients.
I had gotten some experience with web scraping tools like selenium and thought I would be able to do something on a larger scale with the VT dining information for the hackathon using linear optimization libraries in python.
What it does
The first thing the site does is it pulls all of the nutritional information from each dinning hall on campus. The user is directed to input relevant information that is used to figure out daily metabolic rate, allergy information, intended locations for each meal, and target micronutrient values.
With all of the information, it uses PuLP which is a linear optimization algorithm to figure out the ideal number of servings of different foods that get you as close as possible to all target values while minimizing calories.
It takes the guess work out of trying to keep a balanced diet by tell you exactly what you can eat, and if you're unhappy with the optimal selection of foods, you can remove foods and rerun the optimization until you're satisfied.
How I built it
The data collection was fairly straightforward to loop through requests for all menu information. I used regex to disseminate the nutritional information from the html and converted into a standardized JSON file for each day's menu. I built the flask app using google app engine, and scheduled a function to gather each day's menu in advance and store it in a google storage bucket.
The optimization algorithm takes all of the values given by the user and the nutritional data. I built the frontend of the site using a bootstrap carousel template I found to make it a SPA.
Challenges I ran into
Maneuvering google app engine was by far the most difficult part of this. I spent way too much time trying different ways to setup a cron job and it was a steep learning curve to handle most of the aspects outside of just pure flask. I still think the way I went about scheduling tasks and storing data wasn't a best practice, but it worked so I'm happy with it.
Another very annoying thing I ran into was trying to redirect a domain from domain.com to a GAE project. domain.com wouldn't update the txt dns so I was stuck trying to look for other ways to forward or transfer the domain. I would've liked to name the site 'nutricient.tech' since I got the domain for it, but for now it'll stay as an app domain.
Accomplishments that I'm proud of
I'm very happy with how the site UI turned out. I think it is very straightforward to use and should handle several edge cases if the user doesn't enter all of the required information for an optimization.
What I learned
I learned a lot about google cloud, there were several tools like google compute and google apis that I think I want to bring into this project eventually. I figured out a lot of shortcuts for doing different functions and got a lot more experience with CSS and bootstrap when doing UI.
What's next for Nutricient
There are still some edge conditions and form validation bugs I need to account for, but i'm pretty happy with the current state of the site right now.
I don't want to just stop at optimizing tech dining, so including more information about chain restaurants on campus or restaurants in the area would be very cool. I also want to see what an ideal meal from a grocery store would look like, or maybe trying to pull in entire meals or recipes so the optimization results all go with eachother.