MendOS: Gemini Nano on device, Gemini in the cloud, offline repair packs

MendOS is an offline-first repair co-pilot for home electronics, on the web (Chrome) and Android. It runs every AI call through Firebase AI Logic with PREFER_ON_DEVICE, keeps working with no network through offline repair packs, puts safety and privacy in tested code instead of prompts, and walks you from "it's broken" to a verified, logged fix.

Try it: Live web app · Android APK (v0.1.0) · Source code, Apache-2.0 · Evidence index

Inspiration

One Sunday night our router stopped working. The phone was the only screen left, and every source of help we would normally use (a chatbot, a video tutorial, the support site) needed the internet that was broken.

That is the core of MendOS: the device you need to fix is often the device that gives you the internet, and the moment you need help is often the moment you are least connected. Hybrid AI from Firebase fits this exactly: Gemini Nano on the device when it is available, Gemini in the cloud when it is not, and in MendOS, an offline repair pack when there is no network at all.

Sunday night, no Wi-Fi, and a pile of e-waste

It is not only Wi-Fi

The same pattern repeats across the house. A washer stops mid-cycle and shows a code nobody remembers. A monitor goes dark and you cannot tell if it is the cable, the power brick or something dangerous inside. Bike brakes feel soft the morning you need to ride. In each case people either guess, pay for a call-out they did not need, or throw the device away.

Real situation What the person sees What MendOS does Outcome
Router, no internet All lights look "normal", no website loads Asks the one check that splits the most causes first ("Is the router's power light on?", "Does any other phone have internet?"), across 8 causes from power to DNS Fixed at home (restart, WAN cable, DHCP) or told plainly it is a provider outage
Washer stopped, water in the drum E24 (some brands), OE (LG), F21 (Whirlpool), E18 (Bosch, Siemens), 5E (Samsung) Looks up the code offline, ranks drain filter vs. kinked hose vs. failed pump, then a "before you start" checklist and one step at a time Most common cause (clogged drain filter) cleared with a towel and a tray
Washer won't fill IE (LG), 4E (Samsung) Checks the tap and inlet hose first, because they are the cheapest checks No technician needed for a closed tap or a kinked hose
Washer won't start dE / dC door error, UE unbalanced load Door-latch and load-balance checks with confirmations Fixed in minutes
Monitor, no power Black screen, no light Separates socket, power brick, cable, input and sleeping computer with checks like "Plug a lamp into the same socket" Cheap fix found, or internal power board → locked, do not open
Bike brakes and gears Lever pulls to the bar, brakes squeal, chain skips Pads, cable stretch, contaminated rim or disc, gear cable tension, dry chain Safe adjustment steps with a test ride check
Microwave won't heat "Can I open it and check the magnetron?" Locked by code: high voltage inside even when unplugged "Stop, call a qualified professional", plus technicians nearby
Swollen phone or laptop battery Back cover lifting Always locked: fire risk No DIY steps; the finder lists e-waste drop-off points nearby
Gas smell, fridge refrigerant, old CRT TV "How do I fix the gas line / regas the fridge / open the CRT?" Locked by code, whatever the model says No DIY steps, ever

Why this matters

Evidence Source
The world generated 62 million tonnes of e-waste in 2022; only 22.3% was documented as formally collected and recycled Global E-waste Monitor 2024
The EU now requires a right to repair for consumer goods Directive (EU) 2024/1799
A study of 150 appliance manuals found they "do not instruct the diagnosis of frequently failing components" Pozo Arcos et al., 2022
A review of 26 repair barriers lists the "lack of spare parts and repair manuals" Roskladka et al., 2023
"Access to information" and "Safety concerns" are top barriers to DIY repair Rovira-Menaya et al., PLATE 2025
922 repair café volunteers in 14 countries describe what makes repairs succeed Parajuly et al., 2023
More than 2,500 Repair Cafés run worldwide Repair Café

People want to repair. What they lack is diagnosis, safety and help that works when the network does not. MendOS is built around those three gaps.

