DEV Community

n00bgineer
n00bgineer

Posted on • Originally published at n00bgineer.wordpress.com on

Building a privacy-first health app - update #2

Introduction

As I’d mentioned previously, I’ll be using the FoodData Central API provided by US Dept. of Agriculture for accessing the nutritional information about the food.

I was initially planning to download and dump it’s branded and foundational food database in a PostgreSQL database, but decided against it due to certain memory constraints as I’m using the (free) 500MB PostgreSQL DB by Supabase for prototyping this application, while the unzipped size of branded food database alone is 2.7GB.

Instead i’ll be using it’s free API, which has a pretty generous rate limit of 1k requests per hour per IP address, which is perfect for building and testing the prototype.

Updates

  1. I was able to understand the basics of it’s search API endpoint (i.e. /v1/foods/search), including how the response data is structured and how to implement pagination for the endpoint and based on this, I was able to design a basic layout for the food item search component, which can be used to add the number of servings for a food item or look for a food item’s nutritional information.

Next steps

  1. Now, I’ll try to implement the search page which will be used to search the food items and later I’ll update the food item schema to allow users to add the search (or scanned) food item to their food consumption history.
  2. After I’ve built the FoodSearchPage , FoodSearchCell & FoodSearch components along with the respective server-side endpoints, I will test out the Google’s labeling API for the food scanning feature, which will allow users to scan their food and get it’s nutritional information.

Screenshots


cURL request to fetch food items

Top comments (0)