Inspiration
In India, as in a lot of places, your blood test results reach you before your doctor does. The lab sends a PDF to your phone: sixteen numbers, a column of ranges, and an H or an L next to some of them. The appointment is days away.
So people search each value, or paste the whole report into a chatbot, with their name, age, lab ID and doctor still on it. The answers come back confident, sometimes wrong, and occasionally frightening.
I wanted something that answers the question people actually have on that Friday ("what does this mean, and what should I ask?") without the report leaving the phone, and without pretending to be a doctor.
What it does
- Reads the report on your device.
- Web: a digital PDF is read by plain rules in the browser, with no AI involved.
- Android: you take a photo; ML Kit text recognition reads it on the phone.
- On a device with Gemini Nano, Nano reads unusual layouts and photos, in
ONLY_ON_DEVICEmode: a report image is never sent to the cloud, whatever the settings say.
- Code does all the numbers. It parses ranges the way labs print them ("12.0 - 15.0", "< 200", "> 50", "Upto 40") and works out high and low flags, near-a-limit warnings, and trends against earlier reports kept on the device. A model never does arithmetic here.
- Explains each flagged result in two or three plain sentences, with questions to ask the doctor. This runs on Gemini Nano when the device has it, and in the cloud only if you turn on "Cloud explanations".
- Checks every explanation with a guard. An answer is thrown away, and a plain summary shown instead, if it:
- quotes a number that isn't this test's own;
- reads like a diagnosis;
- suggests a medicine or a dose;
- doesn't point back to the doctor.
- Takes your notes, with fixed red flags. You can add what you've noticed. Warning signs like chest pain, stroke signs or fainting are caught by fixed rules, not AI, and tell you to get care now (112, or Tele-MANAS 14416).
- Reads your watch. On Android this comes through Health Connect. Plainly compares this week with your own
previous 28 days:
- Measures: resting heart rate, heart rate variability, sleep, and overnight blood oxygen.
- Recovery: a score from 0 to 100, where 50 is a normal day for you.
- Safety alerts: fixed rules, such as a resting pulse above 100 for three days.
- Workouts: highs, lows, time in zones, one-minute heart-rate recovery, and a live replay.
- Ends on one page for your doctor: your questions, your notes, and your week.
- Runs on the web, Android and iPhone. The web app installs to the iPhone home screen and works offline.
How I used Firebase AI Logic
Plainly splits the work by how private it is.
| Job | Where it runs | Firebase AI Logic mode | What the model sees |
|---|---|---|---|
| Read a report photo | On the device only | InferenceMode.ONLY_ON_DEVICE |
the image |
| Explain a result | On the device, or the cloud when allowed | PREFER_ON_DEVICE, or ONLY_ON_DEVICE when the cloud is off |
de-identified facts only |
| Tidy the patient's notes | On the device only | ONLY_ON_DEVICE |
the notes |
- What the cloud gets: when explanations do go to the cloud, they carry only the test name, value, unit, printed range, the flag code computed, the earlier value, an age band ("50s") and sex. Never the name, lab, dates, IDs, doctor or image. The de-identification is its own small, tested module.
- Structured output both ways:
responseConstrainton the device andresponseJsonSchemain the cloud. - Every answer is labelled:
inferenceSourceis recorded per explanation and shown in the app ("on this device", "in the cloud, de-identified", or "plain summary"). - On Android:
firebase-aiwithfirebase-ai-ondevice(OnDeviceConfig,FirebaseAIOnDevice.checkStatusanddownload), with the cloud fallback on the Agent Platform Gemini API. - Other Firebase products:
- App Check: reCAPTCHA Enterprise on the web; the debug provider in the test APK.
- Remote Config: the cloud model and image size.
- Hosting: the web app.
How I built it
- Web: React and TypeScript with Vite; pdf.js for PDFs; IndexedDB for history.
- Android: Kotlin and Jetpack Compose, ML Kit text recognition, and the Health Connect client.
- One set of rules on both: range parsing, the report reader, flags, trends, the guard, red flags, vitals and workouts are written once in TypeScript and ported line for line to Kotlin. The Kotlin tests assert the same numbers as the web tests (13 tests on each side).
Challenges I ran into
- Real phone photos are messy. The first photo on a mid-range Android phone found 1 of 16 results. ML Kit returns
level boxes even when the page is tilted, so I search a range of slopes and keep the one that parses the most rows.
Then I fixed what the phone actually misread:
- a lost "<";
- decimal commas;
- "g/dL" read as "gldL";
- "Age / Sex" read as "Age I Sex";
- on the emulator, "< 100" read as ":100".
It now finds all ten flagged results. The exact text that phone produced is a test fixture.
- Saying nothing wrong matters more than sounding smart. Small models will happily invent a number or a condition. The guard, plus keeping every number in code, is what makes the explanations safe to show.
- Hardware. My laptop and phone can't run Gemini Nano. Every path works without it, and the app is honest about where each answer was written.
Accomplishments that I'm proud of
- The report itself never leaves the device, on any platform.
- On Android and the web, the same report gives the same flags, the same trends, and the same vitals, down to the digit.
- It refuses to diagnose, and the refusal is enforced in code, not left to a prompt.
What I learned
Hybrid inference is more useful as a privacy boundary than as a speed trick. Deciding what each model may see (the image only on the device, de-identified facts in the cloud) shaped the whole design.
What's next for Plainly
- Native iOS, once Firebase AI Logic's Apple Foundation Models support ships with the iOS 27 SDK.
- Live heart rate from Bluetooth straps, and Fitbit through the Google Health API.
- Hindi and other Indian languages.
- A family health vault, and versions for labs and clinics, where "patient data never goes to a third-party AI" is the selling point.