-
-
Route A(On-Device Execution):Instant local analysis of short sensitive notes using Chrome’s built-in Gemini Nano with zero cloud departure.
-
On-Device NER Scanning: Chrome’s Gemini Nano identifies unstructured names, organizations, and addresses locally before any network dispatch
-
Interactive Redaction Review: Users maintain complete sovereignty to inspect, adjust, and approve redacted tokens before cloud transmission.
-
End-to-End Hybrid Telemetry: Live audit trail tracking execution stages across local regex, on-device Nano and local restoration.
-
SidebySide Proof: Visually verifies that Google Cloud only received synthetic tokens [PERSON_1], while local results are privately restored.
-
Route B (Direct Cloud Analysis): Public, non-sensitive texts stream directly to Gemini 2.5 Flash via Firebase AI Logic
-
Air-Gapped Offline Resilience: Route A executes 100% on-device even with Wi-Fi switched off, keeping private workflows operational anywhere.
-
When offline, long public articles automatically fall back to local on-device execution with a clear quality advisory.
-
Sensitive contracts adapt to local on-device processing when disconnected, ensuring zero data leakage under all network conditions.
Inspiration
We built Veil out of a personal frustration that almost every developer and professional experiences today.
Whenever you have a complex contract, loan note, or medical record, you want the reasoning power of Gemini to find the hidden risks, deadlines, and clauses. But you can't — and shouldn't — paste real client names, bank account numbers, or salaries into an external cloud chatbot.
Small on-device models like Gemini Nano are completely private, but they run out of context quickly on multi-page agreements. Cloud models have the reasoning power, but require raw data departure.
We asked ourselves: Why can't our browser do the privacy work, and the cloud do the heavy thinking? That question led directly to Veil.
What it does
Veil is a privacy-first hybrid document intelligence app. Instead of choosing between weak on-device models or risky cloud models, Veil intelligently combines them into three simple routes:
- Route A (Pure On-Device): Short notes (under 1,500 characters) run entirely inside Chrome using Gemini Nano via the Prompt API. Zero bytes ever leave the device, and it works completely offline with Wi-Fi switched off.
- Route B (Direct Cloud): Public, non-sensitive texts (like research papers) bypass redaction and stream directly to Gemini 2.5 Flash via Firebase AI Logic for maximum cloud speed.
- Route C (The Hybrid Breakthrough): For long, confidential contracts, Veil scans the text on-device using a mix of deterministic regex and Gemini Nano. It catches names, emails, phone numbers, bank accounts, PAN/Aadhaar IDs, and amounts, replacing them with tokens like
[[PERSON_1]]and[[AMOUNT_1]].
Before anything is sent, an interactive Redaction Review Modal pops up so the user stays in complete control. Once approved, only the sanitized text is sent to Google Cloud via Firebase AI Logic. When the analysis returns, Veil swaps the real values back into place inside client memory.
To prove it, a Side-by-Side Inspector shows exactly what the cloud saw (placeholders only) next to what you see (restored text), complete with a one-click copy button.
How we built it
- Frontend: Pure vanilla JavaScript bundled with Vite — zero framework bloat, fast load times, and clean UI.
- On-Device AI (Edge): Chrome’s built-in Prompt API (
window.ai.languageModel) running Gemini Nano directly on device hardware for local Named Entity Recognition (NER) and Route A local summaries. - Cloud AI: Firebase AI Logic (
@firebase/ai) connecting directly to Google Vertex AI viacloudModel.generateContentwith Gemini 2.5 Flash. - Security & Integrity: Firebase App Check with reCAPTCHA Enterprise to attest and protect our cloud endpoint against abuse.
- Dynamic Configuration: Firebase Remote Config to adjust parameters like character limits on the fly without redeploying code.
- Testing: 111 automated tests across 18 test files using Vitest, including leak-prevention suites that verify zero personal data appears in outbound network payloads.
Challenges we ran into
- Making on-device NER fast: Early on, our 1,900-character sample agreement was getting split into multiple small chunks, causing entity detection to take nearly 18 seconds. By tuning the chunking boundary to 3,500 characters and removing duplicate passes, we cut that time down to ~8 seconds.
- Preventing placeholder hallucinations: Occasionally, the cloud model would rewrite
[[PERSON_1]]into[Person 1]or drop a number. We designed strict system prompt rules and a retry validator that catches altered placeholders before local restoration. - App Check in production: Getting App Check working on localhost with debug tokens was straightforward, but transitioning to production on Firebase Hosting (
veil-e5e74.web.app) brought HTTP 403 errors until we properly configured domain allowlisting in reCAPTCHA Enterprise and cleaned up build-time environment variables. - Graceful degradation: Not every browser has Gemini Nano enabled. We made sure Veil doesn't crash on standard browsers; it displays an honest notice, protects structured data with local regex, and lets users manually redact names before sending.
Accomplishments that we're proud of
- Mathematically proven zero-leakage: We ran automated stress tests across 100 diverse contracts, financial statements, and medical notes (protecting 1,206 sensitive entities) with 0 data leaks across the wire.
- Real air-gapped offline support: Disconnect your internet completely, and Route A continues running on Gemini Nano without missing a beat.
- A live, verified production deployment: Hosted live on Firebase Hosting with genuine reCAPTCHA Enterprise App Check tokens passing with clean
200 OKresponses. - Building an intuitive UX for privacy: Making privacy tangible through the interactive review modal and side-by-side payload comparator so users can actually verify the protection themselves.
What we learned
- Hybrid AI is the practical future: Edge models and cloud models aren't competitors; they are natural partners. Edge is best for deterministic filtering, privacy, and low latency; cloud is best for deep reasoning and multi-page comprehension.
- Client-side Firebase AI Logic simplicity: Calling Vertex AI directly through Firebase AI Logic with App Check protection eliminates the need to build and maintain a custom backend API proxy just to keep keys safe.
- Handling on-device model lifecycles: Gained hands-on experience handling Chrome's Prompt API states, model downloading transitions, and browser capability detection.
What's next for Veil
- Client-side document parsing: Adding on-device PDF and image OCR (via WebAssembly) so users can drop in scanned paper agreements directly.
- Compliance presets: Adding one-click toggles for specific regulatory frameworks (e.g., HIPAA mode for healthcare, PCI-DSS for billing).
- Chrome Extension: Packaging the Veil hybrid engine into an extension so people can sanitize text fields across Gmail, Jira, and web apps before submission.
Built With
- chrome-built-in-ai
- chrome-prompt-api
- css3
- cybersecurity
- data-protection
- edge-computing
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- firebase-remote-config
- gemini
- gemini-nano
- google-cloud
- html5
- hybrid-ai
- javascript
- on-device-ai
- privacy
- recaptcha-enterprise
- regex
- vertex-ai
- vite
- vitest