A volunteer at a food bank sort table holds up a donated carton. Keep Until reads the date stamped on it, checks Food Banks Canada's shelf-life chart, and says what to do: keep it until a date, set it aside for the sort lead, or discard it, and only after two reads agree on the date. Every item lands in the food bank's own Google Sheet, and every morning the app checks what was kept against new Government of Canada food recalls.
Gemini Nano checks each photo on the laptop first. Only photos with a date worth reading go to the cloud. With Hands-free on, Nano watches the camera itself and calls the cloud only when a date or a fridge item faces it, so the volunteer has nothing to press. It says each answer aloud from recordings shipped with the app (Chrome's own voice only if a recording cannot play). Built for #BuildHybridAI 2026 with Firebase AI Logic, on Web (Chrome) and Android (the Android app has the same read loop and chart gate, with a Read item button and no hands-free).
To watch hands-free with no item and no webcam, open the app with ?clip=1 in Chrome with Gemini
Nano: a 70-second clip of real pantry photos plays in the camera's place, and nothing from it is
logged. ?clip=long plays the 8-item clip (all 16 pantry photos, 243 seconds). To watch a
recorded run in any browser, with no on-device model, open ?replay=1.
Try it: https://keep-until-hybrid.web.app. No item to hand or no webcam? Press Try a sample photo: it reads a real carton from my pantry the same way, front first, then the top, then a yogurt lid, then a jar of peanut butter dated 2021 that the chart says to discard.
You need Node.js 20 or newer. For on-device reads, desktop Chrome with these turned on in
chrome://flags: Gemma 4 for Built-in AI, Prompt API for Gemini Nano and Prompt API
for Gemini Nano with Multimodal Input. Without them the app still works and says every read
went to the cloud.
git clone https://github.com/JonathanSolvesProblems/keep-until.git
cd keep-until
npm --prefix web install
npm --prefix web test # the chart gate, the date parser, the loop, the sheet
npm --prefix functions install
npm --prefix functions test # the recall matcher, on real recall notices
cp web/.env.example web/.env.local # then fill in your own Firebase project (below)
npm --prefix web run dev # http://localhost:5173The tests need nothing else. Reading items needs a Firebase project of your own in
web/.env.local: register a web app, run npx -y firebase-tools@latest init ailogic, and set up
App Check (a reCAPTCHA Enterprise key for localhost and a debug token). The Android app is in
android/ (./gradlew testDebugUnitTest assembleDebug).
To check the reads yourself, open Testing tools after Start shift: Run comparison reads
the 16 pantry photos three ways and downloads one file; grade it with
python scripts/grade_run.py <that file> results/labels/pantry-2026-11-15.json.
- Reads the stamp the way it is printed. Canadian date stamps put the year first and use bilingual two-letter months ("2027 FE 14"). The app re-prints the stamp large, then the date in words, then the decision and the chart row and page it came from.
- One item, two photos. A carton's front shows the name and no date; its top shows the date and no name. The app asks for the side it is missing and settles from both photos.
- Nothing is binned on one read. A discard needs a second read that finds the same date. A year far from today (a cut-off "2027" read as "5037") is refused, and the item goes to the lead.
- Lands where the food bank already works. Each item becomes a row in the food bank's own Google Sheet (Drive file access only, queued while offline), and in Firestore.
- Keeps watching after the shift. A scheduled Cloud Function pulls the Government of Canada recall feed every morning and lists kept items that share a brand with a food recall. At the next shift start Gemini settles each one: pull it, check the lot code, or no match.
- Says what it could not do. "This laptop could not check it", "Google could not verify this browser", "No name in this photo": limits are stated on the screen where they apply.
| What | Result | File |
|---|---|---|
| Hands-free on real Gemini Nano, 8 items and 16 photos, nobody touching the laptop, expected answers registered before the run | 100 checks on the laptop, 6 calls to the cloud, 6 of 7 graded items right | 8-item run |
| The same 8-item test run again the next morning, voice on, recorded for the video | 104 checks on the laptop, 6 calls to the cloud, the same 6 of 7 | second run |
| Hands-free, the 70-second clip the replay plays | 31 checks on the laptop, 2 calls to the cloud, both items answered right | 70-second run |
| Hybrid: Nano checks every photo on the laptop, the cloud reads dates | 13 of 15 handled right, 6 cloud calls for 16 photos | ablation |
| Cloud only | 14 of 15, 16 cloud calls | ablation |
| Gemini Nano alone on the laptop | 4 of 15 | ablation |
| Gemini Nano alone, re-measured on Chrome's newer on-device model | 4 of 15 pantry photos; 13 of 100 outside dates read right (the cloud: 71) | Nano alone |
| Date reading, 100 photos of products sold in Canada, dates confirmed by Open Food Facts volunteers, registered before the run | 71 of 100 read right; of the 29 misses, 14 read the best-before where the confirmed date was the packed-on date, 2 clear misreads | date control |
| Were the discards right? The same 100 photos, the chart re-run with each volunteer-confirmed date | 32 discards, 0 wrong discards; 26 times the second read disagreed and the item went to the lead | discard check |
| Recall check, 16 real notice and item pairs in two sets, answers registered before each run | Gemini 16 of 16, brand plus a product word 11 of 16, brand alone 6 of 16 | recall control |
| Android gate against the web gate | identical on 294 stamps and 2,580 chart decisions | shared/gate-vectors.json |
| Android on Firebase Test Lab (Pixel 10, Pixel 11, Galaxy S26) | 14 of 15 on the cloud path; on-device unavailable (stub AICore) | Test Lab |
| Android 8 and Android 16 emulators, no on-device model | same answers on the sample carton; offline message fixed | emulators |
"Handled right" means what a careful volunteer would do: logged with the right date, asked to turn the item when no date is in view, or set aside when it needs the fridge. One photo whose stamp I could not read by hand either is not scored. The set mostly tests routing: 9 of the 15 scored photos should get "turn it", so an app that always said "turn it" would score 9 of 15, and only 2 show a date to log (both modes read 1 of them right). Date reading has its own test on 100 outside photos (below).
What it cannot do yet:
- Nobody at a food bank has used it. Everything here was measured on my own pantry and on public photos.
- Hands-free has run on clips of still photos, on one laptop, plugged in. In the 8-item run it never found the small, upside-down date on a bag of chocolate chips and kept asking for it to be turned. On battery my laptop throttles its GPU, a check takes 6 to 10 seconds, and hands-free switches itself off and says so. Two tabs watching at once halve its speed. Gemini Nano's first start after Chrome opens has taken about 8 minutes; items are read in the cloud until it is ready.
- An Android on-device result needs a phone on Google's Nano list (Pixel 9 or later, Galaxy S25 or later); Test Lab's phones, the emulators and my own Galaxy S24 run the cloud path and say so.
- The model picks the chart row, and nothing grades that choice yet.
- Lot codes are not read, so a recall limited to certain lots is always "check the lot code" for the lead.
Firebase AI Logic (hybrid inference on web and Android: the photo check on-device with the cloud taking over when it cannot run, the date read in the cloud, and PREFER_IN_CLOUD for the recall check), App Check, Authentication (anonymous for volunteers, Google for the coordinator's sheet), Firestore (offline, append-only rules), Remote Config (the cloud model and each food bank's own policy over the chart), Performance Monitoring (a trace per read, tagged on-device or cloud), Cloud Functions with Cloud Scheduler (the daily recall pull, retried when the feed download drops), Crashlytics on Android (failed reads, with whether the phone was online), and Hosting.
Every published source the app uses, and the results file behind each number on this page, is listed in devpost/sources.md. The build, decision by decision, is in devpost/build-log.md.
The voice: the spoken answers are 124 short recordings made once with ElevenLabs text to speech
(scripts/make_voice.mjs), listed word for word in web/public/voice/lines.json. The app plays
the files and never calls ElevenLabs; a test fails when a line has no recording of the same words.
Apache-2.0. See LICENSE. One exception: the peanut butter sample photo
(web/public/testset/off/0056664013115-2.jpg and its Android copy) is by Open Food Facts
contributors, CC BY-SA 4.0 (credits).
Built by Jonathan Andrei for food bank sort tables. More of what I build at jonathansolvesproblems.com.