Inspiration

Warehouses, cold-storage facilities, and high-turnover retail backrooms are notoriously hostile environments for cloud-only AI. Thick concrete walls, metal racking, and subterranean loading bays create dead zones where Wi-Fi and cellular signals drop constantly. When an operator scans damaged incoming freight or audits low stock in an offline aisle, cloud-dependent apps freeze—costing businesses thousands in missed discrepancies and delayed restocks.

We built StockPulse Hybrid to prove that enterprise inventory intelligence shouldn't stop when the network drops. By combining on-device Gemini Nano inference with cloud-scale Gemini 2.5 Flash via Firebase AI Logic, StockPulse delivers millisecond-latency SKU extraction and offline decision-making at the edge while seamlessly escalating complex multi-document margin analysis to the cloud whenever connectivity is available.


What It Does

StockPulse Hybrid is an offline-first retail and warehouse operations copilot built across Web, Android, and iOS:

  1. Dual-Stage Hybrid Receipt & Shelf Scanner:
    • Stage 1 (Edge / On-Device): Gemini Nano parses raw supplier manifests, extracts SKUs and quantities, and flags physical damage anomalies in ~35 ms with zero server egress.
    • Stage 2 (Cloud AI Fallback & Escalation): Firebase AI Logic routes structured payloads to Gemini 2.5 Flash to compute blended gross margins, benchmark supplier pricing, and generate vendor credit memos.
  2. Natural Language Inventory Copilot: Warehouse staff issue plain-English operational commands (e.g., "Audit Bay 12 for missing thermal labels and calculate reorder budget"). The copilot outputs strict, deterministic JSON inventory actions alongside real-time inference telemetry (ON_DEVICE vs. IN_CLOUD).
  3. Real-Time Telemetry & Cost-Preservation Analytics: Tracks local vs. cloud inference split, cloud tokens preserved, SKU gross margin spreads, and an immutable AI Operations Audit Trail.
  4. Live Judge & Architecture Inspector: A built-in verification console exposing active Firebase App Check debug telemetry, anonymous judge authentication, offline Cloud Firestore persistence, and dynamic Firebase Remote Config routing thresholds.

How We Built It

We architected StockPulse Hybrid using Flutter for unified multi-platform delivery (Web, Android, and iOS) backed by the Firebase ecosystem:

  • Firebase AI Logic (Hybrid Inference SDK): Configured in PREFER_ON_DEVICE mode with automatic cloud fallback (gemini-2.5-flash) and explicit routing overrides (Auto, Force On-Device, Force Cloud).
  • Dynamic Routing Policy: Our hybrid router evaluates connectivity state, task complexity, and a Firebase Remote Config character threshold ($L_{\max}$) to determine execution placement:

$$\text{Route}(x) = \begin{cases} \text{On-Device (Gemini Nano)} & \text{if } \text{offline} \lor (|x| \le L_{\max} \land \text{localAvailable}) \ \text{Cloud (Gemini 2.5 Flash)} & \text{otherwise} \end{cases}$$

  • Offline-First Data Layer: Cloud Firestore with unlimited local cache persistence ensures catalog mutations, stock adjustments, and audit logs survive complete network blackouts and synchronize automatically upon reconnection.
  • Security & Abuse Protection: Integrated Firebase App Check (reCAPTCHA v3 for Web, Play Integrity + Debug Tokens for mobile/evaluation) and Firebase Authentication (one-click anonymous session initialization).
  • High-Contrast Editorial UI: Designed a high-visibility Swiss editorial interface (#F4F5F7 canvas, #0055FF Cobalt Blue for Edge AI, #FF4500 International Orange for Cloud AI) featuring a custom vector CustomPainter isometric logo and a live animated routing visualizer.

Challenges We Ran Into

  • Cross-Platform Hardware Heterogeneity: While flagship mobile devices support native local foundation models, standard desktop browsers and older mobile hardware lack local NPU weights. Designing a graceful, transparent fallback pipeline in Firebase AI Logic—and surfacing exact routing badges (ON_DEVICE vs. IN_CLOUD) plus a Simulate Offline toggle—ensured consistent behavior across Web, Android, and iOS.
  • Deterministic Structured Outputs on Small Models: Getting reliable JSON inventory mutations from compact on-device prompts required strict schema constraints, concise system instructions, and token-budget tuning via Remote Config.
  • Multi-Platform App Check Configuration: Coordinating reCAPTCHA v3 site keys for Firebase Hosting alongside debug tokens for frictionless judge evaluation across platforms required careful initialization sequencing prior to invoking AI Logic endpoints.

Accomplishments That We're Proud Of

  • 74%+ Edge Offload Rate: Routine SKU lookups, stock health checks, and receipt parsing execute locally with zero cloud token expenditure.
  • True Offline Resilience: Operators can toggle offline mode mid-workflow, execute local AI audits, queue cloud margin tasks, and watch automatic synchronization upon reconnect.
  • Zero-Friction Judge Verification: Any evaluator can open the live web deployment, inspect App Check and Remote Config state in one click, and test both edge and cloud execution paths immediately.

What We Learned

Hybrid AI isn't merely a fallback strategy—it is an architectural superpower for industrial and retail software. Splitting workloads between fast, private, zero-cost edge inference and deep cloud reasoning yields better latency, lower API bills, and uninterrupted uptime in real-world environments.


What's Next for StockPulse Hybrid

  • Camera Barcode & Multimodal Damage Vision: Direct camera stream integration using multimodal Gemini models to visually inspect damaged pallets on the loading dock.
  • Predictive Reorder Agents: Automated ERP purchase-order drafting triggered when rolling 7-day velocity breaches safety stock thresholds.
  • Multi-Warehouse Fleet Sync: Role-based access control and regional warehouse benchmarking across distributed distribution centers.

Built With

  • android
  • cloud-firestore
  • dart
  • edge-ai
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • flutter
  • gemini
  • gemini-2.5-flash
  • gemini-nano
  • hybrid-ai
  • ios
  • offline-first
  • on-device-ai
  • recaptcha
  • web
Share this project:

Updates

Submission history