Inspiration

Aidoo: AI Todo & Daily Planner was already my live Flutter productivity app helping users manage tasks, calendars, notes, and voice planning using cloud Gemini models. However, relying solely on cloud AI created real limitations for users: every quick task capture or private health/personal reminder had to be sent over the internet, consumed cloud API tokens, and stopped working completely when offline.

For #BuildHybridAI 2026, I upgraded Aidoo from a cloud-only AI planner into a hybrid, privacy-first, offline-capable AI assistant powered by Firebase AI Logic bringing on-device AI directly to supported Web, Android, and iOS devices while maintaining seamless cloud Gemini fallback everywhere else.

What it does

Note: Aidoo's core task manager, calendar, notes, Firebase Auth/Firestore sync, and cloud Gemini planning already existed prior to this hackathon. Below is the new on-device & hybrid AI functionality I built specifically for this hackathon.

  • On-Device AI Execution Across 3 Platforms (with Automatic Cloud Fallback):
    • Web (Chrome Built-In AI — Gemini Nano): Runs locally in Chrome Desktop 139+ (macOS, Windows, Linux) using the official Firebase AI Logic JS SDK v13.4.0 and Chrome's Prompt API.
    • Android (Gemini Nano via Google AICore): Runs locally via firebase-ai-ondevice on AICore-enabled flagships such as Google Pixel 8 / 9 / 10 / 11 series, Samsung Galaxy S24 / S25 & Z Fold/Flip flagships, Honor Magic 7 / 8 series, and iQOO 13 / 15, with live model download progress.
    • iOS (Apple Intelligence — FoundationModels): Runs locally on iPhone 15 Pro / 15 Pro Max, iPhone 16 series and newer, and M-series / A17 Pro iPads running iOS 26+.
    • Every Other Device & Simulator: Automatically detects on-device availability and falls back smoothly to Cloud Gemini—while honoring Private Shield by refusing cloud transmission when strict local mode is enabled.
  • 4 Hybrid AI Routing Modes:
    • Smart Hybrid (Recommended): Quick task capture, ADHD-friendly micro-step breakdowns, note-to-task extraction, and private items run locally on-device; deep multi-turn planning uses cloud Gemini with automatic compacted on-device fallback when offline.
    • Save Quota (Prefer On-Device): Prioritizes local inference on every compatible prompt to save cloud tokens.
    • Max Context (Prefer Cloud): Uses cloud Gemini when online and seamlessly falls back on-device if offline.
    • Private Shield (On-Device Only): A dedicated lock toggle in the AI chat AppBar plus per-task and per-note Private flags that strictly enforce ONLY_ON_DEVICE inference and withhold private items from cloud prompts (confirmed with an inline N private withheld badge).
  • Structured On-Device Task Actions: Local on-device models support structured JSON schema constraints to create, update, delete, and list tasks—generating the same interactive action cards as cloud AI.
  • Transparent On-Device UX & Telemetry:
    • Live On-Device Thinking indicator showing the active local engine (Chrome Gemini Nano, Android Gemini Nano, or Apple Intelligence).
    • Per-message Inference Badges displaying On-Device vs Cloud, model name, response time in seconds (e.g., 2.34s), and withheld private item count.
    • Hybrid AI Dashboard in Profile showing on-device readiness, one-tap local model download with progress bar, local-vs-cloud usage split, estimated cloud tokens saved, average local latency, and shielded request count.
  • Quota-Aware Local Continuity: When a user reaches their cloud token limit, Aidoo automatically continues free on-device via Gemini Nano instead of locking them out.

How I built it

