Inspiration

Ingredient labels are long, tiny and full of codes like "INS 322", and they don't know who is reading them. "Contains sugar" means something very different to someone with diabetes, and "whey powder" matters to someone who is lactose intolerant. Generic health scores ignore your conditions, and asking a cloud chatbot means sending your medical history to a server. We wanted personal answers without giving up privacy.

What it does

ScanTruthAI tells you whether a food, supplement or medicine suits your health.

  1. Build your health context privately. Upload a medical report (PDF or photo) or type a note. Names, IDs, phone numbers and addresses are masked on your device. You see exactly what will be sent and approve it. Only the masked text goes to the cloud, where Gemini extracts your conditions, allergies, medications and dietary needs.
  2. Scan a label. Point the camera at the ingredients panel. The app reads only the ingredient list and ignores nutrition tables, allergen statements and the rest of the pack.
  3. Get a personal verdict. Every ingredient is checked against your profile: a 0–100 safety score, a verdict (Good match / Use with care / Avoid), a per-ingredient breakdown and serving guidance.
  4. Everywhere. Sign in with Google and your profile and scan history sync across Web, Android and iOS. Guests can use everything for the session without an account.

How we built it

Three native apps with the same design share one Firebase backend and one Firestore data model. A scan saved on Android shows up on the web and on iOS.

Firebase AI Logic hybrid inference on every platform:

  • Web (Chrome): Gemini Nano via the Chrome Prompt API, with Gemini 3.5 Flash-Lite in the cloud
  • Android: Gemini Nano via firebase-ai-ondevice, with Gemini 3.5 Flash-Lite in the cloud
  • iOS: Apple Foundation Models, with Gemini 3.5 Flash-Lite in the cloud

There's no single "on-device first" or "cloud first" rule. Each task is routed by what it needs (privacy or reasoning power) and by the user's choice:

  • Masking personal details in medical reports and notes always runs on the device, never the cloud. The on-device model finds free-form names and identifiers where it's available, and a rule-based filter always runs, so masking works on every device.
  • Checking health items you type in uses the on-device model first, so the entry stays private, and the cloud only when no on-device model is available.
  • Extracting your health profile uses the cloud model, and only for the masked text you approved.
  • Ingredient analysis is your choice: Auto uses the cloud for the best analysis and switches to the on-device model if the cloud is unreachable, rate-limited or blocked; Cloud and On-device run only that model.

Every result names the model that produced it, and any switch to the on-device model is shown to the user. The app never silently shows a guessed result.

Text recognition:

  • Web labels: Gemini 3.5 Flash-Lite reads the photo directly. Offline, PaddleOCR runs in the browser (with automatic straightening of tilted photos), then Gemini Nano or a rule-based parser picks out the ingredients. Tesseract.js is the last resort.
  • Web medical reports stay on the device: the PDF's own text layer first, then PaddleOCR for scanned pages, with model files served from our own site.
  • Android uses ML Kit and iOS uses Apple Vision, both on-device.

Security: Firebase App Check protects every AI call (reCAPTCHA Enterprise on the web, Play Integrity on Android release builds). Firestore security rules limit each document to its owner and validate every write, and they have their own test suite.

Stack: React + TypeScript + Vite on Firebase Hosting; Kotlin + Jetpack Compose; Swift + SwiftUI; Firebase Authentication, Cloud Firestore, Firebase AI Logic and App Check.

Challenges we ran into

  • Privacy masking without an on-device model. Many devices don't have Gemini Nano or Apple Intelligence, so a rule-based filter always runs and the on-device model adds to it where available. Masking never depends on the cloud.
  • OCR on real packaging in the browser. Curved, glossy, tilted labels defeated plain Tesseract. We moved to Gemini reading the photo, with an on-device fallback of PaddleOCR plus our own deskewing step, after finding that even a 2° tilt garbled PaddleOCR's output.
  • One data model, three platforms. Keeping Kotlin, Swift and TypeScript writing identical Firestore documents, under strict security rules, took careful schema work and tests.
  • App Check everywhere. Firebase AI Logic requires App Check, which meant a different provider and debug-token setup on each platform.

Accomplishments that we're proud of

  • Hybrid AI on all three platforms, with each task on the model that fits it and the model always named in the result
  • Medical documents never leave the device unmasked, and the user approves every byte sent
  • Offline label reading in a plain web page, with no install
  • One profile and scan history that follows you across Web, Android and iOS

What we learned

On-device models are strongest where privacy matters most: reading and masking sensitive documents. The cloud model is best for reasoning across a whole ingredient list and a health profile. Designing for "the on-device model may not exist" from day one made every fallback explicit and honest.

What's next for ScanTruthAI

  • Signed release builds on Google Play and the App Store
  • Full offline support on the web with a service worker
  • More languages for labels and reports
  • Barcode lookup to complement label scanning

Built With

  • android-studio
  • apple-foundation-models
  • apple-vision
  • chrome-built-in-ai
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firestore
  • gemini-3.5-flash-lite
  • gemini-nano
  • google-mlkit
  • jetpack-compose
  • kotlin
  • onnx-runtime-web
  • paddleocr
  • pdf.js
  • react
  • recaptcha-enterprise
  • swift
  • swiftui
  • tesseract.js
  • typescript
  • vite
  • xcode
Share this project:

Updates

Submission history