What it does

MendOS: Fix it, even when the Wi-Fi is the broken thing

Step What happens Where it runs
1. Describe Text, an error code, an optional photo of a label, an LED blink rhythm or a machine's sound On the device
2. Safety gate Code checks the request. Mains, high-voltage capacitors, gas, refrigerant, microwaves, CRTs and swollen batteries are locked On the device, in code
3. Trust Receipt Shows exactly what would leave the device. Wi-Fi keys, passwords, MACs, serials, IMEIs, emails and phone numbers become placeholders; private photos stay local unless you paint over sensitive parts On the device, in code
4. Hybrid answer Firebase AI Logic with PREFER_ON_DEVICE: Gemini Nano when available, Gemini in the cloud otherwise. With no network, the offline repair pack answers with 0 bytes sent Device, cloud or pack, shown on a badge
5. Next best check One question at a time, the one that narrows the cause most per second of effort. Commits when one cause passes 75% On the device
6. Guided steps "Before you start" checklist, then one step at a time with confirmations, read aloud by the device's own text-to-speech On the device, offline
7. Verify and log Check the fix with an after photo or by tapping along with an LED's rhythm; the repair is saved to Firestore and syncs when the network returns Device + Firestore

Android: a router fix online

Android: describe it, see exactly what is sent, answer from Gemini in the cloud

A Wi-Fi key slips into the description. The Trust Receipt replaces it with [WIFI_KEY] before anything is sent, and the Routing Ledger records where the answer came from (IN_CLOUD), the bytes sent and the latency.

Android: airplane mode

Android: offline repair pack answers with 0 bytes sent, then syncs

No network at all. The offline pack answers, the next best check keeps narrowing the cause, the repair is saved as "pending sync", and it reaches Firestore when the phone is back online.

Android: washer error E24, from code to logged fix

Android: error code, most likely cause, safety checklist and guided steps

Android: each step verified, the fix saved and synced

Android: next best check and the safety lock

Android: one question at a time, dangerous repairs locked by code

Asking about a monitor's internal power supply returns "Stop, call a qualified professional" with the hazard class (HIGH_VOLTAGE_CAPACITOR). No DIY steps are rendered for a locked class.

Web: photo diagnosis with privacy built in

Web: paint over private details on a label photo

Web: Trust Receipt shows exactly what leaves the device

Web: hybrid answer with the badge from the SDK

Web: Wi-Fi key and MAC replaced with placeholders

Web: repair or replace, verify, find help

Web: Can-Do meter and repair vs. replace

Web: verify the fix by tapping along with the LED

Web: find a technician or e-waste drop-off nearby

More features

Feature What it does
Can-Do meter and repair-or-replace Effort, tools, cost and e-waste for four options: DIY, a repair café, a technician, or replace and recycle
Find help nearby Google Maps grounding through Firebase AI Logic, with real OpenStreetMap places as a second source, labelled as non-AI
Pack compiler Gemini builds a new offline repair pack from a product's support page (URL context) or Google Search grounding, checked against the pack's JSON Schema and the safety gate
Manual deep dive Upload a PDF manual; Gemini extracts the troubleshooting table into structured, schema-checked rows
Listen Mode Records an 8-band sound fingerprint of a healthy fan, pump or motor and compares it later on the device to spot a change
LED rhythm reader Tap along with a blinking light; a rule-based classifier names the pattern (solid, slow, fast, double) and maps it to the pack's LED table
Routing Ledger Every answer records its source, mode, bytes sent and latency, so you always know where your data went
Installable PWA Reloads and diagnoses with no network

Web: offline repair pack compiled from a manual

Web: Listen Mode compares a sound fingerprint

Web: repair history and impact

How we built it

Architecture

How MendOS works: shared core, Firebase AI Logic hybrid inference, offline packs and Firebase services

Every request passes through the same five layers on both platforms: the user's input, a deterministic shared core (safety, privacy, routing), Firebase AI Logic hybrid inference (or the offline pack), a validation and decision layer that turns an answer into one next check and guided steps, and Firebase services for identity, storage, configuration and hosting.

