Inspiration

Every week millions of people get a lab report full of numbers and abbreviations, and the fastest way to understand it today is to paste it, name, phone, patient ID and all, into a cloud chatbot. In India, where many of us get reports on WhatsApp from diagnostic chains, the report's header carries more identity than the results. We wanted the help without the leak: a tool where privacy is something you can see, not a policy you have to trust.

What it does

  1. Paste text or drop a photo of a lab report (three realistic synthetic reports are built in).
  2. Read on your device. Firebase AI Logic runs Gemini Nano inside Chrome. Deterministic rules seal names, IDs, phones, emails, dates and addresses before any model sees the text, and Gemini Nano extracts each test as structured JSON and flags any identifier the rules missed.
  3. The airlock. Veil shows the report with identity sealed on the left and, on the right, the exact anonymous packet that may leave: test names, values, units, ranges, an age band and sex. Nothing else. You choose: open the airlock to cloud Gemini, or keep it all on the device.
  4. Plain-language results in six languages (English, Hindi, Malayalam, Tamil, Spanish, French): an urgency badge, one card per test with a range bar, questions to ask your doctor and everyday notes. Veil explains, it never diagnoses or prescribes.
  5. Follow-up questions stream from the on-device model first.
  6. Privacy ledger and receipt. Every model call is logged with the inference mode Veil asked for, where Firebase AI Logic says it actually ran (inferenceSource), latency and the exact payload. The receipt summarises it: "Your identity never left this device."

Strict mode (Device only) fails closed: if Gemini Nano isn't available, nothing is sent anywhere. Photos can't be rule-scrubbed, so a photo never reaches the cloud without an explicit consent dialog.

How we built it

  • Firebase AI Logic hybrid inference (firebase/ai, getGenerativeModel with mode):
    • Read: ONLY_ON_DEVICE in strict mode, PREFER_ON_DEVICE in hybrid, with structured output on both sides (responseConstraint on device, responseSchema in the cloud) and multimodal image input.
    • Explain: PREFER_IN_CLOUD, receiving only the anonymous packet; ONLY_ON_DEVICE when offline.
    • Ask: PREFER_ON_DEVICE, streamed with generateContentStream.
  • Firebase App Check (reCAPTCHA Enterprise) protects the Gemini endpoint; Remote Config sets the cloud model and explanation tone; anonymous Auth + Firestore keep a private history of anonymous values only, with rules that reject any other field; Firebase Hosting serves the PWA.
  • React 19, Vite, Tailwind CSS 4, Motion for the sealing and airlock animations, and a Web Audio sound design synthesised in code (no audio files).
  • The privacy boundary never depends on a model behaving: the outbound packet is rebuilt from analyte fields only and every field is re-checked by the rules; anything that looks like identity is dropped. Vitest covers the boundary.

Challenges we ran into

  • Lab reports are hostile to regexes: 4000-10000 looks like a phone number, 3.5-10.5 looks like a date, 1,50,000 is Indian digit grouping and 4,8 is a European decimal. We built and tested rules that seal identity without corrupting values.
  • Keeping "device only" honest: the SDK can fall back to the cloud when the on-device model is missing, so Veil checks for the model itself and refuses to make a device-only call it can't keep local.
  • Some Chrome builds expose the Prompt API but never answer an availability check; Veil times the probe out instead of hanging.

Accomplishments that we're proud of

  • A privacy model users can see: the airlock and the ledger turn "trust us" into "check for yourself".
  • Hybrid inference used for what each side is best at: the device for private reading, the cloud for rich multilingual explanation, the device again for quick follow-ups.
  • A product that looks and sounds finished.

What we learned

On-device models are good enough to do the sensitive half of a task, which changes what "private AI" can mean in a browser. Structured output is what makes the hand-off between the two models safe to inspect.

What's next for Veil

Trends across saved reports, PDF input, more Indian languages, and a clinic mode that lets a doctor receive the anonymous packet by QR code.

What is live and what is not

  • Live: every Firebase AI Logic call, with the inference source the SDK reports shown in the ledger; the rule-based sealing and packet rebuild (unit tested).
  • Gemini Nano runs where Chrome ships the Prompt API (Chrome desktop 139+). Elsewhere Veil says so up front; Device only mode then sends nothing.
  • The sample reports and photo are invented.

Built with

firebase-ai-logic, gemini-nano, gemini, chrome-prompt-api, firebase-app-check, firebase-remote-config, firebase-auth, cloud-firestore, firebase-hosting, react, typescript, vite, tailwindcss, motion, web-audio-api

Built With

Share this project:

Updates

Submission history