How to manage an ingredient database
Gram uses a local ingredients.yaml file to store physical and nutritional data about the ingredients you use in your recipes. Maintaining this database ensures that features like Mass Standardization, Yield Calculation, and Nutritional Estimation work perfectly.
This guide explains the standard workflow for maintaining your database using the Gram CLI.
The database workflow
Section titled “The database workflow”The recommended workflow consists of three steps, to be run in this exact order:
-
Syncing new ingredients
Section titled “Syncing new ingredients”As you write new recipes, you will inevitably use ingredients that are not yet in your database. Instead of adding them manually, let the CLI find them.
This command scans all
.gramfiles in your project. If it finds an ingredient (e.g.,@coconut milk{200ml}) that doesn’t exist iningredients.yaml, it will add a blank entry for it. -
Linting and deduplication
Section titled “Linting and deduplication”Sometimes, you might write
@eggin one recipe and@eggsin another. Or@sugarand@sucreif you write in multiple languages.This command uses the configured AI (see Configure AI Provider) to detect semantic duplicates in your database. If it finds
eggandeggs, it will ask you which one to keep as the primary key. It will then merge the other into the primary key’saliaseslist.From now on, writing
@eggswill automatically point to theeggdatabase entry. -
v1.1.0
Enriching data
Section titled “Enriching data”Now that your database has clean, deduplicated entries, you need to fill in their physical (density, unit weight, yield) and nutritional (calories, macros) data.
Doing this manually is tedious. Gram can use AI to propose values for you in batches (see Configure AI Provider):
The CLI will fetch standard nutritional data and densities for all incomplete entries, then walk you through them one by one so you can accept, edit, or skip each proposal — density and nutrition values are product-specific (a French AOP butter isn’t the same as a US one), so only you can really validate them.
category/tagsare low-stakes and get written automatically.It only ever fills in missing fields, never overwrites data you’ve manually entered, and is safe to re-run. Values you accept as-is are tagged
# [LLM]iningredients.yaml, marking them as AI estimates not yet reviewed by a human.
Validating your database
Section titled “Validating your database”Before committing your ingredients.yaml to version control, it is good practice to validate it against the Gram schema to ensure there are no formatting errors (like overlapping aliases).
Sharing and merging databases
Section titled “Sharing and merging databases”If you are working on a team, or if you want to import a community-driven ingredient database, you can merge an external YAML file into your local one:
If there are conflicts (e.g., the community database says butter has 717 kcal, but yours says 740 kcal), the CLI will ask you interactively how to resolve them.