Firebase AI Logic at the center

Web (apps/web/src/ai/hybrid.ts):

const model = getGenerativeModel(fb.ai, {
  mode: InferenceMode.PREFER_ON_DEVICE,
  onDeviceParams: { createOptions, promptOptions: { responseConstraint: schema } },
  inCloudParams: {
    model: rcValue("cloud_model_fast"),          // from Remote Config
    generationConfig: { responseMimeType: "application/json", responseJsonSchema: schema, temperature: 0.4 },
  },
});
const res = await model.generateContent(prompt);
const source = sourceFromSdk(res.response.inferenceSource); // "ON_DEVICE" | "IN_CLOUD"

Android (Ai.kt):

val modelName = Firebase.remoteConfig.getString("cloud_model_fast")   // from Remote Config
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = modelName,
    generationConfig = generationConfig { responseMimeType = "application/json"; responseSchema = schema },
    onDeviceConfig = OnDeviceConfig(mode = InferenceMode.valueOfMode(mode)),
)
val src = if (res.inferenceSource == InferenceSource.ON_DEVICE) "ON_DEVICE" else "IN_CLOUD"

The on-device status is read with FirebaseAIOnDevice.checkStatus() on Android and LanguageModel.availability() in Chrome, and shown in the app. In Chrome, initializeDeviceModel() downloads Gemini Nano with a progress bar.

The badge is never guessed. It comes from the SDK's inferenceSource (sourceFromSdk). When no model ran, the badge says OFFLINE_PACK or DETERMINISTIC.

Every Firebase product we use

Firebase product How MendOS uses it Proof
Firebase AI Logic: hybrid inference PREFER_ON_DEVICE on web (firebase/ai) and Android (firebase-ai + firebase-ai-ondevice); one JSON Schema as on-device responseConstraint and cloud responseJsonSchema hybrid.ts, Ai.kt
Firebase AI Logic: grounding and tools Google Maps grounding for the repair finder, URL context and Google Search grounding for the pack compiler, PDF input for the manual deep dive cloudPipelines.ts
App Check Enforced on Firebase AI Logic. reCAPTCHA Enterprise on the live site, Play Integrity for Android release builds, debug providers only in development builds init.ts, MendApp.kt
Authentication Anonymous sign-in: no account form, but every repair belongs to a user ID init.ts
Cloud Firestore Repair history at users/{uid}/repairs, persistent local cache for offline writes, owner-only security rules with 10 emulator tests firestore.rules, rules.test.ts
Remote Config Model names, router thresholds and feature flags, with in-code defaults so the app works before the first fetch config.ts
Hosting Serves the installable PWA at mendos-292ab.web.app firebase.json
AI Logic monitoring Requests, success rate, latency and tokens in the Firebase console Console screenshot below

Built on Firebase: App Check enforced, AI Logic monitoring

Firebase project with the Android and Web apps

App Check enforced on Firebase AI Logic

Firebase AI Logic monitoring

Anonymous Authentication users

A repair document written from the phone in Firestore

Firebase Hosting serving the PWA

Safety and privacy are code, not prompts

A shared core in pure TypeScript (packages/shared-core) holds every decision that must not depend on a model. It is ported to Kotlin for Android (apps/android/core) and both versions run against the same JSON test vectors (tests/vectors).

Module What it decides TypeScript Kotlin
Safety gate Hazard class from rules and from the model; stricter() picks the stricter of the two, and locked classes never release DIY steps safetyGate.ts SafetyGate.kt
Credential scrubber Masks Wi-Fi keys, passwords, MACs, serials, IMEIs, emails and phone numbers, keeping the type ([WIFI_KEY], [MAC_1]) so the model can still reason; findLeaks() re-checks the final payload scrubber.ts Scrubber.kt
Router On-device, cloud, offline pack or rules, from network state, model availability, uncertainty and Remote Config thresholds decideRoute.ts DecideRoute.kt
Next best check Bayesian update over faults and the check with the highest information gain per second of effort nextBestCheck.ts NextBestCheck.kt
Uncertainty Agreement between several on-device samples decides whether to escalate uncertainty.ts web (on-device sampling)
Procedure state machine Guided steps with confirmations, verification and a safe stop fsm.ts Fsm.kt
LED cadence classifier Names a blink pattern from tap timings cadence.ts Cadence.kt
Sound fingerprint 8-band spectrum and cosine distance for Listen Mode spectrum.ts web only

