Inspiration

People paste hospital bills, leases, insurance denials and immigration letters into chatbots because those documents are dense and the deadlines are real. Those same documents hold exactly what should never be uploaded: full name, date of birth, address, member and claim numbers, card and account numbers. The people who need help the most (patients, tenants, non-native speakers) are often the least able to judge that risk.

We wanted the clarity of a cloud model without handing it your identity, and we wanted the privacy claim to be something you can check, not a promise.

What it does

Veil turns a sensitive document into a plain-language explanation while your personal data stays on your device.

  1. Add a document: paste text, open a file, or take a photo (photos are read by Gemini Nano on-device only).
  2. Review under the veil. Pattern rules and Gemini Nano find names, addresses, phone, ID and card numbers. The document sits under a draggable veil: on one side your real text, on the other exactly what the cloud would receive, with every personal value turned into a placeholder like [PERSON_1]. Missed something? Select it to protect it.
  3. Understand. Gemini in the cloud explains the redacted text: summary, deadlines, red flags, key facts, next steps and questions to ask, in 11 languages, with follow-up questions. Your real details are filled back in locally and highlighted.
  4. Do the next thing. An action kit drafts a dispute letter or a phone script and exports deadlines to your calendar. The cloud writes with placeholders; your name, address and claim number are filled in on your device, so the cloud never sees them.

Proof, not promises. A Privacy Ledger shows where each AI step really ran (from the SDK's inferenceSource). An On the wire view records every request that actually left the browser, re-checks the bytes, shows the exact text sent and exports a privacy receipt. Under every answer, a one-line proof says how many requests went to Gemini and that none contained personal data.

How we built it

All inference goes through Firebase AI Logic hybrid inference (firebase/ai, getGenerativeModel with InferenceMode), protected by App Check (reCAPTCHA Enterprise). We use hybrid inference as a data-sensitivity router, not only as an availability fallback. Each task declares what kind of data it reads, and that decides the only modes it may use:

Task Input Mode
Read a photo, find personal data raw document ONLY_ON_DEVICE (built with no cloud config, so nothing to fall back to)
Identify the document type redacted text PREFER_ON_DEVICE
Explain, follow-up, draft a letter redacted text PREFER_IN_CLOUD, with Gemini Nano as the offline fallback

On top of that, a route planner weighs the document's language (Nano officially supports English, Spanish and Japanese), its size, connectivity, data saver, battery, Nano status and a Remote Config kill switch, and shows the plan and the reason for every step before anything runs.

Details we are proud of:

  • One JSON Schema drives structured output on both backends (responseConstraint on-device, responseJsonSchema in the cloud).
  • An egress guard re-checks every cloud-bound payload against the vault and the detectors, and blocks it if anything personal remains. A "Prove it" button tries to send the original and shows the block.
  • The invariant raw input ⇒ ONLY_ON_DEVICE is unit-tested and asserted at startup; a raw-data result that somehow ran off-device is discarded.
  • Cloud calls run as a chain with timeouts (main model, lighter model, then a compact on-device summary), and the ledger shows each try.
  • Remote Config sets the cloud models and can pause the cloud for everyone without a release.

Stack: TypeScript, React, Vite and Vitest; Firebase AI Logic, App Check, Remote Config and Hosting. The privacy-critical logic lives in a framework-free core/ module with 90+ unit tests and CI. Built during the submission period with Claude Code as the AI coding assistant.

Challenges we ran into

  • Making "never falls back to the cloud" testable, not just a sentence in a README.
  • Names in free text: rules alone miss them and models can hallucinate them. Entities must literally occur in the source, the vault merges variants like "Dr. Chen" and "Chen", and the user always gets a review step.
  • Gemini Nano limits: single-turn sessions and a small context, so documents are chunked and follow-ups are self-contained. Cold starts take seconds, so Veil warms the model up when the page loads.
  • Cloud latency varies, so every cloud step has a timeout and a fallback, and the UI says what is happening.

Accomplishments that we're proud of

  • The veil: a single view that makes redaction tangible. Drag it and watch your identity turn into placeholders.
  • A complete, honest flow rather than a demo: review and correction, offline behaviour, 11 languages, accessibility (axe: zero violations in light and dark themes) and a ledger that shows evidence instead of asking for trust.

What we learned

Hybrid inference is most interesting when the routing decision is about the data, not just about whether a model happens to be installed. Once every task states what it reads, privacy becomes a property of the architecture you can test.

What's next for Veil

PDF support with local text extraction, Android and iOS versions with the same routing policy, and redaction rules that organisations such as clinics and legal aid groups can share.

Try it

Open https://veil-hybrid-99fj.web.app in desktop Chrome 139+ and click Try it on a sample bill (every name and number in the samples is fictional). No login needed. Without Gemini Nano (other browsers, or add ?nano=off) Veil still works with pattern rules plus a confirmation step, and the explanation still uses only redacted text.

Built With

  • chrome-built-in-ai
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-hosting
  • firebase-remote-config
  • gemini
  • gemini-nano
  • github-actions
  • prompt-api
  • react
  • recaptcha-enterprise
  • typescript
  • vite
  • vitest
Share this project:

Updates

Submission history