Inspiration

Dining out with a food allergy means relying on menus that may not list every ingredient. The Consumer Affairs Agency of Japan states on its public page (accessed November 22, 2026) that its mandatory allergen labeling covers packaged processed foods, and it is currently surveying restaurants and takeout shops about how they provide allergy information. AllerCard Hybrid helps a person with an allergy check a menu, and show the result to the staff, without giving the allergy list to any model.

What it does

The user selects their allergens once. The list is saved only in the browser. The user then pastes the menu text or uploads a menu photo (PNG or JPEG). The model reads the menu and returns the allergen names it finds, from a fixed list of nine. Anything it cannot map is shown as unclear. The app compares the result with the user's list in plain code. The result shows a possible match, a check with the staff, or no match in the text that could be read. It never says a dish is safe, because the check is an estimate. The app also shows a card in Japanese and English that the user can show to the staff.

Features: a saved list of the nine specified allergens (特定原材料), menu text or photo input, a device-only mode, a source line on each result, a manual check that works without AI, a word match on the menu text that adds allergens the model missed, and a bilingual card with a full-screen view. If the Firebase settings are missing, the app shows the reason and keeps the manual check working.

How I built it

The app calls getAI with GoogleAIBackend, then getGenerativeModel with InferenceMode.PREFER_ON_DEVICE (Auto) or ONLY_ON_DEVICE (Device only). The on-device and the cloud configuration both carry the same JSON schema for structured output, and the allergen field is constrained to the nine ids. The app calls initializeDeviceModel from a button click, as the SDK requires. Each result reports its inferenceSource (ON_DEVICE or IN_CLOUD), and the result shows it. App Check is set up with reCAPTCHA Enterprise and enforced for Firebase AI Logic.

It is a static web app (HTML, CSS, JavaScript modules) built from an empty repository created for this contest, with a plain-code allergen matching module and automated tests run with the Node.js test runner.

Why hybrid

The allergy list is health data, so the app keeps it in the browser and matches it there; no model receives it. When the on-device model is used, the menu stays on the device too. When the device cannot run the model, the app uses the cloud model for the menu only, and the result says so. The same screen works on devices with and without the on-device model.

Challenges I ran into

At first the on-device model stayed in the "downloading" state on my test machine. Chrome needs at least 22 GB of free disk space for the model, and my Mac had less. The first demo video was recorded then, so it showed only the cloud fallback and the Device only mode refusing to run. Device only checks Chrome's model state first: if the model is not "available", it does not run the check and sends nothing to the cloud.

After I freed disk space, the model finished downloading (November 29, Chrome 158 on macOS). With a Japanese menu that contains egg and wheat, both Auto and Device only found egg and wheat and showed "Checked on this device". With a menu that contains none of the nine allergens, the on-device model did not give a clear answer, so the app asked the user to confirm with the staff instead of reporting no match. A picture of the egg-and-wheat menu in Device only was also read on the device and gave egg and wheat, both as PNG (about 40 seconds) and as JPEG (about 20 seconds). With fetch and XHR blocked inside the page (a simulation, not a real airplane-mode test), Auto still ran on the device and made no network request.

The on-device model is not deterministic. In one run it reported only wheat for a menu that literally says 卵 (egg). So I added a plain-code word match on the menu text: if an allergen word such as 卵, 小麦 or "egg" is written in the text, it is added to the result even when the model missed it. It can only add allergens, never remove them, and it does not help with photos. On the live page I then saw the model miss egg again, and the app still reported egg with the line "Found by word match in the menu text". The demo video was updated on November 29 to show these on-device runs.

What's next

No user testing has been done yet. Next I want people with allergies and restaurant staff to try the card, and to add the items listed as 特定原材料に準ずるもの.

Limits

Only the nine 特定原材料 are checked. 特定原材料に準ずるもの (for example almond and pistachio) are not covered. On-device inference needs Chrome on desktop, version 139 or later, with the on-device model downloaded (about 22 GB of free disk space is needed). On Chrome 158 for macOS no flag was needed; older versions may need one. The word match on menu text uses a short fixed word list and simple substring matching, so it can flag words that only look like an allergen. The menu may be incomplete, so every result is an estimate.

Testing instructions

No account or login is needed. Use Chrome on desktop, version 139 or later.

  1. Open https://vpgkotaro-jpg.github.io/allercard-hybrid/ . Under "1. Your allergens", tick two or three items.
  2. Under "2. Check a menu", paste this sample menu, then click "Check this menu": Chicken karaage with soy glaze (wheat, egg), white fish meunière with butter sauce, rice.
  3. The result shows whether the check ran on the device ("Checked on this device") or in the cloud ("Checked in the cloud").
  4. On-device model (optional): click "Prepare on-device model" and wait for the download (Chrome needs about 22 GB of free disk space), then check again. On older Chrome versions you may also need to enable chrome://flags/#prompt-api-for-gemini-nano-multimodal-input and restart Chrome.
  5. Device only: if the model is not ready, the app says so and sends nothing to the cloud.
  6. "Check by hand" works without AI.

AI tools disclosure: this project was written with Claude Code, an AI coding assistant. The Firebase AI Logic integration and the app's behavior were checked by the author.

Built With

Share this project:

Updates

Submission history