Inspiration

Food prices move faster than budgets. In Nigeria, and in many places with high inflation, a grocery budget that worked last month can fall apart at the till. Most budgeting tools only tell you that you're over. They don't help you decide what to give up.

I wanted a tool that answers a harder question: what is the smallest set of changes that gets this basket back under budget, without touching what I can't live without?

What it does

BasketBrain takes a budget, a currency (GBP, USD, EUR, or NGN), and a grocery list, and marks each item as essential, flexible, or optional.

When the basket is over budget, it:

  • finds swaps, smaller quantities, or removals that save money
  • never touches essentials
  • only suggests a swap when the replacement has the same package size, so a cheaper 500 g bag never counts as a saving against a 2 kg bag
  • finds the plan with the fewest changes that fits the budget and marks those cards "In your plan"
  • shows what you save, what you trade off, and your new total after each change

In the demo basket, the total is £13.04 against an £11.00 budget. The plan makes 3 changes and saves £2.35, because $13.04 - $2.35 = $10.69 \le $11.00

If the basket is already within budget, it shows how much is left and still lets you check for savings. If no combination can reach the budget, it says so honestly and never claims the goal is impossible.

How I built it

  • Next.js 15, TypeScript, and Vercel for the app and deployment.
  • Money in whole pence, quantities in hundredths, so there are no floating-point errors. Typing 19.99 gives exactly 1999.
  • Plain code does all the math. Totals, savings, and the plan search are deterministic. The search checks 1-change plans, then 2-change plans, and so on, with a hard cap, and it reports a separate "search limit reached" result.
  • AI writes words only. The OpenAI API explains each suggestion. The server rejects any AI text that contains digits or currency symbols, so the AI can't contradict the app's numbers. If AI is unavailable, the app still works with fixed explanations.
  • The Devpost Learn Skill Pack produced the plan (scope.md, prd.md, spec.md) before any code was written. I planned with ChatGPT, built with AI coding agents, and used Claude to review the spec and the code.
  • 92 automated tests cover arithmetic, package matching, stale-state handling, the API, and failure cases.

Challenges I ran into

  • Stale suggestions. If you edit your basket while suggestions load, old ideas could appear for items you changed. Each response is now stamped with the basket version and discarded if the basket has changed.
  • Honest comparisons. Comparing prices across different package sizes gives fake savings, so every swap must match package size and currency.
  • The spec took four review rounds. Each one found real problems, from unbounded search to the plan not being visible.
  • My first demo basket could never reach its budget. Running the real code showed that only one item had any savings. I rebuilt the sample so the plan actually lands on budget.
  • Naira prices were 100 times too small in the catalogue. We found this by testing every currency.
  • Time and tooling. I ran out of coding-agent credits on the last day and finished the fixes by hand with a small script.

Accomplishments that I'm proud of

  • Every number on screen comes from tested code, not from an AI guess.
  • The app is honest about its limits: items outside the catalogue are marked, and a basket that can't reach the budget is reported as such.
  • A one-click sample basket shows the whole journey in under two minutes.

What I learned

  • Plan before you build. Writing the scope, requirements, and spec first prevented a lot of rework.
  • Use AI for language and code for money. Letting the AI explain and the code calculate made the product trustworthy.
  • Review finds what building hides. Reading the spec and running the real code caught problems that passing tests did not.

What's next for Basket Brain

  • Real, community-reported prices, so that prices can move with the market
  • A much larger catalogue, including local market items and unit conversion
  • Remembering which swaps you accept, so suggestions fit your habits
  • Saved weekly baskets and trend tracking

Built With

Share this project:

Updates

Submission history