Inspiration

A menu in Tokyo lists 揚げ出し豆腐. A translation app will tell you, correctly, that this is fried tofu in broth. It will not tell you that the broth is usually made from bonito flakes, which is fish. Nothing on the menu says so.

That gap is where people get hurt. In a study of the FARE Patient Registry (Oriel et al., Journal of Allergy and Clinical Immunology: In Practice, 2021), about 54% of reported restaurant reactions happened even though the diner had told the staff about the allergy. At home you can at least have that conversation. Abroad you can't read the menu, and you can't ask the question.

We wanted one tool that does both jobs: find the allergens a menu doesn't print, then make the conversation with the server possible without a shared language.

What it does

  1. You pick your allergies once. They are stored on your device and never sent anywhere.
  2. You scan a menu, or paste its text. Dish lists for Japan and Spain are built in: 40 dishes each, plus an allergen table of 981 words and spellings.
  3. Every dish gets one of three verdicts: Avoid, Ask, or "No listed allergens — still ask". Platecard never tells you a dish is safe. Each verdict gives its reason in plain words, such as "Often made with fish."
  4. You hand over a staff card. Tap "Ask the staff" and the screen becomes a card in the local language with fixed, pre-written questions: does it contain this allergen, is it fried in shared oil. The server taps Yes, No or Not sure, and you read the answers in English.
  5. Unknown dishes get explained, with the source. For a dish that is in no list, "Explain this dish" asks Gemini for the typical recipe. Gemini reads the dish's Wikipedia page, and Platecard links that page as the source. The ingredients go into a shared dish dictionary, so the next traveler sees them at once.
  6. You can see what left your device. A "What was sent" sheet lists every model call, where it ran, and its exact text. Its first line is always "Your allergies: never sent."

Platecard runs as an iPhone app and as a web app in Chrome. Both use the same allergen table and the same dish lists, and give the same verdicts.

How we built it

One rule shapes everything: a fixed list decides, and AI only helps. In our first tests, Apple's on-device model read 海老 (shrimp) as "seaweed". A model that can erase a shellfish allergen cannot be the judge. So every verdict comes from a fixed allergen table and the dish lists. A model may only match a menu line to a known dish, and its result can raise a verdict but never lower one. A test checks that rule for every combination.

How hybrid inference is used, job by job

  • Matching menu lines to known dishes. Real menus rarely spell a dish the way a list does, so a model matches them. This is the main hybrid job.
    • Chrome: getGenerativeModel from firebase/ai with InferenceMode.PREFER_ON_DEVICE. Gemini Nano, built into Chrome, answers when the browser has it ready. Otherwise Gemini in the cloud answers. If an on-device attempt fails or times out, we retry it once in the cloud. The route badge reads response.inferenceSource.
    • iPhone: Apple Foundation Models first (SystemLanguageModel.default). If the phone has no on-device model, the same request goes to Gemini through Firebase AI Logic (FirebaseAI.firebaseAI(backend: .googleAI()).geminiLanguageModel(name:)), used inside the same Apple LanguageModelSession. Firebase's iOS SDK 13 has no built-in hybrid switch, so the choice is our own RoutingPolicy, a small pure function with unit tests.
    • With no model and no signal, spelling rules still give every verdict.
    • Why on-device first: at a restaurant table abroad there is often no signal, and a verdict should not wait on a network. Only dish lines are ever in the prompt, never the allergy profile.
  • Reading the menu photo. On iPhone, Apple's Vision framework reads the text on the phone, and the photo is never uploaded. In Chrome, Gemini Nano reads the photo on the device with PREFER_ON_DEVICE, and the cloud is the fallback. A menu photo holds no allergy data, and the sheet says when one was sent.
  • Explaining an unknown dish. Cloud only, on purpose: InferenceMode.ONLY_IN_CLOUD on the web, and the Firebase AI Logic cloud model on iPhone, both with the URL context tool. Gemini reads the dish's Wikipedia page instead of answering from memory, and the app shows that page as the source. This job needs knowledge of the world, and a small model invents recipes. Only the dish name and the country are sent.
  • Verdicts and the staff card. No model at all: fixed data and fixed phrases.

