Recipe price calculator API and thin-client
- Python 43.6%
- JavaScript 34.7%
- HTML 19.6%
- CSS 1.4%
- TypeScript 0.7%
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> |
||
|---|---|---|
| api | ||
| extension | ||
| price-packs | ||
| scripts | ||
| training | ||
| website | ||
| .gitignore | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
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
- Browse any recipe site - Extension detects JSON-LD recipe schema automatically
- See the cost instantly - Floating badge shows total cost and per-serve price
- 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
- Go to
chrome://extensions/ - Enable "Developer mode"
- 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
- Create
api/data/{region-code}.jsonfollowing the existing format - Import in
api/src/pricing.jsand add toPRICE_PACKS - 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.