Inspiration
Healthcare clinics, legal teams, and field auditors handle sensitive documents daily—patient intake notes, master service agreements, and compliance checklists—yet standard cloud-only AI workflows introduce three major friction points:
- Privacy & Compliance Risk: Streaming raw Personally Identifiable Information (PII) such as patient names, medical record numbers, phone numbers, and addresses straight to external cloud endpoints creates unnecessary data exposure.
- Connectivity Bottlenecks: Field audits and remote clinics frequently operate in low-connectivity or offline environments where cloud-only AI tools stall completely.
- Unnecessary Inference Costs: Running every initial extraction and classification pass in the cloud burns API quota on tasks that lightweight local models can handle at zero marginal cost.
We built VaultLens AI for the #BuildHybridAI 2026 Hackathon to prove that a single client-side web application can deliver local-first PII redaction and offline resilience while seamlessly escalating sanitized payloads to cloud Gemini models for deeper compliance reasoning.
What it does
VaultLens AI is a privacy-first, offline-capable document and field intelligence workspace built with Firebase AI Logic and Gemini Nano 4 in Chrome:
- Tier 1 — Local Extraction & PII Shield (
ONLY_ON_DEVICE/PREFER_ON_DEVICE): Runs directly inside Chrome using Gemini Nano 4 via the Chrome Prompt API. It classifies documents (e.g., medical intake notes, contracts, field audits), extracts structured key-value fields and action items, and scrubs PII (Sarah Jenkins, phone numbers, MRNs, emails, addresses) into[REDACTED_...]tokens with zero network traffic and$0.0000cloud cost. - Offline Local Vault (IndexedDB): Persists all locally analyzed documents in browser IndexedDB so users can review, reload, and audit records even when completely offline.
- Tier 2 — Sanitized Cloud Escalation (
ONLY_IN_CLOUD/PREFER_IN_CLOUD): Once PII is stripped locally, users can escalate only the anonymized[REDACTED_...]payload to cloud Gemini models (gemini-3.5-flash-lite/gemini-3.8-flash) for deep regulatory, clinical, or contractual analysis. - Hybrid Routing X-Ray HUD: Inspects
result.response.inferenceSource(ON_DEVICEvs.IN_CLOUD), routing strategy, end-to-end latency, PII protection status, and estimated cloud cost in real time.
How we built it
- Frontend & Offline Storage: Built with React 19, TypeScript, Vite, and Tailwind CSS, paired with IndexedDB for zero-network record persistence.
- Unified Hybrid AI SDK (
firebase/ai): Used Firebase AI Logic to orchestrate both on-device and cloud inference from a single client-side SDK with no custom backend servers:- Configured
InferenceMode.ONLY_ON_DEVICE(when Strict Local Shield is locked) andInferenceMode.PREFER_ON_DEVICEfor Tier 1 local extraction. - Configured
InferenceMode.ONLY_IN_CLOUD(with offline fallback toPREFER_IN_CLOUD) for Tier 2 cloud compliance verification. - Implemented a multi-model cloud failover chain (
gemini-3.5-flash-lite$\rightarrow$gemini-3.8-flash$\rightarrow$gemini-4-hydrogen) with automatic retry handling if optional Google Search Grounding hits free-tier quota limits.
- Configured
- Security & Hosting: Secured every cloud AI call using Firebase App Check backed by Fraud Defense (reCAPTCHA Enterprise) and deployed the production web app on Firebase Hosting.
Challenges we ran into
- On-Device JSON & Unicode Tokenization Quirks: During local testing on Windows/Chrome, Gemini Nano 4 occasionally wrapped JSON responses in Markdown headings (
## ...) or emitted corrupted UTF-16 escape sequences (such as\渀instead of\n) inside multi-line redacted strings. We solved this by building a resilient sanitizer and JSON extractor (parseModelJson) that normalizes non-ASCII escape sequences and extracts valid JSON objects cleanly. - SDK Casing Normalization: The Firebase AI Logic Web SDK returns
result.response.inferenceSourcein lowercase ("on_device"/"in_cloud"). Normalizing those values ensured our Hybrid Routing X-Ray telemetry badge, model labels, and$0.0000cost counters aligned accurately across offline and online runs. - Transient Cloud Capacity & Grounding Quotas: During peak hackathon traffic, free-tier Google Search Grounding and individual cloud endpoints can return
429or500responses. Adding an automatic fallback chain across cloud Gemini models kept Tier 2 escalation reliable without exposing raw errors in the UI.
Accomplishments that we're proud of
- Zero-Backend Hybrid Architecture: Delivered end-to-end local PII redaction, offline persistence, App Check security, and cloud escalation using purely client-side Firebase SDKs.
- Verifiable Offline Execution: Demonstrated 0 bytes transmitted in Chrome DevTools during Stage 1 analysis while maintaining full structured extraction and IndexedDB storage.
- Real-Time Observability: Built the Hybrid Routing X-Ray panel so users and reviewers can visually verify every
ON_DEVICEandIN_CLOUDrouting decision as it happens.
What we learned
- Hybrid AI shines when local and cloud models have clear, complementary responsibilities: small on-device models excel at fast classification, entity extraction, and PII redaction close to the user, while cloud models excel at deep regulatory and cross-domain reasoning once sensitive identifiers are removed.
- Designing defensive parsers, model warm-up controls, and multi-model cloud fallbacks is essential for shipping reliable hybrid web applications in production.
What's next for VaultLens AI
- Custom Redaction Policies: Allow organizations to define custom regex + semantic redaction rules (e.g., HIPAA Safe Harbor vs. GDPR presets) before cloud escalation.
- Batch Document & Camera Capture Pipelines: Expand multimodal photo capture to multi-page PDF and batch receipt scanning in the Offline Local Vault.
- Cryptographic Audit Logs: Export verifiable telemetry receipts proving that raw PII never left the client device during compliance audits.
Built With
- chrome-ai
- firebase
- firebase-ai-logic
- firebase-hosting
- gemini
- gemini-nano
- indexeddb
- react
- recaptcha
- tailwindcss
- typescript
- vite