Skip to content
Calorie-counting diet planner and tracker
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


Calorie tracker and diet planner


Count calories

In sustenance.toml:

# pantry
name = 'rolled-oats'
serving-size = '100g'
protein = 13.2
carbs = 67.7
fat = 6.5

# meals
date = 2018-05-31
time = 10:15:00

  # eat 150g rolled oats
  food = 'oats'
  servings = 1.5


export RAKULIB=lib
bin/sustenance --date=2018-05-31 gen-macros sustenance.toml


use Sustenance;
my Date $date .= new('2018-05-31');<sustenance.toml>).gen-macros($date);

Make a diet plan

Make a diet plan for a lightly active male athlete, age 31, weighing 59 kg at 175.26 cm.


export RAKULIB=lib
bin/sustenance \
  --weight=59.4206 \
  --height=175.26 \
  --age=31 \
  --gender=male \
  --activity-level=lightly-active \


use Sustenance::DietPlan;


Calorie tracking

Processes daily caloric intake from TOML meal journal formatted per the synopsis (see also: doc/sample-pantry.toml).

The Sustenance meal journal must consist of at least one food entry and at least one meal entry.

Each food entry must have:

key description value
name name of food string
serving-size serving size string
protein grams of protein per serving number
carbs grams of total carbohydrates¹ per serving number
fat grams of fat per serving number

Each food entry may have:

key description value
aka alternative name by which food is known string
aka alternative names by which food is known array of strings
fiber grams of total fiber² per serving number
fiber grams of total fiber per serving, $insoluble-fiber / $total-fiber array of floats or array of integers
alcohol grams of alcohol per serving number
source source of macronutrient data string

Each meal entry must have:

key description value
date yyyy-mm-dd date
time hh:mm:ss time
portion see below array of hashes

Each meal portion must have:

key description value
food name of food string
servings number of servings of food number

¹: total carbohydrates includes all types of carbohydrates - sugars, sugar alcohols, starches and dietary fiber - per USA food labels (see: international food labeling differences)

²: total fiber includes both soluble and insoluble fiber

Diet planning

Creates rudimentary diet plan for weight maintenance, muscle gains and fat loss.

First estimates Basal Metabolic Rate (BMR) with the Mifflin St Jeor equation.

Then estimates Total Daily Energy Expenditure (TDEE) by taking the product of BMR and the appropriate Katch-McArdle multiplier for a given activity level.

Adds 250-500 calories on top of TDEE to estimate caloric intake requirements for muscle gains.

Subtracts 250-500 calories from TDEE to estimate caloric intake requirements for fat loss.

Recommends obtaining 1.4-1.6 grams of protein per kilogram body weight.

Recommends obtaining 20-35% of daily calories from healthy sources of fat.

Recommends obtaining remainder of daily calories from healthy sources of carbohydrates.




This is free and unencumbered public domain software. For more information, see or the accompanying UNLICENSE file.

You can’t perform that action at this time.