DEV Community

perfectsea
perfectsea

Posted on

Why Hardcoded Recipes Beat AI: Building a Filipino Meal Cost Engine with Real Market Data

 Every Filipino household has heard this question at least ten thousand times:

"Ma, ano ulam?" (Mom, what's for dinner?)

It's so universal it's practically a national catchphrase. And now that I'm the one who cooks and shops at the wet market (palengke), I hear it in my own head — every single day.

The problem isn't cooking. It's deciding what to cook when ingredient prices change daily and you're trying to stretch a budget.

So I built a web app to answer the question with math instead of guesswork.

Live: ma-anoulam.vercel.app
GitHub: chanrylejay/ano-ulam


The Problem

Here in the Philippines, the Department of Agriculture publishes a daily price bulletin called Bantay Presyo — it tracks commodity prices (vegetables, meat, fish, rice, cooking oil) across Metro Manila markets and supermarkets. It's publicly available as a PDF on their website.

The data exists. But nobody is using it to help regular people decide what to cook.

I wanted to build something that:

  • Pulls real market prices every day automatically
  • Figures out which meals are cheapest to cook right now
  • Shows per-ingredient cost breakdowns so you know exactly what you're spending
  • Runs by itself with no manual work

V1: The AI Approach (And Why It Failed)

My first instinct was to let AI handle everything. I sent the price data to DeepSeek and asked it to generate Filipino recipe suggestions with cost estimates.

The results were... not great.

Accuracy: 6-7 out of 10.

Here's what went wrong:

  • Wrong ingredients: It would suggest "Sinigang na Baboy" but include ingredients that don't belong in sinigang
  • English names: It used "eggplant" instead of "talong," "string beans" instead of "sitaw" — which felt wrong for a Filipino cooking app
  • Bad cost estimates: It would guess prices instead of calculating from the actual data
  • Invented recipes: It occasionally generated dishes that don't exist in Filipino cuisine
  • Inconsistent portions: Serving sizes varied wildly between suggestions

AI is excellent at many things. Generating accurate, domain-specific structured data about Filipino wet market cooking is not one of them.


The Pivot: Hardcoded Recipes + Pure Math

I threw out the AI recipe generation entirely and did something that felt almost too simple:

I hardcoded all the recipes myself.

47 Filipino recipes. Each one with verified ingredients, quantities, units, and the exact DA commodity name each ingredient maps to. All based on actual palengke shopping experience — what you'd really buy, in what quantities, at what unit.

Examples:

  • Adobo: 3/4 kg chicken, soy sauce, vinegar, bawang, paminta
  • Sinigang na Baboy: 3/4 kg pork, sampaloc mix, kangkong, talong, siling haba
  • Ginisang sardinas: 1 can sardines, kamatis, sibuyas, bawang

Cost calculation is pure JavaScript math:

For each recipe:
  For each required ingredient:
    Look up today's price from DB
    Multiply by quantity needed
    Apply palengke rate overrides for small items
  Sum = total meal cost
Enter fullscreen mode Exit fullscreen mode

The "palengke rate overrides" handle a real-world quirk: DA prices are per kilo, but at the palengke you buy bawang (garlic) by the bulb and sibuyas (onion) by the piece. So for small quantities (≤0.20 kg), I override with actual per-piece palengke rates:

  • Bawang: ₱175/kg → 1 ulo ≈ ₱7
  • Sibuyas: ₱80/kg → 1 pc ≈ ₱8
  • Luya (ginger): ₱125/kg → 1 piraso ≈ ₱5

Result: 10/10 accuracy. Every cost matches what you'd actually pay at the market.

AI is still in the system — but only for natural language reasoning. After the cost engine selects the 8 cheapest meals, I send a summary to DeepSeek and ask "Bakit ito ang mura ngayon?" (Why is this cheap today?). That's a ~500 token call. The AI explains trends in conversational Filipino. That's it.


The Daily Pipeline

Everything runs automatically via Vercel Cron Jobs:

8:00 AM Manila — PRICE INGESTION
  DA Bantay Presyo website
  → Find today's Daily Price Index PDF
  → Download and extract text via pdf-parse
  → Send to DeepSeek for CSV extraction
  → Parse CSV in JavaScript
  → Batch upsert ~98 commodity prices into Neon PostgreSQL

8:05 AM Manila — MEAL SUGGESTION
  Pull today's prices from database
  → Pull yesterday's prices for trend comparison
  → Run 47 recipes through cost engine
  → Balanced selection (max 2 fish, 2 chicken, 2 pork, 1 beef, 1 egg, 1 veggie)
  → Avoid duplicate main ingredients in same result set
  → 3-pass selection: strict balanced → relax duplicates → fill remaining
  → Send 8 cheapest to DeepSeek for "Bakit?" reasoning only
  → Cache everything in database

When a user visits:
  → Read from cache
  → Render meal cards with cost breakdowns
  → Zero AI calls. Instant load.
Enter fullscreen mode Exit fullscreen mode

The key insight: every user visit is just a database read. No AI inference, no scraping, no computation. All the expensive work happens once a day at 8 AM, and the results are cached.


Frontend Decisions

A few design choices that matter:

Filipino naming convention:

  • Meat cuts in English: Chicken Breast, Ground Pork, Beef
  • Vegetables and spices in Filipino: Kamatis, Talong, Bawang, Luya
  • Fish in Filipino: Bangus, Galunggong, Tamban
  • Recipe names in Filipino: Adobo, Sinigang, Tinola, Ginisang Sardinas

This matches how Filipinos actually talk about food — you say "chicken breast" but you'd never say "tomato" when you mean "kamatis."

Per-ingredient cost breakdown:
Each meal card shows every ingredient with its cost, color-coded green (required) or rose (optional). Optional ingredients at ₱0 are automatically hidden. Trend arrows (↑↓→) show if prices went up, down, or stayed the same.

Receipt-style price dashboard:
The /prices page shows all ~55-60 commodities in a single-column receipt layout. Color thresholds: green (≤₱100/kg), amber (≤₱250/kg), red (₱251+/kg). Search bar and category filter pills for quick browsing.


Cost Breakdown

Service Monthly Cost
Vercel Hosting $0 (Hobby plan)
Neon PostgreSQL $0 (Free tier, Singapore region)
DeepSeek API ~$0.15–0.30
Domain $0 (using .vercel.app)
Total ~$0.15–0.30/month

That's less than ₱20/month to run a full-stack web app with daily automated data pipelines.


The Real Lesson

This project taught me something I keep coming back to:

Know when to use AI and when not to.

AI is incredible at:

  • Natural language reasoning and explanation
  • Text extraction from messy PDFs
  • Conversational responses
  • Translation and summarization

AI struggles with:

  • Domain-specific structured data (Filipino recipes, palengke quantities)
  • Precise numerical calculations (cost per ingredient)
  • Cultural accuracy (what actually goes in sinigang vs. what ChatGPT thinks goes in sinigang)

For structured, domain-specific data: hardcoded databases + math engines will outperform AI generation every time. Use AI for what it's actually good at — reasoning and language — and let deterministic systems handle the data.


Built With

  • Next.js 14 (App Router) + TypeScript + Tailwind CSS
  • Neon PostgreSQL (Singapore region) for prices, recipes, suggestions
  • DeepSeek API (deepseek-chat) for PDF extraction and reasoning
  • Vercel hosting + Vercel Cron Jobs for daily automation
  • pdf-parse v2 for PDF text extraction
  • AI-assisted development: Bolt.new for initial scaffold, VS Code for everything else

I'm not a traditional software engineer — I come from 4+ years in operations and content moderation. I build production systems using AI-assisted development tools. This project was scaffolded in Bolt.new, extended and debugged in VS Code, version-controlled via GitHub, and deployed on Vercel.


Try It

🔗 Live: ma-anoulam.vercel.app
💻 GitHub: github.com/chanrylejay/ano-ulam (MIT License)

If you cook at home and shop at the palengke — or if you know someone who does — give it a try. Recipe suggestions and feedback are welcome.

And if you're building something where you're tempted to have AI generate structured data: try hardcoding it first. You might be surprised at the difference.


Built by Chanryle Jay Cagara · Manila, Philippines

Top comments (0)