Inspiration
Vehicle breakdowns rarely happen in the convenience of your driveway on a stable 5G connection. They happen on rural highways, in underground parking garages, and in cellular dead zones. We realized that relying purely on cloud-based AI in an emergency leaves stranded drivers with a hanging loading screen and zero actionable advice. We wanted to build an application that didn't just wrap an API, but actively adapted to the user's hardware and environment to guarantee a safe exit strategy.
What it does
Nano Mechanic is a hybrid automotive AI dispatcher. Using a smartphone camera, it visually diagnoses engine failures, dashboard warning lights, and body damage.
It features Network-Aware Dynamic Routing:
- When Online (The Master Mechanic): It routes to Firebase Cloud (Gemini Carbon/Flash), delivering deep, multi-modal reasoning to identify specific parts, grade severity, and recommend precise tools.
- When Offline (The First Responder): It instantly routes to the on-device Gemini Nano model. Prioritizing safety, it evaluates the emergency and generates native Google Maps dispatch queries (e.g.,
"nearest 24 hour tow truck") so the user can immediately launch their GPS and get help without a single byte of internet.
How we built it
We built Nano Mechanic natively in Kotlin, leveraging the Firebase AI Logic SDK and Android AICore.
At the core of the app is our custom routing repository. When an image is captured, our Synchronous UI Gatekeeper evaluates network availability and Nano model readiness in milliseconds. If online, it serializes the image for Firebase Cloud. If offline, it intercepts the request, downscales the image pipeline, and hands off the tensor data directly to the device's Neural Processing Unit (NPU).
All endpoints are secured via Firebase App Check (Play Integrity), and all diagnostic reports are persisted locally via a Room Database so the driver's history is always accessible offline.
Challenges we ran into
Building for edge computing is fundamentally different than building for the cloud. We faced severe hardware-level constraints:
- NPU Memory Exhaustion (
ErrorCode -110): Feeding raw 50-megapixel CameraX bitmaps directly to the local NPU caused instantaneous memory crashes. We had to architect an offline-specific image pipeline that aggressively downscales bitmaps to a maximum of 800px, preserving visual context while keeping the memory footprint hardware-safe. - Hardware Cold Boots: Loading a 3GB localized model into active RAM can take 20 to 30 seconds. Standard network timeouts caused the app to crash before Nano could finish thinking. We engineered a 45-second asynchronous circuit breaker specifically for the on-device repository.
- Prompting Quantized Models: Gemini Nano rejected standard
application/jsonconfigurations. We had to decouple our cloud and edge configurations, manually injecting JSON-enforcement rules into the Nano system prompt and building a robust string-cleaning parser to prevent the UI from crashing on raw markdown.
Accomplishments that we're proud of
We successfully bridged the gap between cutting-edge LLMs and mobile hardware realities. We didn't just build a chatbot; we built an intelligent state machine that knows its own limitations. We are incredibly proud of the dynamic UI that transitions seamlessly between cloud fidelity and edge-computing triage, and our URI-encoded Maps integration that turns an AI diagnosis into physical, real-world roadside assistance.
What we learned
We learned the profound architectural differences between a 100-billion-parameter cloud model and a 2-billion-parameter edge model. We discovered that for on-device AI, prompt engineering isn't about extracting maximum knowledge—it is about defensive programming. We learned to explicitly prompt Nano to prioritize safety (Severity: Unknown) rather than hallucinating mechanical advice it didn't have the parameters to verify.
What's next for Nano Mechanic
We plan to integrate Bluetooth Low Energy (BLE) to connect directly with standard OBD-II car scanners. By combining real-time engine telemetry codes with our hybrid Vision AI, Nano Mechanic will be able to cross-reference visual damage with internal computer errors, creating the ultimate, fully offline diagnostic tool for both everyday drivers and professional mechanics.
Built With
- android
- api
- artificial-intelligence
- edge-computing
- firebase
- gemini
- google-cloud
- json
- kotlin
- machine-learning
- mobile
- on-device-ml
- room
- sqlite
- ux-design