This project is the prototype for a full stack app which uses information from the USDA Nutrient database to retrieve and display nutritional data for most foods. (The ones provided in the USDA database)
This API is built with Node.js and Express, with a PostgeSQL database and is a Read Only service. Create, Update and Delete is not necessary since the data is managed on the database side.
This project originated from an idea I had for a spreadsheet I could use to manage my dietary needs in bodybuilding. I wanted to maximize Amino Acid intake and to focus on foods that delivered the biggest delivery of required nutrients.
Due to my fascination with databases, I was able to find the USDA nutrition database on the internet.
Due to the USDA food value database being so comprehensive and detailed, the project grew. THe scope and possibilities increased.
When I learned how to properly develop and deploy a custom API, the project grew further and also developed more refinement.
At this time (November 5, 2023), it is intended to be a Full Stack Web Application. At some point I would like to include AI to assist with analysis.
Also, in time it will be extended to a Mobile app (iOS and Android).
2023 11 01
- The API is built and functioning on several endpoints. More endpoints to follow
- Node.js (I recommend installing node using NVM)
- PostgreSQL
- React
Create a .env
file with Postgres database parameters and HOST parameter for server:
HOST=<FQDN or IP>
DBUSER=<postgres user>
DBPW=<postgres user password>
DBHOST=<postgres server>
DBPORT=<postgres port>
DB=<postgres database>
Postgres connect string as JavaScript interpolated string:
postgres://${process.env.DBUSER}:${process.env.DBPW}@${process.env.DBHOST}:${process.env.DBPORT}/${process.env.DB}
The backend is a REST API using JavaScript and Express to develop the endpoints.
-
/food - Test endpoint, returns a preselected food id
-
/food/categories - All Food categories (Food Groups)
-
/food/category/byid/{id} - Specific Food category (Food Groups)
-
/food/
{id}
/nutrients/ - Retrieve all info about a particular food -
/food/nutrition/
{term}
?page=number&limit=n - Retrieve food and nutrition data by search term (The search term is a string within the food long description. number = 'page number', n = 'items per page'
) -
/food/nutrients - Retrieve list of all nutrients
-
/food/nutrients/
{term}
- Retrieve nutrient info, search by nutrient name -
/food/nutrients/
{id}
- Retrieve info about a specific nutrient by id -
/food/nutrients/aminos - Retrieve a list of all Amino Acids
-
/food/nutrients/aminos/essential - Retrieve a list of all Essential Amino Acids
-
/food/
{id}
/nutrients/aminos - Retrieve foods that contain any of the nine essential amino acids in a quantity > 0 -
/food/nutrients/aminos/
{food search term}
/{quantity}
- Retrieve foods that contain the named amino in the minimum quantity