The next best check scores each check \( c \) by expected information gain per second of effort:

$$ \text{score}(c) = \frac{H(F) - \mathbb{E}_{r \sim P(r \mid c)}\left[H(F \mid c = r)\right]}{\text{effort}(c)} $$

where \( H(F) \) is the entropy of the fault distribution. Cheap, informative checks ("Is the tap open?") come before expensive ones ("Remove the drain pump"), which is exactly how an experienced technician works.

Every model reply is validated against one JSON Schema per output (schemas/) with zod on the web and kotlinx.serialization on Android. Invalid output is retried once, then the deterministic fallback answers.

Built with Gemini, reviewed by Gemini

We built MendOS with coding agents and the Firebase agent skills. Gemini reviewed and triaged the code through the run-gemini-cli GitHub Action (workflows) and Gemini Code Assist on pull requests.

The research behind the idea

Each part of MendOS comes from published work. We read these papers and built the feature on the finding.

MendOS feature Research it builds on What we took from it
Next best check Heckerman, Breese & Rommelse, "Decision-theoretic troubleshooting", CACM 1995 Choose repair actions by probability of fixing the fault per unit cost
Next best check Vershinin et al., 2025 Ask the question that will "maximize the ratio of expected information gain to expected cost"
Next best check Rainforth et al., "Modern Bayesian experimental design", Statistical Science 2024 Expected information gain as the score for the next experiment
Next best check McCabe et al., 2026 LLM agents "struggle to consistently identify faults" in appliances on their own, so the questioning policy should not be left to the model
Next best check SADE, Tseng et al., 2026, FaulT-Bench, 2026 In network troubleshooting, most of the gain comes from the diagnostic policy, and agents without one keep probing until a benign condition is blamed
Escalate on uncertainty Self-consistency, Wang et al., 2022 Sample several answers and trust agreement
Escalate on uncertainty Semantic entropy, Farquhar et al., Nature 2024 Disagreement between samples predicts errors
Escalate on uncertainty SelfCheckGPT, Manakul et al., 2023 Sampling the same prompt detects unreliable answers with no access to model internals
Escalate on uncertainty HARISSA, Alkiek et al., 2026 For a local model, "delivering a wrong answer is worse than deferring", so MendOS escalates or defers
Hybrid routing Gemini technical report, 2023, On-device LLM review, 2024 Small on-device models for private, offline work; larger cloud models when needed
Credential scrubber Carlini et al., "Extracting training data from LLMs", USENIX Security 2021 Text sent to a model can be memorized and leaked later
Credential scrubber Lukas et al., 2023 "Scrubbing techniques reduce but do not prevent" leakage, so MendOS scrubs and also shows a Trust Receipt
Safety gate SafeText, Levy et al., 2022 Language models can give physically unsafe advice, so the final decision belongs to rules
Safety gate VLESA, Hu et al., 2026 Physical actions have immediate, irreversible consequences, so a hazard lock must not depend on a model's output
Can-Do meter Bandura, "Self-efficacy", 1977, van den Berge et al., DRS 2022 Repair intention is "self-efficacy mediated": show effort and tools up front
Listen Mode MIMII dataset, Purohit et al., 2019 Machine faults show up as changes in sound
Guided repair Pozo Arcos et al., 2022, Parajuly et al., 2023 Diagnosis is the missing step; step-by-step help is what volunteers give

Full quotes and access dates: docs/RESEARCH.md.

Measured results

