Introducing the Price And Nutrition Tracking System

In early 2017 I had just gone onto disability pension. Desperate to improve my health despite being broke, I was looking for a way to get the maximum fibre and protein from my food for the minimal cost and calories. I started entering in all the nutritional data from food I bought into a spreadsheet, calculating and plotting those protein:fibre:cost:calories ratios.

Later that year I started to create and analyse recipes which combined different ingredients. This quickly became cumbersome in a spreadsheet, so I started a Django project initially called the Price And Nutrition Tabulation System (P.A.N.T.S) for storing and visualising the data for both recipes and ingredients.

Soon I also realised since I was entering in all my recipes here it would also be easier if I used it as my daily calorie counter and added a “food diary” to the system, renaming it the Price And Nutrition Tracking System.

Example screenshot of the diary view:

/galleries/software-screenshots/pants-diary-screenshot.thumbnail.png

Ratios

Although PANTS shows per-serve and per-kg data, the emphasis is on the ratios of protein-per-calorie and fibre-per-calorie, and maximizing those ratios. The per-dollar ratios are also shown (although less emphasized than the per-calorie ones).

PANTS also “ranks” different foods by combined protein/fibre/calories/cost formulae to provide a simplified, single score of the “healthiness” of recipes (although these are secondary to the more objective, raw data).

Recipes and Meta-Recipes

A key feature of PANTS is the ability for recipes to be components of other recipes. For example a dough recipe and a filling recipe can both be components in a pie recipe; you can clone the pie recipe with alternate fillings to compare the nutritional values of the alternatives. Any changes to the dough recipe will be reflected in the data for all of the pies.

These “meta-recipes” can also be used to easily compare between different similar meals and define meal plans. For example. an “average breakfast” meta-recipe which just contains one serve each of all your other breakfast recipes; divided by the number of serves this provides an average breakfast which can be used for planning. This can be combined with other “typical meal” meta-recipes to make an “average day” recipe which can be used for long term planning.

Daily Targets

Daily Nutritional targets aren’t just a single value with a warning when you go over it. Targets can include a maximum and minimum, so all nutritional values have a more realistic range. Visualisation is done over both the current calendar day and the last 24 hours, to provide a more realistic comparison to a “day” and prevent bingeing in the morning (when the meter is low) and making it impossible to avoid going over your limit by the evening.

You can also have multiple targets and switch between them (e.g. for days with/without strength training, or for “post-workout meal” targets etc). As well as being shown on diary views, the recipe/ingredient pages can be used to compare individial foods to a target to see how well different foods suit your goals.

Amino Acids and other Micronutrients

The previous (pre-diary-just-analysis) incarnation of PANTS had support for detailing the individual amino acids in protein, for vegetarians and vegans to find complementary proteins.

After initially getting excited (as a new vegetarian at the time) and arduously typing in an extra 20 values for every ingredient, I quickly tired of it; nearly all grains, pseudograins, nuts and seeds were low in Lysine but high in Methionine/Cysteine, while all Pulses/Legumes were the opposite (along with Pumpkin Seeds, oddly) and Dairy/Egg products were balanced. I stopped bothering to enter that data as it was easier to just have plenty of legumes and grains/seeds each day as a rule of thumb.

Eventually the nutrition object was merged into ingredient for code and DB performance reasons, leaving the underutilized amino acids adrift. As PANTS emphasises power users and data analysis, I would very much like to add this back in; at the moment I’m trying to refactor all the nutrition calculation code out again into a separate class and when this is done having support for arbitrary micronutrients should be much simpler.

As well as per-amino-acid analysis, this should allow for things such as calcium (and other minerals), EFAs, glycemic index and different types of sugar and fibre to be added to targets.

Source and Setup

Price And Nutrition Tracking System on Github; follow the instructions on the README (spoiler: virtualenv and pip-install like most Python/Django projects). Currently, PANTS is not recommended for non-technical users.