Inspiration
Students often study with an unstable or expensive internet connection: in a library with weak Wi-Fi, on a commute, or in regions where data is costly. Yet most AI study tools need the cloud for everything, so they stop working exactly when students need them. At the same time, on-device models like Gemini Nano are fast, private and free to run, but they are not available on every device. We wanted an app that uses the best of both worlds: local AI when it's available, cloud AI when it isn't or when the task is too heavy, with one SDK deciding for us.
What it does
SmartStudy AI is a study assistant with six tools:
Light tasks (summarize a note, generate flashcards, explain a concept) run on-device with Gemini Nano through InferenceMode.PREFER_ON_DEVICE. They work offline, keep notes private and cost nothing. If no local model exists, Firebase AI Logic falls back to the cloud automatically. Heavy tasks (deep analysis of a long course or PDF, a full 14-day revision plan, complex exam-level exercises with solutions) use InferenceMode.ONLY_IN_CLOUD.
Every result shows a badge, Local · Gemini Nano or Cloud, so the routing is visible. Offline, the app tells the student clearly when a task needs internet. Students sign in with Google, and their generations are saved to a private history in Firestore.
How we built it Frontend: React, TypeScript and Vite, with a custom CSS design. Firebase AI Logic: getAI, getGenerativeModel and InferenceMode in src/ai.ts. Light tasks use PREFER_ON_DEVICE; heavy tasks use ONLY_IN_CLOUD. App Check: reCAPTCHA Enterprise in production; the debug provider is enabled only in development builds (import.meta.env.DEV). Authentication: Google sign-in. Firestore: per-user study history, protected by security rules. Remote Config: cloud model names and the local text-length limit can change without redeploying. Hosting: free deployment on Firebase Hosting. PDF support: text extracted in the browser with pdfjs-dist, so documents never need a server.
We built it with Claude as a coding assistant, with all AI calls going through Firebase AI Logic.
Challenges we ran into App Check: moving from the debug token to reCAPTCHA Enterprise took several iterations (403 errors on token exchange, a provider mismatch between reCAPTCHA v3 and Enterprise, and a build that still shipped the debug flag). We fixed the last one by enabling the debug provider only when import.meta.env.DEV is true. Different devices, different scores: reCAPTCHA scores varied across browsers and phones, so some devices were rejected. We kept App Check initialized but in monitoring mode on the public deployment so every reviewer can use the app. Model availability: cloud model names change quickly (a default model was retired), so we moved model names into Remote Config. On-device limits: Gemini Nano only runs on desktop Chrome with the local model installed, and only with short single-turn text. We added a character limit for local tasks and a clear message when a heavy task needs the internet. [à adapter: mentionne ici ta difficulté réelle avec le mode hors ligne si tu l'as eue] Accomplishments that we're proud of A single codebase where the same SDK routes each request to the device or the cloud, with a visible badge proving it. A complete product, not just a demo: authentication, saved history, PDF import, remote configuration and a public deployment. Offline studying that actually works on supported desktops [à adapter: garde cette phrase seulement si ton test hors ligne avec le badge Local a réussi]. Using five Firebase products together (AI Logic, App Check, Authentication, Firestore, Remote Config) plus Hosting. What we learned Hybrid inference is mostly about deciding which task belongs where: short, private, repeatable tasks locally; long, complex ones in the cloud. App Check needs the provider type, the key type and the console configuration to match exactly, and a production build must never be able to use a debug token. Never hardcode model names: they get retired. Remote Config makes this a one-minute fix. On-device AI is great but not universal, so a graceful cloud fallback and honest UI messages matter. What's next for SmartStudy AI Android version with Gemini Nano through the same Firebase AI Logic SDK, and an iOS version with Apple Foundation Models, to bring true offline study to phones. Offline caching (service worker) so the app itself loads without a connection. Spaced-repetition scheduling for flashcards and progress tracking. Smarter routing: choose local or cloud automatically from the text length and device capability. Re-enabling App Check enforcement with a tuned score threshold once we have enough real traffic data.