Recipe price calculator API and thin-client
  • Python 43.6%
  • JavaScript 34.7%
  • HTML 19.6%
  • CSS 1.4%
  • TypeScript 0.7%
Find a file
Hugo O'Connor 843af140d2
fix(website): link all extension buttons to Chrome Web Store
Update remaining download/extension buttons across index, privacy,
and embed-demo pages to point directly to the extension listing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 09:19:47 +11:00
api docs: add extract/sample commands to AGENT.md 2025-12-30 17:25:38 +11:00
extension feat: link to ingredient source 2025-12-30 13:19:05 +11:00
price-packs Add Grub Price browser extension with LLM ingredient parsing 2025-12-18 11:58:37 +11:00
scripts feat: add VIC, QLD, TAS regions to API pricing 2025-12-27 18:34:29 +11:00
training Add Grub Price browser extension with LLM ingredient parsing 2025-12-18 11:58:37 +11:00
website fix(website): link all extension buttons to Chrome Web Store 2026-01-14 09:19:47 +11:00
.gitignore feat: add usage meter, update icons, bump free tier to 12 2025-12-29 18:45:31 +11:00
LICENSE Add AGPL-3.0 license headers to source files 2025-12-27 12:32:58 +11:00
package.json feat: add nz price pack 2025-12-29 14:32:32 +11:00
README.md docs: update README 2025-12-27 12:44:54 +11:00
tsconfig.json Add Grub Price browser extension with LLM ingredient parsing 2025-12-18 11:58:37 +11:00

Recipe Price

Calculate the cost of any recipe while browsing. A browser extension that extracts ingredients from recipe websites and estimates the total cost using local grocery prices.

How It Works

  1. Browse any recipe site - Extension detects JSON-LD recipe schema automatically
  2. See the cost instantly - Floating badge shows total cost and per-serve price
  3. Click for breakdown - Expand to see individual ingredient costs

The extension uses an LLM (via Groq API) to parse natural language ingredients like "2 1/2 cups flour, sifted" into structured data (2.5 cups flour), then looks up prices from regional price packs.

Project Structure

recipe-price/
├── api/                    # Cloudflare Worker API
│   ├── src/
│   │   ├── index.js        # Hono routes
│   │   ├── parser.js       # LLM ingredient parsing (Groq)
│   │   ├── pricing.js      # Price lookup & cost calculation
│   │   └── auth.js         # API key validation
│   ├── data/
│   │   └── au-nsw-2000.json  # Price pack (1800+ ingredients)
│   └── wrangler.toml
├── extension/              # Chrome Extension (MV3)
│   ├── src/
│   │   ├── background.js   # Service worker, API client
│   │   ├── content.js      # Page injection, UI
│   │   ├── content.css     # Badge & panel styles
│   │   └── recipe-parser.js # JSON-LD extraction
│   └── manifest.json
└── price-packs/            # Price data sources

API

Live at: https://api.recipeprice.com

Endpoints

GET /v1/detect

Detect user's region from IP (Cloudflare geolocation).

{
  "detected": "AU-NSW",
  "bestMatch": "AU-NSW",
  "available": ["AU-NSW"],
  "geo": { "country": "AU", "region": "New South Wales", "city": "Sydney" }
}

POST /v1/recipe/cost

Calculate recipe cost. Region auto-detected if not provided.

curl -X POST https://api.recipeprice.com/v1/recipe/cost \
  -H "Content-Type: application/json" \
  -d '{
    "ingredients": ["2 kg chicken breast", "1 tbsp olive oil", "3 cloves garlic"],
    "servings": 4
  }'

Response:

{
  "success": true,
  "data": {
    "ingredients": [
      {
        "original": "2 kg chicken breast",
        "parsed": { "amount": 2, "unit": "kg", "ingredient": "chicken breast" },
        "cost": 24.00,
        "price": { "matched": "chicken_breast", "price": 12.0, "confidence": "high" }
      }
    ],
    "totalCost": 25.47,
    "costPerServing": 6.37,
    "region": "AU-NSW",
    "currency": "AUD"
  }
}

GET /v1/regions

List available price packs.

Development

API

cd api
npm install
cp .dev.vars.example .dev.vars  # Add GROQ_API_KEY
npm run dev                      # Local dev server on :8787
npm run deploy                   # Deploy to Cloudflare

Extension

  1. Go to chrome://extensions/
  2. Enable "Developer mode"
  3. Click "Load unpacked" and select the extension/ folder

Price Packs

Price data is stored as JSON files in api/data/. Each pack contains:

  • ~1800 ingredients with prices per kg/litre
  • Aliases for common variations (e.g., "capsicum" → "bell_pepper")
  • Category-based estimates for unmatched items

Currently available:

  • AU-NSW - Australia (New South Wales), prices in AUD

Adding a new region

  1. Create api/data/{region-code}.json following the existing format
  2. Import in api/src/pricing.js and add to PRICE_PACKS
  3. Deploy

Tech Stack

  • API: Cloudflare Workers, Hono, Groq (Llama 3.1 8B)
  • Extension: Chrome MV3, vanilla JS
  • Parsing: LLM-based (no regex) for natural language ingredients

License

GNU Affero General Public License v3.0 (AGPL-3.0)

This means:

  • You can use, modify, and distribute this code
  • If you run a modified version as a network service, you must open-source your changes
  • All derivatives must use the same license

See LICENSE for full text.