How AI Estimates Your Food's True Expiry Date
You scan a receipt, and three seconds later every item has an expiry date — including the produce that never had a label. Here's the machinery behind that trick.
Most expiry apps have a dirty secret: the dates are whatever a volunteer typed into a database years ago. ShelfLife takes a different approach. When a receipt scan lands an item in your inventory, the app runs a pipeline that asks real models, checks shared caches, and falls back to USDA-derived guidance when the network fails. This post walks through each layer — the same way we'd explain it to an engineer, minus the jargon.
The core problem: receipts don't print shelf lives
A grocery receipt tells you what you bought and what you paid. That's it. No dates, no storage hints, no "use by" stamps. The celery you bought at the deli counter has no label at all. And even when a package does carry a date, it's often a quality suggestion aimed at the retailer — not a safety deadline for your kitchen. We break down what the labels actually mean here; the short version is that "sell by" and "best before" tell you surprisingly little about when food turns.
So an expiry tracker that's actually useful has to answer a question the receipt never answers: given this specific item, stored the way you store it, how long is it realistically good for? That's an estimation problem — which is why it's a job for AI, not a static lookup table.
Step 1: turning a receipt line into real food
Everything starts with the scan. AI vision reads every line of the receipt — the club pack of chicken thighs, the store-brand oat milk, the two loose Roma tomatoes. Then a cleanup pass (powered by Gemini) normalizes the noise: "CLC MT RND 3.99LB" becomes chicken, and cryptic store-brand names get matched to recognizable product categories with estimated quantities.
The output isn't a barcode match or a best-guess string — it's a normalized food item with a category, a quantity, and enough context for the next stage to reason about. The full OCR internals are covered in the receipt-scanning deep dive; for expiry purposes, the key point is that the pipeline catches everything, including unlabeled produce, bulk-bin items, and deli purchases that no barcode database has ever heard of.
Step 2: the multi-provider AI cascade
Here's where most "AI-powered" apps would take a shortcut: one API call to one model, and if it's down, your dates are down. ShelfLife doesn't rely on any single vendor. Every expiry estimate runs through a multi-provider AI cascade with automatic failover — think of it as a relay team rather than a solo runner.
The first provider gets the question: "How long does whole milk last, refrigerated, purchased today?" If it answers in time, done. If it's slow, rate-limited, or having a bad day — and every AI provider eventually has one — the request automatically fails over to the next provider in the chain. You never see the handoff. From the kitchen counter, the whole thing takes a few seconds and the answer just appears.
Why bother? Because expiry dates are the foundation of everything else the app does — alerts, Eat This First scores, Rescue Mode recipes. If the foundation depends on one vendor's uptime, the whole product wobbles every time that vendor has an outage. A cascade with failover means your Tuesday-night "what's about to turn" answer doesn't depend on someone else's status page.
What the models are actually reasoning about
When a model estimates shelf life, it's weighing a handful of factors that any cook knows from experience — it just does so consistently, for thousands of items:
- Perishability class. Raw poultry is a two-day proposition; hard cheese is a two-week one; dried pasta is measured in years. The base category sets the anchor.
- Storage zone. The same tomato has three different lifespans depending on whether it sits on the counter, in the fridge, or in the crisper. Estimates are adjusted per storage zone — which is also why where in the fridge you put things matters as much as the date itself.
- Temperature reality. A fridge at 40°F (4°C) keeps milk good for days longer than one that drifts to 45°F. Consistent cold is the single biggest lever on real shelf life.
- Processing and packaging. Ultra-pasteurized milk, vacuum-sealed meat, canned versus fresh — how food was treated before it reached you changes the clock.
The estimate you get isn't a random guess or a marketing number; it's a reasoned window that reflects how that item actually behaves under normal conditions.
Key takeaway: the cascade never relies on one vendor being up. If the first AI provider is slow or down, the request fails over automatically. Your dates keep flowing either way.
Step 3: two layers of cache, so nobody pays twice
Asking an AI model the same question twice is wasteful, and shelf-life answers don't change week to week. So each answer gets cached in two places: a device cache on your phone, and a shared Supabase cloud cache across all ShelfLife users.
The practical effect: the second person to scan whole milk gets their answer nearly instantly, pulled from the cloud cache instead of triggering a fresh model run. And because your own device keeps a copy, items you've scanned before don't even need the network. Faster answers, less battery, fewer API calls — boring infrastructure, but it's the difference between a snappy scan and a spinning loader.
Step 4: the USDA-derived offline fallback
Now the part most AI apps skip entirely: what happens when you're standing in a grocery parking lot with one bar of signal? This is where the local fallback earns its keep — an offline dataset built from USDA food-storage guidance, sitting on your device.
If the cascade can't reach any provider — airplane mode, dead zone, full outage — the app quietly answers from that USDA-derived table instead. No spinner, no "check your connection," no skipped items. The dates are more conservative and less item-specific than a fresh AI estimate, but they're grounded in the same authoritative storage data the USDA's own FoodKeeper app publishes. (For how that guidance stacks up against a modern tracker, see our ShelfLife vs FoodKeeper comparison.)
The result is an expiry engine that works on a plane, in a basement grocery store, or during a provider-wide outage. Your inventory doesn't wait for the internet.
| Layer | Runs when | Speed | Character |
|---|---|---|---|
| Device cache | Item already scanned by you | Instant | Your previous answer, unchanged |
| Shared cloud cache | Another user asked the same item | Fast | Consensus answer, no model run needed |
| AI cascade | First time anyone asks this item | Seconds | Fresh multi-provider estimate with failover |
| USDA-derived fallback | Offline or all providers down | Instant, offline | Conservative storage-guidance window |
Habit-based personalization
Every household is different. Some people demolish a gallon of milk in three days; others nurse one for two weeks. As you use the app, it learns how fast you actually consume each category and tightens or relaxes its reminders to match — a personalization layer that turns the expiry predictor from a generic estimate into one shaped by your real behavior.
Combined with the full receipt-to-reminder walkthrough, what you end up with isn't a static database of dates. It's a system that knows what you bought, how you store it, how fast you eat it, and what to do when something slips past its window.
What this means in practice
Scan a receipt in any conditions — full signal or none — and every item gets a usable expiry estimate. Alerts fire at 7, 3, and 1 day out, and urgent items ping within the hour, so a silent estimate in a database never becomes a forgotten bag of spinach. When something is genuinely about to turn, Eat This First scores it against recipes you can actually make tonight.
The stakes are real: the average US household wastes roughly $1,500 a year on food. Estimates you can trust are what turn "I should use that chicken" into an alert you actually get before it's too late.
One honest caveat: these are estimates, not guarantees. We're not a food-safety authority. Storage conditions vary, and no model can see inside your fridge. When in doubt — smell it, check it, and if something seems off, throw it out.
See the estimates in action
Scan one receipt and watch every item get a realistic expiry date — offline included.
See how it works Get early access