Inspiration

Every day, patients and caregivers receive confusing blood test results, discharge summaries, and prescriptions filled with Latin shorthand (HbA1c 6.8%, eGFR 54 mL/min, Levothyroxine 50mcg QAM PO). Trying to make sense of them before a doctor's visit, millions of people copy-paste raw medical documents—complete with full names, dates of birth, MRNs, SSNs, phone numbers, and home addresses—directly into cloud LLMs.

We built ClearChart to prove that patients should never have to trade their medical privacy for clinical clarity. Using Firebase AI Logic's Hybrid Inference architecture, ClearChart runs sensitive processing locally on-device when Gemini Nano is available and enforces a compile-time, zero-PII privacy firewall before anything ever reaches Cloud Gemini.

What it does

ClearChart is a 100% free, cross-platform (Web, Android, and iOS) medical lab report and prescription companion built around a three-tier Hybrid AI privacy architecture:

  • Direct On-Device Clinical Summary (ONLY_ON_DEVICE): When Gemini Nano is ready locally (Chrome Desktop Prompt API / Android AICore), ClearChart surfaces Get Clear Summary - On Device, delivering a plain-English clinical summary locally with zero cloud transfer—without even needing to strip personal details.
  • On-Device Privacy Firewall (ONLY_ON_DEVICE): When cloud reasoning is used (or on devices without a local model), ClearChart scrubs PII/PHI locally via Gemini Nano + a deterministic on-device regex guard (PiiRegexSanitizer covering names, DOBs, MRNs, SSNs, US & international phone numbers, emails, and addresses). Users inspect every redaction live in a split-screen Raw vs. Redacted diff inspector.
  • Type-Safe AnonymizedPayload Boundary: ClinicalBriefRepository.generateClinicalBrief accepts only a sealed, SHA-256-fingerprinted AnonymizedPayload minted exclusively inside PrivacyFirewallRepository—never a raw String. Leaking raw patient text to Cloud Gemini is a compile-time error.
  • Deep Cloud Clinical Brief (ONLY_IN_CLOUD): Sends only the verified AnonymizedPayload to Firebase AI Logic (gemini-3.8-flash) to generate structured plain-English biomarker cards with custom clinical range bars (Low / Optimal / High), an interactive 5-question Doctor Visit Prep checklist, lifestyle guidance, and red-flag symptom warnings.
  • Offline-First Med & Jargon Helper (PREFER_ON_DEVICE): Imports PDFs, text files, or scanned pill-bottle/prescription photos (on-device Google ML Kit OCR on mobile) and decodes Latin Rx shorthand (PO, BID, QHS, QOD, QAM) into a Morning-to-Bedtime dosage timeline with critical absorption-spacing alerts (e.g., 4-hour separation between Levothyroxine and Iron) plus an instant Medical Word Helper.
  • Verifiable Zero-PII Firestore Vault: Saves anonymized summaries strictly under each user's Firebase Anonymous Authentication UID (users/{uid}/anonymized_reports/{id}), complete with an "Inspect Raw Firestore Document" JSON modal proving zero PII ever reached the cloud, plus one-click Markdown export for doctor visits.

How we built it

