Goals
- Users building a weekly meal plan struggle to find relevant recipes in a large catalog.
- Picking recipes for the plan takes too many steps and breaks the planning flow.
- Users need confidence they found the right recipe before committing it to the plan.
Non-Goals
- No server-side search or pagination.
- No recipe editing or creation from this page.
- No meal plan scheduling by day or drag-and-drop ordering.
Desired Behavior
- User sees a search input and a list of recipes below it.
- Typing in the search input filters visible recipes by title.
- Clearing the search input shows all recipes again.
- Each recipe row has an "Add to meal plan" button.
- Clicking "Add to meal plan" adds the recipe and shows a confirmation.
- Empty search results show a "No recipes found" message.
Design
RecipeSearchPageowns the search input and filtered recipe list.RecipeRepositoryservice provides the full recipe catalog.MealPlanRepositoryservice stores recipes added to the current meal plan.- Filtering is case-insensitive substring match on recipe title.
Diagram
flowchart TD
RecipeRepository(("RecipeRepository"))
MealPlanRepository(("MealPlanRepository"))
RecipeSearchPage -->|"[recipes: Recipe[]]"| RecipeList
RecipeList -->|"(recipeAdd: Recipe)"| RecipeSearchPage
RecipeSearchPage -->|"search({query: string}): Recipe[]"| RecipeRepository
RecipeSearchPage -->|"add({recipe: Recipe}): void"| MealPlanRepositoryImplementation Details
(Note: this section is removed after the PR Plan is created.)
interface Recipe {
id: string;
title: string;
}
interface RecipeRepository {
getRecipes(): Recipe[];
}
/**
* Case-insensitive substring match on `title`.
* Empty query returns every recipe.
*/
function filterRecipes(recipes: Recipe[], query: string): Recipe[];
interface MealPlanRepository {
addRecipe(recipe: Recipe): void;
}- Scaffold
RecipeSearchPagewith search input and recipe list. - Display all recipes from
RecipeRepository. - Filter recipes by case-insensitive substring match on title.
- Show "No recipes found" when filter matches nothing.
- Add
MealPlanRepositorywithaddRecipe(recipe: Recipe): void. - Add "Add to meal plan" button on each recipe row.
- Show confirmation toast after a recipe is added.
Testing Strategy
PR Plan
flowchart LR
PR1["PR#1<br>List recipes"]
PR2["PR#2<br>Filter recipes"]
PR3["PR#3<br>Add recipe to meal plan"]
PR1 --> PR2
PR1 --> PR3<details>
<summary>🚧 PR#1 — List recipes</summary>Tasks
- Add
Recipeinterface withidandtitlefields. - Add
RecipeRepositorywithgetRecipes(): Recipe[]. - Scaffold
RecipeSearchPagewith search input and recipe list. - Display all recipes from
RecipeRepository.
Testing Strategy
🚧 list recipes
- Mount
RecipeSearchPagewith fake repository returning 3 recipes. - Assert all 3 recipes are displayed with their titles.
Tasks
- Filter recipes by case-insensitive substring match on title.
- Show "No recipes found" when filter matches nothing.
Testing Strategy
🚧 filter recipes with matching query
- Mount
RecipeSearchPagewith fake repository returning 3 recipes. - Type "pasta" in search input.
- Assert only matching recipes are displayed.
🚧 filter recipes with no results
- Mount
RecipeSearchPagewith fake repository returning 3 recipes. - Type "xyz" in search input.
- Assert "No recipes found" message is displayed.
Tasks
- Add
MealPlanRepositorywithaddRecipe(recipe: Recipe): void. - Add "Add to meal plan" button on each recipe row.
- Show confirmation toast after a recipe is added.
Testing Strategy
🚧 add recipe to meal plan
- Mount
RecipeSearchPagewith fake repositories. - Click "Add to meal plan" on the first recipe.
- Assert
MealPlanRepository.addRecipewas called with the first recipe. - Assert confirmation toast is displayed.
Alternatives Considered
- Client-side regex search — Rejected; substring match is simpler and sufficient.
- Inline meal plan sidebar — Rejected; out of scope; confirmation toast is enough for now.
Kitchen Sink
Open Questions
- Should search match recipe tags or ingredients too?
- Should the button be disabled if the recipe is already in the meal plan?
Future Plans
- Debounce search input for large recipe catalogs.
- Show meal plan preview on the same page.