To add on-device hybrid AI into my existing Flutter codebase without disrupting existing users, I built a clean, modular hybrid layer:

  • Unified Hybrid Router (HybridAiService & hybrid_ai_bridge.dart): A single Dart service with conditional platform exports that resolves routing modes, enforces privacy filtering (privateItemsFiltered), compacts prompts for local context windows, tracks telemetry, and manages graceful fallbacks.
  • Web Bridge (web/hybrid_ai_bridge.js): Integrated Firebase AI Logic JS SDK v13.4.0 (getAI, GoogleAIBackend, InferenceMode) with Chrome's LanguageModel API, responseConstraint JSON schemas, and explicit output language attestation (expectedOutputs).
  • Android Native Bridge (HybridAiPlugin.kt): Built a Kotlin MethodChannel and EventChannel wrapping com.google.firebase:firebase-ai and com.google.firebase:firebase-ai-ondevice for availability detection, streaming model download progress, and hybrid generation.
  • iOS Native Bridge (AppDelegate.swift): Built a Swift MethodChannel bridging Apple's FoundationModels framework for on-device generation on Apple Intelligence–capable iOS devices.
  • UI & WebApp Upgrades: Added the AI chat Private Shield switch, on-device thinking bubble, inference badges, Profile Hybrid AI telemetry card, actionable Show / Done notifications (including Web Service Worker notifications), and packaged a hosted Flutter WebApp (https://aidoo.sineix.com/webapp/) alongside updated Android and iOS builds.

Challenges I ran into

  • Getting structured task actions out of compact on-device models: Local models like Gemini Nano have tighter context windows and stricter formatting needs than cloud Gemini. I solved this with automatic prompt compaction (compactOnDevicePrompt) and explicit JSON schema constraints (responseConstraint) so local responses reliably drive Aidoo's Create/Update/Delete task UI.
  • Bridging 3 different native on-device ecosystems into Flutter: Chrome Prompt API, Android firebase-ai-ondevice, and iOS FoundationModels each expose different APIs, hardware requirements, and availability states (AVAILABLE, DOWNLOADABLE, DOWNLOADING, UNAVAILABLE). Normalizing them behind one Dart bridge required careful platform-specific engineering—including handling simulator limitations where on-device model daemons (like AICore or ModelManagerServices) are unavailable.
  • Production release stability on Android: Integrating native firebase-ai-ondevice and its Kotlin/Ktor dependencies triggered R8 full-mode reflection stripping in release APKs (WorkDatabase_Impl crash on startup), which I diagnosed via adb logcat and fixed with targeted ProGuard keep rules.
  • Web deployment under a subpath: Hosting the WebApp at /webapp/ required configuring --base-href /webapp/, relative bridge asset paths, and automatic REST fallback when browser App Check is not active.

Accomplishments that I'm proud of

  • Upgrading my existing production Flutter app to support true 3-platform on-device hybrid AI (Chrome Gemini Nano, Android Gemini Nano via AICore, and iOS Apple Intelligence) with automatic cloud fallback and zero breaking changes for existing users.
  • Delivering verifiable privacy: users can mark sensitive tasks/notes as Private or flip Private Shield on and immediately see On-Device execution and private withheld badges on every response.
  • Shipping working builds across Web (https://aidoo.sineix.com/webapp/), Android (release APK/AAB), and iOS with live telemetry proving real cloud tokens saved.

What I learned

  • Adding on-device AI to an existing cloud app isn't just about cutting API costs—it unlocks entirely new user value: offline task planning, strict local privacy for sensitive personal items, and free local continuity when cloud quotas run out.
  • Transparency matters: Showing users which model is thinking, whether a reply ran locally or in the cloud, how fast it ran, and how many private items were kept off the cloud makes hybrid AI tangible and trustworthy.

What's next for Aidoo: AI Todo & Daily Planner

  • Offline multimodal task capture: Extending on-device inference to process photos of notes, receipts, and schedules completely locally.
  • On-device smart calendar optimization: Running local conflict detection and automatic daily schedule rebalancing without cloud round-trips.
  • Public rollout: Releasing Aidoo v1.2.3 with Hybrid AI to the Google Play Store and Apple App Store.

Built With

  • apple-intelligence
  • chrome-built-in-ai
  • cloud-firestore
  • dart
  • firebase
  • firebase-ai-logic
  • firebase-analytics
  • firebase-app-check
  • firebase-auth
  • flutter
  • foundation-models
  • gemini-nano
  • google-aicore
  • google-gemini
  • javascript
  • kotlin
  • pwa
  • riverpod
  • swift
Share this project:

Updates

Submission history