Blog / Build with AI /
Building a meal planner with AI
“What are we eating this week?” is one of the most repeated questions in any household, and one of the least fun. A tiny planner that suggests seven dinners and turns them into a shopping list is a good beginner project: low stakes, useful, and easy to see whether it works.
This is a walk-through of how I’d build one with an AI chatbot. The finished thing is a single web page where you keep a list of meals, press a button, and get a week of dinners plus a combined shopping list. It’s a method and an example, not a claim that I’ve built this exact planner.
Why this is a good project
- No server. The page can store your meals in the browser.
- Your own data. The meals are the ones your household actually eats, so you don’t depend on the AI’s idea of dinner.
- Easy to judge. If the plan puts jollof rice on six nights out of seven, you’ll notice.
- Real logic. It involves lists, randomness and combining items, which are worth learning.
Step 1: define it in a few lines
A single HTML page. I can add meals, each with a name and a list of ingredients. A “Plan my week” button picks seven different meals at random and shows them against the days of the week. Below, it shows one shopping list that combines all the ingredients, with duplicates merged. Meals are saved in the browser.
Notice what’s missing: accounts, calorie counting, recipe photos. Add them later, one at a time.
Step 2: build the shell first
Ask for the page structure before any clever logic:
Write the HTML and CSS only: a form to add a meal name and ingredients (one per line), a list of saved meals, a button, and two empty areas for the weekly plan and the shopping list. No JavaScript yet.
Open it in a browser and look. If the layout is wrong, it’s cheaper to fix now.
Step 3: add the behaviour in small pieces
Next prompts, one at a time:
- “Add JavaScript that saves each new meal to
localStorageand shows it in the list after a page refresh.” - “Add a Plan my week button that picks seven different meals at random and shows them with the days Monday to Sunday.”
- “Build the shopping list by combining all the ingredients from the chosen meals and removing duplicates.”
After each step, test it. Don’t ask for everything at once; when something breaks, you won’t know which part did it.
Step 4: the awkward cases
This is where homemade tools reveal themselves.
- Fewer than seven meals. What should happen if you’ve saved only four? Repeat some, or show a message? Decide. Without a rule, the script may crash or loop.
- Duplicates that aren’t identical. “Tomato”, “tomatoes” and “Tomatoes ” are the same thing to you, and different strings to the code. Ask for a step that trims spaces and ignores capital letters. Plurals are harder, so you may need to tidy the list by hand.
- Quantities. Merging “2 onions” and “1 onion” into “3 onions” needs a data structure with amounts, not plain text. Start without quantities; add them if you really need them.
- Same meal twice in a row. Random isn’t the same as varied. Ask for a rule that avoids picking one meal twice in a week.
Step 5: where the AI’s suggestions need checking
You may also want the chatbot to suggest meals. That’s fine as a source of ideas, but treat it carefully:
- It can’t know your allergies, budget or what’s in your local market. If you shop in a Lagos market, a recipe built around ingredients you can’t easily find isn’t helping.
- Nutrition claims are unreliable. If someone has a medical condition or serious allergy, don’t use a chatbot’s plan as advice. Ask a professional.
- Quantities and cooking times in generated recipes can be off. Cook with something you trust.
A sensible use is: ask for ten dinner ideas using ingredients you already buy, pick the ones you like, and type them into your own list.
Testing the result properly
Whatever the page looks like, test it like a sceptic. Add a meal with no ingredients and see what the shopping list does. Add one with a very long name and check the layout on a phone, since that’s where many people will open it. Refresh the page and confirm your meals are still there. Open it in a second browser and notice they are not, which is your reminder that browser storage is per browser.
If you’re on a patchy connection, as many of us are, a single local file has a real advantage: it works offline. That alone can make a homemade tool better than a clever app that needs data every time you open it.
What I’d watch for
- Browser storage is local. Meals saved on your laptop won’t appear on your phone. If you want that, you’ll need a small back end or a way to export and import a file.
- Clearing browser data deletes the list. Add an “export my meals” button early.
- Don’t over-polish. The point is a working weekly habit, not an app store launch.
A next step
Once it works, add a “lock this meal” button so you can keep Tuesday’s dinner and re-roll the rest. It’s a small prompt, and it teaches you how state works in a page. If you want to practise the same method on a different idea, building a colour palette tool with AI follows the same shape.
Related reading
- Building a colour palette tool with AI
- Building a tiny tool with AI: from idea to working page in an afternoon
- Building a text cleanup tool for copied content with AI
What’s the dinner your household would put on the list first?