Inspiration
Nutrition advice has changed a lot over the past few decades. What was considered "healthy" in 1992 (high carbs, low fat) might be considered "inflammatory" today. With food pyramids changing so often, we wanted to visualize just how different these standards really are. We built this tool to let users answer that question.
What it does
The Pyramid Score Calculator is a nutrition tracker spanning three food pyramids. Users can search for foods using real-time USDA data and build a meal. The app then analyzes that meal against three distinct nutritional frameworks:
The 1992 Pyramid: Rewards grains and low fat.
MyPlate (2011): Rewards a balance of veggies, fruits, and proteins.
The RFK Model: Rewards tallow, raw milk, and heavily penalizes seed oils and processed sugars.
The app provides a percentage score for each era and features dynamic reaction images.
How we built it
Backend: Python with Flask. We also called the USDA FoodData Central API.
Data Processing: We implemented a categorization engine. Since the USDA API often returns vague categories, we wrote a hierarchical filter (Phase 1: Junk Detection, Phase 2: Macro Identification) to ensure certain foods like "Strawberry Cake" count as a sweet, not a fruit. There is still a lot to be improved here, and the search will often mistake food categories.
Frontend: HTML and Javascript
The Algorithm: We wrote custom scoring logic for each era with special score penalties and bonuses.
Challenges we ran into
The USDA API is massive and inconsistent. Some items are "Branded" (packaged) while others are "Foundation" (raw). Normalizing serving sizes and nutrient IDs (which changed between dataset versions) was a major challenge.
Our logic often categorizes foods incorrectly. For example, if we could not find a category, then they will default to categorizing them as "grains," which could lead to some foods that are not grains being categorized as such. Another problem is that our keyword search could lead to errors. For example, pasta salad is not a vegetable but because it has salad in its name, it is classified as such.
API Stability: Handling API timeouts and rate limits required implementing a retry session adapter with backoff logic. There were a lot of search errors in the beginning because the API took some time to connect.
What we learned
It is quite difficult to expect clean orderly data even from a government API. It was also difficult to find a simple API to use that is not deprecated, behind paywall, and has enough good information.
What's next for Food Pyramid Score Calculator
We plan on making the search much better as well as make the score calculation clearer to the users and more intelligent.
Log in or sign up for Devpost to join the conversation.