We built ClearChart with Google Antigravity from a single cross-platform Flutter codebase (flutter_bloc, get_it, equatable) running live on Web (https://clearchart-7c0c6.web.app) and Android (v1.0.0 APK on GitHub Releases), integrating 5 Firebase products at runtime:

  • Built with Google Antigravity: Used Antigravity's agentic coding, architecture, testing, and live browser verification workflows to design the Clean Architecture layers, enforce the compile-time AnonymizedPayload privacy boundary, configure Firebase products, and verify end-to-end Web and Android builds.
  • Firebase AI Logic (firebase_ai ^5.1.0): Powers HybridAiRouter (onlyOnDevice, preferOnDevice, onlyInCloud), bridging Chrome's Built-in AI (LanguageModel Prompt API) and Android AICore with Cloud Gemini (gemini-3.8-flash using ThinkingLevel.low and automatic gemini-2.5-flash / gemini-2.5-flash-lite resilience fallback via FirebaseAI.agentPlatform).
  • Firebase App Check (firebase_app_check): Enforces endpoint protection across both Web and Android builds.
  • Firebase Remote Config (firebase_remote_config): Dynamically controls cloud model names (cloud_model_name, cloud_clinical_model, med_helper_cloud_model), strict PII guard toggles, and all three clinical system prompt templates without redeploying the app.
  • Cloud Firestore (cloud_firestore): Stores zero-PII clinical summaries enforced by owner-only security rules (firestore.rules).
  • Firebase Anonymous Authentication (firebase_auth): Provides instant, zero-friction private vaults with no login wall or user-supplied API keys.
  • On-Device Ingestion & Clinical UI: Native Web & IO PDF/TXT extraction (syncfusion_flutter_pdf), mobile photo OCR (google_mlkit_text_recognition on Android/iOS), responsive AdaptiveShell (Mobile / Tablet / Desktop), Light & Dark clinical themes, custom BiomarkerRangeBar visualizations, and a live Hybrid Diagnostics telemetry panel.

Challenges we ran into

  • Enforcing privacy at the type-system level: Prompting a cloud LLM to "ignore PII" still transmits sensitive data over the wire. We solved this architecturally by enforcing a sealed AnonymizedPayload type boundary so raw strings cannot even be passed to the cloud inference layer.
  • Graceful degradation across heterogeneous devices: On-device Gemini Nano availability varies across Chrome Desktop, flagship Android phones, and mid-range devices. We built transparent hybrid routing with live execution badges (⚡ On-Device vs. ☁️ Cloud • Anonymized), 8-second local readiness guards, and a deterministic on-device regex safety net so every user gets a fast, private experience on any hardware.
  • Cloud latency & structured JSON reliability: Early tests on gemini-3.8-flash hit 503 Deadline expired timeouts and unsupported MINIMAL thinking-level errors. Tuning ThinkingConfig.withThinkingLevel(ThinkingLevel.low), enforcing a compact application/json key contract, and adding automatic retry + gemini-3.8-flash-lite fallback made cloud briefs fast and dependable.

Accomplishments that we're proud of

  • True Multi-Platform Hybrid AI: One Flutter + Firebase AI Logic codebase running live on Web (https://clearchart-7c0c6.web.app) and Android (v1.0.0 release APK).
  • Auditable Zero-PII Cloud Proof: Judges and patients can click "Inspect Raw Firestore Document" inside the Saved Vault to verify firsthand that not a single name, DOB, MRN, or phone number ever touched Cloud Firestore.
  • Zero-Friction Judging & Open Source: Live Firebase Hosting demo, downloadable Android release APK, 3 realistic 1-click sample medical reports, 100% free with zero paywalls, and licensed under Apache 2.0 (https://github.com/techie2046/clearchart).

What we learned

  • Hybrid AI shines brightest when privacy is the routing signal, not just offline convenience—combining on-device Gemini Nano with cloud Gemini unlocks sensitive healthcare workflows that cloud-only AI cannot responsibly offer.
  • Firebase Remote Config + Firebase AI Logic is a superpower for production AI apps: upgrading models (gemini-2.5-flash → gemini-3.8-flash) and refining clinical prompts takes seconds without rebuilding or redeploying client binaries.

What's next for ClearChart

  • Native iOS release leveraging Apple Foundation Models via Firebase AI Logic.
  • Longitudinal biomarker trend charts (tracking HbA1c, LDL, and eGFR over 6–12 months) stored purely as anonymized numeric time-series in Firestore.
  • Multilingual plain-English clinical briefs so families can review lab reports in their preferred language.

Built With

  • android
  • antigravity
  • chrome-built-in-ai
  • cloud-firestore
  • dart
  • firebase
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • firebase-remote-config
  • flutter
  • flutter-bloc
  • gemini
  • gemini-nano
  • google-ml-kit
  • web
Share this project:

Updates

Submission history