We ran 30 scenarios across routers, washers, monitors, bikes and hazards with real model calls through Firebase AI Logic (eval/RESULTS.md, scenarios, runner).

Metric Result
Dangerous requests locked (gas, swollen battery, mains, high-voltage capacitor) 5 / 5
Safe requests wrongly locked 0
Secrets found in cloud payloads 0
Schema-valid diagnosis cards 25 / 25
Correct fault ranked first 23 / 25
Correct fault in the top 3 25 / 25
Median cloud answer time 2,049 ms
Tests Count Proof
TypeScript unit tests (shared core and web) 251 unit-tests.txt
Kotlin tests on the same JSON vectors 50 android-core-tests.txt
Firestore security rules tests (emulator) 10 firestore-rules.txt
End-to-end browser tests 7 e2e/
Continuous integration on every push all of the above ci.yml

Every claim in this story is mapped to a file, test or screenshot in docs/EVIDENCE.md.

Challenges we ran into

  • Making hybrid honest. It is easy to show "on device" whenever a model might be present. We read only the SDK's inferenceSource, record it in the Routing Ledger, and label every non-model answer as OFFLINE_PACK or DETERMINISTIC.
  • One behaviour on two platforms. Safety and privacy had to behave identically in Chrome and on Android. We solved it with one TypeScript core, a Kotlin port and shared JSON test vectors that both must pass.
  • Making privacy visible. Masking secrets is not enough if the user cannot see it. The Trust Receipt shows the exact payload, the masked items and the byte size of any photo before anything is sent.
  • Keeping the model inside the lines. One JSON Schema per output serves as both the on-device responseConstraint and the cloud responseJsonSchema, so on-device and cloud answers are interchangeable for the UI, and the validator catches the rest.
  • Repair with no network. The full flow (diagnosis, checks, guided steps, text-to-speech, saving) had to work in airplane mode. Offline packs, Firestore's persistent cache and the device's own speech engine made that possible.
  • Turning answers into actions. A long chat reply does not fix a washer. We moved the decision of what to ask next out of the model and into a small Bayesian engine.

Accomplishments that we're proud of

  • Hybrid inference on two platforms from one Firebase project, with App Check, Authentication, Firestore, Remote Config and Hosting wired on both.
  • Real repair cases beyond Wi-Fi: routers, washing machines (10 error codes across 5 brands), monitors and bikes, with dangerous categories locked by code.
  • 0 secrets in cloud payloads, 5 / 5 hazards locked and 0 false locks in a 30-scenario eval with real model calls.
  • A complete repair flow that works in airplane mode on a real phone and syncs when the network returns.
  • 311 automated tests across TypeScript, Kotlin and Firestore rules, plus end-to-end tests, all in CI.

What we learned

  • Hybrid AI is a product decision as much as a technical one: people need to know where an answer came from and what left their device.
  • One schema across on-device and cloud paths makes the model interchangeable; the UI never needs to know which one answered.
  • Deterministic code around the model (safety gate, scrubber, decision engine) is easier to test and to trust than prompt instructions.
  • Classic decision theory still beats a chat transcript for troubleshooting: the right next question is faster than a long answer.

What's next for MendOS

  • More repair packs (laptops, printers, fridges, e-bikes) compiled from manufacturers' manuals with the pack compiler.
  • Publish on-device measurements across more Gemini Nano-capable phones and desktops.
  • Photo-based diagnosis and voice questions in the Android app.
  • A hand-off to local repair cafés, so a volunteer can pick up where MendOS stops.

Try it: mendos-292ab.web.app · Android APK · Source code (Apache-2.0) · Evidence index

Built With

  • android
  • cloud-firestore
  • cloudflare-workers
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • gemini
  • gemini-nano
  • jetpack-compose
  • junit
  • kotlin
  • ml-kit
  • openstreetmap
  • play-integrity
  • playwright
  • pwa
  • react
  • recaptcha-enterprise
  • typescript
  • vite
  • vitest
  • web-audio-api
  • zod
Share this project:

Updates

Submission history