# Grocery Price Provider Strategy

Status: MVP guardrails for Grocery Optimizer price research.

## Non-negotiable rules

- No invented prices.
- No LLM price source.
- No login scraping.
- No automatic ordering.
- No provider calls during normal page render.
- No secure saving without price, unit price or comparable package/unit, source, date and confidence.
- Uncertain prices remain review suggestions and are never counted as secure savings.

## Three-layer model

### A. Product mapping

Goal: Migros receipt product → normalized product → possible alternatives.

Allowed sources:

- Accepted manual mappings.
- Open Food Facts / FoodRepo-style product data for product metadata.
- Optional local LLM/Qwen for normalization, unit extraction, candidate comparison and clustering.

Prices are not required in this layer.

### B. Price source

Goal: price and unit price with date and source.

Allowed sources:

- Open Prices if data exists.
- Manual user-entered price.
- User-checked Rappn or retailer link-out.
- Later official or commercial API after explicit approval.

### C. Saving calculation

Only allowed when all are present:

- price
- unit price or comparable package/unit
- comparable unit
- price date
- source/link
- sufficiently high confidence

Otherwise the item remains a review suggestion.

## LLM role

Allowed:

- Normalize product names.
- Recognize units.
- Compare product candidates.
- Cluster similar products.
- Interpret barcodes/product text.
- Draft review suggestions.

Forbidden:

- Generate prices.
- Act as price source.
- Decide secure savings.
- Confirm mappings without user review.

## Provider matrix

- Rappn.ch: public API not confirmed. `https://api.rappn.ch` returned 403/500 during public docs check. MVP mode is link-out only plus manual user-checked price entry (`manual/rappn_user_checked`). Do not scrape.
- Open Food Facts: official public product data API. Useful for product/barcode metadata, not prices.
- Open Prices: official public API. Useful for explicit low-volume spike candidates with source/date/attribution. Results remain review candidates until the complete saving criteria are met.
- FoodRepo: Swiss product data appears legacy/redirected to Open Food Facts. Not a price source.
- Pepesto: commercial grocery API option. Evaluate later; not enabled in MVP.
- Migros/Coop/Denner/Aldi/Lidl/Otto’s direct websites: no login scraping and no unstable HTML scraping for secure savings. Direct searches are experimental only and never silently run.

## MVP implemented behavior

- Provider strategy endpoint documents matrix and LLM rules.
- Rappn creates a safe external link-out only.
- Open Prices spike uses explicit user action only and returns review candidates with attribution.
- Manual mapping has Preview → Confirm → Audit.
- Manual prices can count as secure only with source, date, price and unit price/package data.
- Cache status distinguishes manual, fresh, stale, missing and error.
