Inspiration
Across Indian cities, millions of students and young professionals live in PGs (paying-guest hostels). The places where maintenance emergencies happen (basements, concrete interior bedrooms, water-heater corners, stairwells) are often dead zones with one bar of signal, so cloud-only apps fail exactly where the problem is. Students sharing 2- or 3-bed rooms are also hesitant to share candid notes about study schedules or noise sensitivity if the raw text sits on a server.
We wanted on-device AI for the instant, private, signal-free half of PG living, and cloud AI for heavy multi-ticket reasoning on the owner side.
What it does
- Snap & Triage (
PREFER_ON_DEVICE): In the Resident Portal, a resident snaps a photo of a leak, broken fan or sparking socket (or types a short note). The photo is downscaled in the browser to a <=1024px JPEG and Firebase AI Logic (firebase/ai) returns structured output: category, priority (LOW | NORMAL | HIGH | URGENT), title, description and a safety tip. IfsafetyRisk: true(exposed wires, gas smell, flooding), the app shows a safety alert and forcesURGENT. Every result shows "Analysed on your device 🔒" or "Analysed in the cloud ☁️" plus latency in ms. - Offline outbox with Cloud Firestore: With no signal, the triaged ticket and compressed photo are stored via Firestore
persistentLocalCache()underoutbox/{uid}/tickets/{id}("Queued, will send when you're back online"). When connectivity returns, tickets are sent automatically and the user sees "N offline report(s) sent". - Private on-device VibeCheck (
ONLY_ON_DEVICE): Prospective roommates describe their routine in plain English. Gemini Nano converts it in Chrome into 8 numeric lifestyle habit indices, so the raw text never leaves the device. If the Prompt API isn't available, the user is told clearly and the app falls back to the cloud endpoint. - Owner cross-ticket digest (
ONLY_IN_CLOUD): In the Owner console, "Summarise today's open tickets" produces a 3-bullet operational summary and flags repeated issues across rooms (e.g. several rooms on one floor losing water pressure). - Remote Config + App Check +
?debug=ai: Remote Config controlstriage_inference_mode,triage_prompt_version,vibe_on_device_enabledandcloud_model_name. App Check protects Cloud Gemini calls (debug tokens supported for judges). Append?debug=aito any URL for a drawer that shows Gemini Nano status, triggersinitializeDeviceModel(), switchesInferenceModeand shows the live inference source and latency.
How we built it
- Firebase AI Logic Web SDK (
getAI,GoogleAIBackend,getGenerativeModel,InferenceMode,InferenceSource,Schema,initializeDeviceModel) with structured JSON schemas, inProject/frontend/src/ai/. - Cloud Firestore (offline persistence + security rules), Firebase Anonymous Auth, App Check (reCAPTCHA v3 / debug token), Remote Config.
- React + TypeScript + Vite frontend; Express + PostgreSQL backend deployable to Cloud Run. Vitest unit tests for the AI, outbox and VibeCheck modules.
Built during the submission period (existing-app disclosure)
LivingPlus started as an existing PG marketplace, booking, rent-ledger and operations web app. During #BuildHybridAI (Nov 11 – Nov 30, 2026) we built:
- The whole
Project/frontend/src/ai/module: Firebase AI Logic client, App Check, Remote Config bootstrap, Chrome Prompt API availability hook, client-side image downscaler and the?debug=aipanel. - Snap & Triage and the Firestore offline outbox (
ResidentMaintenanceView.tsx,outbox.ts,firestore.rules, Anonymous Auth) plus backend support for resident ticketpriorityandimageUrl. - The on-device VibeCheck privacy path (
VibeProfileBuilder.tsx) and the owner cloud digest (OperationsViews.tsx). - Apache-2.0 license,
.env.examplefiles, unit tests and docs.
The existing app provides the core value the new hybrid features build on: real PG listings, resident and owner accounts, and the maintenance ticket system that on-device triage now fills in automatically.
Challenges we ran into
- Chrome only downloads the on-device model after a user gesture, so we added an explicit "Enable offline AI" button and
initializeDeviceModel()warm-up. - Keeping triage useful without signal meant designing a Firestore outbox that survives reloads and flushes cleanly on reconnect.
- Making the hybrid behaviour visible and testable for judges, which led to the on-device/cloud badges and the
?debug=aidrawer.
What we learned
Hybrid inference works best when each feature has a deliberate mode: prefer on-device for instant, private, offline work; only on-device where privacy is the point; only cloud where reasoning spans many records.
Judge testing guide
- Clone the repo, copy
Project/backend/.env.exampleandProject/frontend/.env.example, start backend + frontend (npm run seedloads demo PG data in Chennai). - Enable Gemini Nano in Chrome 139+ (
chrome://flags/#optimization-guide-on-device-modeland#prompt-api-for-gemini-nano), as described in the README. - Open e.g.
http://localhost:5173/stay/green-park-pg/maintenance?debug=ai. - Offline check: DevTools → Network → Offline, Report an issue → Triage → Queue offline report, then go back online and watch the outbox sync.
What's next
Multi-property support for PG chains, vendor integration, and an Android build with Gemini Nano.
Built With
- chrome-built-in-ai
- cloud-firestore
- express.js
- firebase
- firebase-ai-logic
- firebase-app-check
- firebase-authentication
- firebase-remote-config
- gemini
- gemini-nano
- node.js
- postgresql
- react
- typescript
- vite