Inspiration
I live in Central Florida, where a summer thunderstorm or a hurricane can leave cracks, sinkholes, and flooding on roads that also lose cell service. Crews depend on residents to report what they see, but the worst spots often have no signal, and the reports are full of names and phone numbers. On-device models are fast, work offline, and keep private notes local. Bigger jobs, like grouping dozens of reports or writing a work order, need a cloud model. Firebase AI Logic hybrid inference is built for that split.
What it does
RoadGuard Hybrid is two apps that share one Firestore backend.
Android field app. In the demo, my Pixel 10 is in airplane mode with no signal. I switch on Storm Mode and type an optional note that includes personal info ("Big crack in the right lane, call John at 555-0123"). Then I capture a photo of the street. Gemini Nano triages it on the phone and returns a hazard type, a severity from 1 to 5, a confidence score, a summary, and whether a car can get through. Severity 4 or 5 means impassable, and 1 to 3 means passable. My report came back as severity 3, passable. Firestore stores the report offline with its GPS location and syncs it once signal returns.
Chrome county ops dashboard (live at https://roadguard-hybrid.web.app). The report I took offline appears on the map as soon as the phone reconnects. Clicking "Scrub PII (On-Device)" runs Gemini Nano in Chrome, which removes the name and phone number from the resident's note before any cloud model sees it. Raw notes never go to the cloud. Cluster & Rank then sends cloud Gemini only the scrubbed summaries. It groups nearby reports, ranks the repairs, and writes a work order, like the Sinkhole order in the video. Clicking Mark Repaired sends that status back to the reporter's phone.
How I built it
Every model call goes through Firebase AI Logic (firebase-ai and firebase-ai-ondevice on Android, firebase/ai on the web). Each feature has its own inference mode:
• Photo triage: PREFER_ON_DEVICE, which works in dead zones and falls back to the cloud on phones without Nano
• Storm Mode passability: ONLY_ON_DEVICE, so it never waits on a cell tower
• Repair escalation and Spanish translation: ONLY_IN_CLOUD, queued until the phone is back online
• Chrome personal-info scrub: ONLY_ON_DEVICE, with a local regex fallback and never the cloud for raw notes
• Cluster and rank, plus work orders: ONLY_IN_CLOUD, after nearby reports are pre-grouped locally
Also used: Firestore with an offline cache, App Check, Remote Config (escalation threshold, minimum severity, and a cloud kill switch), anonymous auth, and Firebase Hosting.
Challenges I ran into
Picking an inference mode per feature took more care than one chat call. Offline status was the trickiest bug. Reports reached Firestore, but the phone stayed stuck on "Syncing…" because the app waited on a check of the whole offline cache. I fixed it by marking each report synced once the server confirmed the write. I also found that Storm Mode defaulted to "not passable" whenever the model was unsure, so I tied passability to severity instead.
Accomplishments that I'm proud of
• My first ever mobile app and dual build - the mobile app, a real airplane-mode demo on a Pixel 10, with on-device triage and no network capability!
• A full loop shown live: offline capture, sync, on-device privacy scrub, cloud work order, and a repaired status sent back to the phone
• Two platforms on one SDK and one Firestore schema, with routing tunable from Remote Config... The fact that I took a kernel of an idea and was able to (for the first time)
What I learned
Hybrid inference works best when each job gets its own mode. Privacy and outages call for on-device only. Long, multi-report work belongs in the cloud, but only after the data has been reduced and redacted. --- FireBase is cool and a relatively easy (user-friendly) platform backed with Google credibility that enabled me to build my first mobile app and overall dual build!
What's next for Roadguard Hybrid
Primary: tighten the passable check (make it more than demo ready, make it production grade). Build with real data, remove seed data. That's number one priority.
Second of Primary - Move everything from central to SOUTH FL - Miami. Connect to city / US Census data.
Secondary: Turn on reCAPTCHA Enterprise for App Check on the hosted dashboard, label redacted names as [NAME] instead of [PHONE], share a test build through Firebase App Distribution, and add a proper app icon.
Built With
- android
- cloud-firestore
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-remote-config
- gemini-nano
- jetpack-compose
- kotlin
- leaflet.js
- react
- tailwind-css
- typescript
- vite

