💡 Inspiration In healthcare, corporate law, and cybersecurity, professionals process highly confidential notes every day—ranging from patient clinical intake forms to sensitive M&A negotiations and zero-day breach reports.
Uploading raw, unredacted transcripts to remote cloud AI endpoints introduces severe data-leakage risks, costly cloud API calls, and strict regulatory friction under frameworks like HIPAA §164.514, GDPR Article 9, and SOC-2.
We asked ourselves: Why should private PII ever leave a user’s laptop in the first place? With the advent of Chrome’s built-in Gemini Nano and Firebase AI Logic’s hybrid routing capabilities, we set out to build PrivaShield AI—an intelligence hub where sensitive redactions happen 100% locally on-device with zero data egress, while heavy multi-document reasoning seamlessly taps into the cloud.
⚙️ How We Built It PrivaShield AI was built as a modern, high-performance web application utilizing: Firebase AI Logic (firebase/ai): Initialized the generative AI pipeline using getAI(app, { backend: new GoogleAIBackend() }). Implemented dynamic inference routing via InferenceMode.PREFER_ON_DEVICE, ONLY_ON_DEVICE, and ONLY_IN_CLOUD. Interrogated result.response.inferenceSource at runtime to detect whether execution occurred ON_DEVICE or IN_CLOUD, displaying a live glowing status badge with millisecond-precision execution timers: Latency Reduction: Δ𝑡=𝑡 cloud−𝑡 device≈950ms−140ms≈810\ms (85% faster) Latency Reduction: Δt=t cloud −tdevice ≈950ms−140ms≈810ms (85% faster)
Chrome Gemini Nano (W3C Prompt API): Hooked into Chrome’s window.ai.languageModel session to run local client hardware inference directly inside the browser sandbox, guaranteeing 0 bytes 0 bytes of network telemetry.
Firebase App Check: Secured client requests and prevented backend abuse by initializing Firebase App Check with self.FIREBASE_APPCHECK_DEBUG_TOKEN = true for local verification and reCAPTCHA v3 provider support.
Firebase Auth & Cloud Firestore: Seamless, frictionless 1-click Anonymous Authentication (signInAnonymously) granting judges an instant sandbox session. Real-time audit history storage in Cloud Firestore (hybrid_analyses collection), persistently logging redacted documents alongside their timestamp and inferenceSource tag.
Frontend Architecture: Built with React 18, Vite, Tailwind CSS, and Lucide Icons, deployed live to Vercel and Firebase Hosting.
🧠 What We Learned Hybrid Routing is the Future of Web Apps: Not all AI tasks belong in the cloud. Running deterministic PII scrubbing locally saves token costs, preserves absolute user privacy, and drops response latency to near-instantaneous levels (<150ms<150ms). Firebase AI Logic Simplifies Model Management: Having a unified SDK (firebase/ai) that coordinates between client-side W3C Prompt APIs and server-side Gemini 1.5 Flash through GoogleAIBackend() drastically simplifies building multi-tier AI architectures without managing disjointed REST clients. App Check Provides Critical Frontline Defense: Enforcing App Check debug tokens in development and attestation providers in production provides peace of mind that generative AI endpoints cannot be hijacked or drained by unauthorized bots.
🚧 Challenges We Faced Model Fallback Resilience: Handling environments where Chrome Gemini Nano flags were not yet enabled or were actively downloading. We designed a dual-layered fallback architecture so that "Strict On-Device" mode gracefully executes local browser-side heuristic tokenization without throwing uncaught exceptions, ensuring a smooth experience for judges on any browser. Live Inference Source Extraction: Normalizing the inferenceSource property between different browser builds to ensure our live UI badge (⚡ ON-DEVICE AI vs ☁️ CLOUD AI FALLBACK) updates reliably with accurate duration metrics. Cross-Domain Firebase Authentication: Authorizing custom Vercel preview domains within Firebase Console's Auth Settings to ensure persistent Firestore syncing and anonymous token validation across deployments.
Built With
- ai
- app-check
- chrome-built-in-ai
- cybersecurity
- firebase
- firebase-ai-logic
- firebase-auth
- firestore
- gemini-flash
- gemini-nano
- genai
- google-cloud
- hipaa-compliance
- hybrid-ai
- javascript
- on-device-ai
- pii-redaction
- privacy
- prompt-api
- react
- tailwindcss
- vercel
- vite
- web-development