A TypeScript library for planning recipes, meals, weekly menus, and generating grocery lists with ingredient normalization for French cuisine.
- Recipe Management โ Parse, store, and scale recipes by serving count
- Ingredient Matching โ Fuzzy string matching to identify ingredients across recipes and store sections
- French Language Support โ Automatic plural-to-singular normalization for French ingredient names
- Weekly Meal Planning โ Organize meals into structured weekly plans with lunch and dinner
- Shopping List Generation โ Aggregate ingredients across all meals into a consolidated, section-organized grocery list
- Recipe Filtering โ Filter recipes by type (entrรฉe, plat, dessert, etc.)
- Node.js >= 18
- npm >= 9
npm installnpm run buildnpm testnpm run lintStart the web server to access the meal planning UI in your browser:
npm run build
npm run serveThen open http://localhost:3000. The web frontend provides:
- ๐ Recipes โ Add, view, and delete recipes with ingredients
- ๐ Meal Plan โ Assign recipes to lunch/dinner for each day of the week
- ๐ Shopping List โ Generate a consolidated grocery list from the current meal plan
Set a custom port with the PORT environment variable: PORT=8080 npm run serve
import {
IngredientFinder,
createWeeklyPlan,
generateShoppingList,
formatShoppingList,
scaleRecipe,
} from 'meal-planner';
// Create an ingredient finder for fuzzy matching
const finder = new IngredientFinder([
{ name: 'carotte', rayon: 'lรฉgumes' },
{ name: 'pomme de terre', rayon: 'lรฉgumes' },
{ name: 'sel', rayon: 'condiments' },
]);
// Find the best match for a misspelled ingredient
console.log(finder.find('carottes')); // โ 'carotte'
// Scale a recipe to different servings
const recipe = {
id: '1',
title: 'Gratin dauphinois',
type: 'plat',
person_count: 4,
ingredients: [
{ name: 'pomme de terre', quantity: 800, unit: 'g' },
{ name: 'crรจme fraรฎche', quantity: 200, unit: 'ml' },
],
instructions: 'รplucher les pommes de terre...',
};
const scaled = scaleRecipe(recipe, 6); // Scale to 6 servings
// Generate a shopping list from a weekly plan
const plan = createWeeklyPlan(meals, 4);
const shoppingList = generateShoppingList(plan, courseIngredients);
console.log(formatShoppingList(shoppingList));src/
โโโ index.ts # Public API exports
โโโ types.ts # TypeScript type definitions
โโโ utils.ts # Utility functions (name normalization, measurement parsing)
โโโ ingredients.ts # Ingredient finding, parsing, and merging
โโโ recipes.ts # Recipe parsing, scaling, and filtering
โโโ meal-plan.ts # Weekly meal planning and shopping list generation
โโโ server.ts # Express web server with REST API
โโโ utils.test.ts # Tests for utility functions
โโโ ingredients.test.ts # Tests for ingredient logic
โโโ recipes.test.ts # Tests for recipe logic
โโโ meal-plan.test.ts # Tests for meal planning and shopping lists
โโโ server.test.ts # Tests for the web server API
web/
โโโ index.html # Single-page web frontend
dico.jsonโ French plural-to-singular word dictionary used for ingredient name normalizationexampleMenu.jsโ Sample menu data from the La Fabrique ร Menus servicecliqual/โ CIQUAL French food composition database (nutritional reference data)createDict.jsโ Script to regeneratedico.jsonfrom the DELA French dictionary XML
Normalize a French ingredient name by converting plurals to singular form.
Parse a numeric quantity from a value that may contain HTML entities.
Class that matches ingredient names using exact or fuzzy string matching.
constructor(courseIngredients: CourseIngredient[])โ Initialize with known ingredientsfind(ingredient: string): stringโ Find the best matching ingredient name
Scale recipe ingredients to a different number of servings.
Filter recipes by type (case-insensitive, partial match).
Create a structured weekly meal plan from a list of meals.
Generate a consolidated shopping list from a weekly meal plan.
Format a shopping list as human-readable text organized by store section.
GPL-3.0 โ see LICENSE for details.