Inspiration
School communications coordinators, youth shelter staff, live streamers, and people relocating for personal safety regularly post everyday photos without realizing a street blade, bus stop, or rooftop school name in the background gives away their exact location.
Building a pre-publish privacy checker hits a fundamental catch-22:
- You cannot upload an unpublished private photo to a cloud server just to test whether it is safe to publish.
- An on-device model cannot search real-world maps or public knowledge bases to test whether a combination of clues uniquely pinpoints a real neighborhood or intersection.
Backdrop solves this catch-22 using Firebase AI Logic Hybrid Inference across a strict zero-pixel airgap: the unpublished photo never leaves the browser, while a cloud "red-team investigator" tries to narrow down the photo using only the user-approved text clues. The user wins when the cloud attacker fails.
What it does
- Stays on This Device (
ONLY_ON_DEVICEvia Chrome Gemini Nano): Reads background signs, street blades, school names, and transit route codes directly from browser memory (~25scold model load,~1sonce warm,0 image bytessent to cloud). Includes a local Zoom-Inspect tool that crops and OCRs tiny background details locally. - Human-in-the-Loop Airgap Gate: Before anything crosses to the cloud, users can edit OCR text, uncheck sensitive items, and inspect the exact selected clue JSON (e.g.,
416 Btext,0 pixels) alongside full disclosure that live OSINT lookups hit OpenStreetMap Nominatim and Wikipedia directly from the browser. - Cloud Red-Team Investigator (
ONLY_IN_CLOUDviagemini-3.5-flash-lite+ Function Calling): Protected by enforced Firebase App Check (reCAPTCHA Enterprise), receives zero pixels and only the approved text strings. Uses Firebase AI Logic Function Calling to query live OpenStreetMap Nominatim (throttled to <=1 req/s) and Wikipedia. To keep the tool strictly defensive, Nominatim results are sanitized to broad areas only (house numbers, GPS coordinates, and direct map node links are stripped). If lookups fail or return HTTP 429, Backdrop fails closed toInconclusiverather than falsely claiming safety. - Hybrid Verdict Structurer (
PREFER_ON_DEVICE): Structures the cloud investigator's free-text deduction chain into a calibrated precision scale (Unlocatable from Extracted Clues,Country,City,Neighborhood / Facility,Street / Intersection,Exact Building / Facility, orInconclusive). - Honest Red-to-Green Redaction Unit Test (
ONLY_ON_DEVICE): Users drag a Blur Mask or Solid Bar directly over leaking signs on the local HTML canvas and click Re-Verify Redacted Photo. Chrome Gemini Nano blindly re-scans the masked canvas locally (~1swarm). If zero legible clues remain, Backdrop honestly skips the cloud call (0 bytes sent, labeledCloud skipped · 0 legible clues on-device) and drops exposure to green. If any text survives, Backdrop pauses locally for user consent (preserving unchecked items) before re-testing in the cloud. Any subsequentUndoorClearimmediately invalidates the green banner so users never export an unverified copy. Exported JPEGs are re-encoded from canvas to strip EXIF/GPS metadata. - Offline-Resilient Clue Risk Guide (
PREFER_IN_CLOUD): Clicking any clue category sends only a generic category enum (e.g.,school_or_org) to explain how strangers combine that clue type, and seamlessly falls back on-device to Chrome Nano when the browser goes offline. - Live Hybrid Telemetry, Firestore Insights & Remote Config: Every inference call is audited in real time showing requested
InferenceMode, verifiedinferenceSource, latency, and exact cloud prompt bytes (0px). Anonymous Auth + strictfirestore.rulespersist metadata-only audits (imagePixelsStored == 0) and monotonically incrementedclueStatsaggregates. Remote Config controls the investigator model, safety note, and a client-side daily cloud soft cap (supporting0as a kill-switch).
How we built it
- Frontend: React 19, TypeScript, Vite, Tailwind CSS v4, HTML5 Canvas pixelation/masking + EXIF-stripping export.
- Firebase AI Logic (
firebase/aiv13.4.0): All four hybridInferenceModevalues (ONLY_ON_DEVICE,ONLY_IN_CLOUD,PREFER_ON_DEVICE,PREFER_IN_CLOUD), multimodal JPEGinlineDatafor Chrome Gemini Nano, and multi-turn Function Calling (search_osm_places,search_wikipedia) with strict 1:1functionCall/functionResponsepairing forgemini-3.5-flash-lite. - Firebase Platform: Hosting, enforced App Check (reCAPTCHA Enterprise), Anonymous Auth, Cloud Firestore with strict schema & monotonic rules, and Remote Config.
Challenges we ran into
- Preventing silent cloud fallback on Web: Reading
@firebase/ai's runtime implementation revealed that whenglobalThis.LanguageModelis unavailable,InferenceMode.ONLY_ON_DEVICEcan silently fall back to cloud inference. We built a 3-layer defense-in-depth guard: pre-callLanguageModel.availability()check, dedicatedONLY_ON_DEVICEmodel instance, and strict post-callresponse.inferenceSource === "on_device"assertion, plus blocking personal photo uploads on unsupported browsers (allowing only clearly labeled simulated demo mode). - Preventing VLM priming hallucination during re-verification: Feeding previously detected sign names into Chrome Nano's re-verification prompt caused the compact on-device vision model to hallucinate masked text from prompt context. Switching to a strictly blind adversarial re-scan eliminated false positives while computing the cleared/remaining clue diff deterministically in TypeScript.
- Spark free-tier grounding quota & defensive OSINT: Built-in
googleSearchgrounding returned HTTP 429 on the Spark free tier, so we implemented live Firebase AI Logic Function Calling against OpenStreetMap Nominatim and Wikipedia with broad-area sanitization, rate throttling, and fail-closed error handling.
Accomplishments that we're proud of
- Genuine architectural necessity for hybrid AI where neither cloud-only nor on-device-only can solve the problem safely.
- Strict verification honesty: zero fake
on_devicebadges, zero auto-transmitted re-verify clues, fail-closed parsing/OSINT errors, and immediate green-banner invalidation on mask undo. - Full end-to-end verification on live Firebase Hosting with real Chrome Gemini Nano (~1.1s warm), real reCAPTCHA Enterprise App Check, offline
PREFER_IN_CLOUDfallback, and locked-down Firestore security rules.
What we learned
- Web on-device multimodal AI (
LanguageModel) ignoressystemInstruction(instructions belong in the prompt body), takes ~25s on first cold weight load and ~1s once warm, and works best with blind concise prompts. - Defensive geolocation tools must be careful with both sides of honesty: never over-expose exact street numbers/map pins, and never over-promise "100% safe" when visual landmarks or architecture still exist outside text OCR.
What's next for Backdrop
- Optional on-device visual landmark/skyline risk classifier alongside text OCR.
- Batch folder auditing for school and nonprofit comms teams.
- Server-side Cloud Functions quota enforcement if moving beyond the Spark free tier.
Built With
- cloud-firestore
- firebase
- firebase-ai-logic
- firebase-app-check
- gemini
- gemini-nano
- openstreetmap
- react
- tailwindcss
- typescript
- vite