INSPIRATION

Indonesia has tens of millions of warung and micro-shops. Their "software" is paper notes and WhatsApp chats: supplier price lists arrive as messy chat messages, and comparing two suppliers means squinting at two chats side by side. Cloud AI could help, but a shop's purchase prices are its most sensitive business data — and many owners are on cheap phones, prepaid data, and flaky connections. That tension is exactly what hybrid inference is for.

WHAT IT DOES

Paste any messy text — a supplier price list, a WhatsApp chat, stock notes — and WarungWise: (1) Extracts & summarizes it into a structured item/price table with an estimated shopping total. This runs on-device first (Gemini Nano via Firebase AI Logic PREFER_ON_DEVICE) with automatic cloud fallback. (2) Drafts with the cloud (ONLY_IN_CLOUD): a price comparison across suppliers, a polite WhatsApp negotiation message, and a promo caption. (3) Shows a Hybrid Router panel: every request is logged with the mode requested, the path that actually served it (response.inferenceSource), and its latency. A mode toggle (Auto / On-device / Cloud) lets you watch routing and fallback happen live.

HOW I BUILT IT / FIREBASE AI LOGIC

On-device (Gemini Nano, Chrome Prompt API): extraction & summary — frequent, latency-sensitive, private, and must work offline and for free. The app detects Prompt API availability and warms up / downloads the model from a user gesture with progress (initializeDeviceModel). Cloud (Gemini via Gemini Developer API): creative drafting — quality-sensitive, infrequent, worth the round trip. App Check (reCAPTCHA Enterprise / Fraud Defense) protects the API quota; a debug provider keeps localhost development frictionless. No custom backend: the browser talks to Firebase AI Logic directly.

CHALLENGES

Firebase has deprecated reCAPTCHA Classic for new App Check registrations — I migrated the setup to reCAPTCHA Enterprise (Fraud Defense) mid-build. The SDK's InferenceSource enum keys are ON_DEVICE / IN_CLOUD, but its runtime values are the lowercase strings on_device / in_cloud — my router badge silently showed "unknown" for every request until I read the SDK source and normalized the values. When Nano isn't downloaded yet, the router additionally infers the cloud fallback from the device status instead of pretending.

WHAT'S NEXT

Saved price history in Firestore, photo-of-a-price-list extraction (multimodal on-device), and a PWA so warung owners can install it.

Built With

Share this project:

Updates

Submission history