Inspiration
Students in much of the world — including here in Indonesia — study on connections that are slow, metered, or simply gone for hours at a time. Cloud-only AI tutors fail exactly when they're needed most: the night before an exam, on a bus, in a village with one bar of signal. Meanwhile, the phone or laptop in the student's hand already carries a capable model — Gemini Nano — that costs nothing to run and never sends a byte anywhere.
NanoWise was built around a simple question: why should every question pay the cloud toll? A definition doesn't need a data center. A 40-page chapter summary does. NanoWise routes each question to the cheapest brain that can answer it well — and proves the routing with a receipt on every answer.
What it does
NanoWise is an offline-first study companion (Web/Chrome):
- Ask anything — type a study question, optionally paste the material it should be answered from.
- Summarize mode — paste a long text and get a summary; routing is automatic based on length and complexity.
- Hybrid routing, pinned honestly — light tasks (definitions, short Q&A, phrase translation, short summaries) go on-device to Gemini Nano via Firebase AI Logic with inferenceMode "only_on_device"; heavy tasks (long documents, comparisons, multi-step reasoning) go to cloud Gemini (gemini-3.5-flash) with "only_in_cloud". Routes are pinned, never "prefer", so the origin badge can never lie.
- Origin badge on every answer — "On-device · $0 · private" / "Cloud · Gemini" / "Local fallback", plus the routing reason and latency.
- "Why this brain?" panel — explains each routing decision and shows session stats: % answered on-device and estimated cloud cost avoided.
- Honest local fallback — if on-device is unavailable and the cloud is unreachable, a built-in extractive engine answers from the student's own material and badges itself as a fallback. It never invents facts.
- Session history in Firestore — every Q&A receipt (question, origin badge, timestamp) is persisted.
- Routing tuned without redeploying — thresholds (max on-device chars, model names, cost rate) live in Remote Config.
How we built it
A zero-build static web app (HTML/CSS/vanilla JS ES modules) on Firebase Hosting:
- ai-router.js classifies each task (complexity markers, total character count vs. the Remote Config threshold, user mode override: Auto / On-device / Cloud) and orchestrates the route + fallback chain.
- firebase-ai.js wires all Firebase services: getAI with GoogleAIBackend, per-route getGenerativeModel with explicit inferenceMode, App Check, Firestore history writes, and Remote Config fetches with in-code defaults.
- local-engine.js is the offline extractive fallback (summaries, material Q&A, glossary, phrasebook).
- Cloud model is gemini-3.5-flash — verified live end-to-end (the 2.x Flash models were retired mid-hackathon; 3.8 stalled in testing). On-device calls target Gemini Nano in Chrome; where Nano isn't present, the SDK's hybrid path and our fallback chain keep the app answering.
- App Check is enforced with reCAPTCHA Enterprise; the demo build uses a registered App Check debug token, as the hackathon rules explicitly allow.
Challenges we ran into
- Model churn mid-hackathon: the cloud model we started with was retired by Google during the build window. We diagnosed it from live API errors, tested replacements, and landed on gemini-3.5-flash.
- App Check vs. automated testing: reCAPTCHA tokens can't be minted by test browsers, so we registered a debug token for the demo build (allowed by the rules) and verified server-side that its JWT exchanges and passes App Check on Vertex AI calls.
- Honest badges are a design constraint, not a label: using "prefer_on_device" would let the SDK silently answer from the cloud while we claimed "on-device". We pinned "only_on_device" / "only_in_cloud" and built the fallback chain around the failures that honesty creates.
- Cloud latency (~50s on the free path) shaped the UX: routing feedback and the why-panel had to make waiting feel explained, not broken.
Accomplishments that we're proud of
- A live, verified hybrid app: cloud Gemini answering through Firebase AI Logic with App Check enforced, confirmed from a clean browser profile.
- Transparency as a feature: every answer's origin, routing reason, and latency are visible — judges can audit the hybrid claim instead of trusting it.
- $0 to build and run: Spark plan, Gemini Developer API free tier, no paid services anywhere in the stack.
- The app never hard-fails: no Nano → cloud; no cloud → local engine; no Firebase config → full demo mode. Every degradation is labeled, not hidden.
What we learned
- Hybrid inference is a product decision, not just an API flag: the interesting engineering is the classifier, the thresholds, and the honesty contract with the user.
- Remote Config turns routing policy into something you can tune like a dial instead of redeploying code.
- Building for flaky networks changes every default: assume the next request fails, cache the policy, and make the fallback good enough to be a feature.
What's next for NanoWise
- True offline study packs: pre-downloaded chapter summaries generated in the cloud, consumed offline on-device.
- Spaced-repetition flashcards generated from session history in Firestore.
- A Chrome extension build so NanoWise sits next to any reading material.
- Per-subject routing profiles (math escalates earlier; vocabulary stays on-device).
Built With
- 3.5
- ai
- app
- check
- config
- firebase
- firestore
- flash
- gemini
- hosting
- javascript
- logic
- nano
- remote