Inspiration
Rural and low-connectivity clinics should not have to choose between a fast first screen and a reliable referral record. Offline Clinic was built around a simple constraint: the safety-critical triage result must appear immediately, even when the network does not.
What it does
Offline Clinic turns a short maternal chief complaint into an explainable red/yellow/green result, a structured referral, and a local handover record. A health worker types or dictates the complaint, answers a small set of structured questions, and sees the exact reason codes behind the local decision. Records persist on the device and can be reopened, inspected, deleted, printed, or exported as JSON or CSV.
When connectivity returns, the same structured record can be sent to Firebase AI Logic for a separate documentation-quality review. The local red-flag result always remains authoritative. The app never uploads audio, and it degrades honestly to a pending-review queue when the cloud is unavailable.
How we built it
The local workflow is deterministic and testable: validation, red-flag precedence, persistence, metrics, export, and reset are covered by automated tests. The production cloud path imports getAI, getGenerativeModel, GoogleAIBackend, and InferenceMode from firebase/ai. It initializes a hybrid model with InferenceMode.PREFER_ON_DEVICE, uses gemini-3.8-flash for cloud fallback, and calls model.generateContent(reviewPrompt(intake)) at runtime. Firebase App Check protects the cloud path, and the UI reports the SDK inference source.
The interface includes a first-run synthetic case, local product metrics, a searchable archive, record detail, JSON/CSV export, and a deterministic demo reset so judges can reproduce the full workflow quickly.
Challenges and lessons
The hardest boundary was keeping cloud uncertainty out of the safety decision. We made local triage authoritative, isolated the Firebase review as a separate state, added a 30-second timeout, and preserved pending records when capacity is unavailable. We also treated speech as an optional input: typed text remains the reliable offline path because browser speech recognition may use an online vendor service.
Value
Offline Clinic demonstrates a practical hybrid pattern: instant local intelligence first, optional cloud quality review second, and a clear audit trail throughout. It is a triage-support prototype, not a certified medical device, and the transparent rule set is ready for clinical review.
Built With
- firebase-ai-logic
- firebase-app-check
- github
- google-gemini
- javascript
- localstorage
- vite
- vitest