Every Firebase product in the app

  • Firebase AI Logic: every cloud model call on both platforms, and the hybrid on-device and cloud calls on the web (Firebase iOS SDK 13.2, Firebase JS SDK 13.4).
  • App Check: App Attest in release builds and the debug provider in debug builds on iOS; reCAPTCHA Enterprise on the web app. Both use limited-use tokens for AI Logic. Enforcement is on for Firebase AI Logic and Cloud Firestore.
  • Remote Config: one template for both apps. It holds the cloud model (gemini-3.5-flash-lite) and a fallback model (gemini-3.5-flash), used once after a quota or server error. It also holds switches for the on-device model and for Explain, the web inference mode, the tool Explain uses, the wording of the "none listed" verdict, and a warning banner. A problem during judging can be fixed without an update.
  • Cloud Firestore: the shared dish dictionary, one dishes collection for both platforms. A document holds a dish name, typical ingredients, hidden ingredients such as broths and batters, and Wikipedia source links. It never holds a profile, an allergen choice or a verdict. Each device turns the ingredients into allergens with its own fixed table, and a saved note can only add caution. The security rules check every field for type and size, accept only Wikipedia links, refuse queries, and allow no edits or deletes.
  • Firebase Authentication: anonymous sign-in, used only so the Firestore rules can require a signed-in client. An entry carries the random anonymous ID of the device that wrote it, with no name, email or profile behind it.
  • Firebase Hosting: serves the web app.

One engine, two platforms. The Swift engine is the reference. The TypeScript engine mirrors it and imports the very same JSON data files from the iOS folder, so there is one allergen table, not two. A shared set of parity cases runs in both test suites, so both platforms give the same verdict for the same menu line.

Stack: Swift, SwiftUI, Vision, Foundation Models, xcodegen and XCTest on iOS; TypeScript, Vite, Vitest and Lucide icons on the web.

Challenges we ran into

  • The on-device model got allergens wrong. Shrimp became seaweed. We stopped asking the model about allergens and gave it one narrow job: match names.
  • The same answer on two platforms. Japanese text has to be normalized the same way in Swift and in JavaScript (character width, katakana, accents, dashes). We pinned it with shared test cases until both engines agreed.
  • No hybrid switch on iOS. We wrote and tested the routing ourselves.
  • The simulator's model. Apple's on-device model only answers in the simulator when the simulator runtime matches Xcode's iOS SDK. On older runtimes it reported "not ready" and never recovered.
  • Sharing knowledge without sharing people. The dictionary had to be useful to strangers and say nothing about anyone. Storing ingredient words, and working out allergens on each device, solved both.

Accomplishments that we're proud of

  • It catches what a word scan can't: fish in the broth of fried tofu, wheat and egg in tempura batter.
  • The same product on iPhone and in Chrome, from one Firebase project, with shared data and shared test cases.
  • It still works with no AI at all. With no on-device model and no signal, the fixed list still gives verdicts and the staff card.
  • Tests: 110 iOS tests (XCTest, 0 failures) and 248 of 248 web tests (Vitest).
  • Measured in the iOS 27.2 Simulator: Apple's on-device model matched six menu lines in about 6 seconds. The cloud route, with App Check enforced, took about 7 seconds for the same six lines (measured before we moved to the current cloud model).

What we learned

Small on-device models are good matchers and poor authorities. The safest design lets a model add caution and nothing else. We also learned that "hybrid" is a product decision before it is an API: decide for each job what must work offline, what must stay private, and what truly needs the cloud, and the routing follows.

What's next for Platecard

  • Dish lists reviewed by native speakers and by allergy specialists, then more countries.
  • Testing on physical iPhones and with real menu photos (glare, handwriting, vertical text). So far the iOS app has run only in the iOS Simulator.
  • A known limit in the dish dictionary. Notes are create-only, so the first note saved for a dish stays, even if a better one comes later. The verdict engine only ever adds caution, so a bad note can never make a dish look safer. Next, a server function will review notes, one per verified install, so a note can be corrected.
  • A way to carry your allergy card between your phone and your browser without putting your allergies on a server.

Notes for judges

  • AI coding tools. Platecard was built with Claude Code, an AI coding agent, directed and reviewed by the author. We installed the Firebase Agent Skills plugin and used its firestore-rules-creation skill to write the Firestore rules and its firebase-security-rules-auditor skill to audit them (docs/rules-audit.md).

Built With

  • app-attest
  • cloud-firestore
  • eslint
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • foundation-models
  • gemini
  • gemini-nano
  • google-fonts
  • lucide
  • recaptcha-enterprise
  • swift
  • swiftui
  • typescript
  • vision
  • vite
  • vitest
  • xcodegen
  • xctest
Share this project:

Updates

Submission history