<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Moses Sunday</title>
    <description>The latest articles on DEV Community by Moses Sunday (@mosss_os).</description>
    <link>https://dev.to/mosss_os</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3939038%2F376f4a9d-f14d-42fe-88b8-171c364b8cb6.png</url>
      <title>DEV Community: Moses Sunday</title>
      <link>https://dev.to/mosss_os</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mosss_os"/>
    <language>en</language>
    <item>
      <title>uilding an Offline-First AI Medical Triage App That Runs 100% On-Device</title>
      <dc:creator>Moses Sunday</dc:creator>
      <pubDate>Mon, 18 May 2026 22:55:50 +0000</pubDate>
      <link>https://dev.to/mosss_os/uilding-an-offline-first-ai-medical-triage-app-that-runs-100-on-device-3mi6</link>
      <guid>https://dev.to/mosss_os/uilding-an-offline-first-ai-medical-triage-app-that-runs-100-on-device-3mi6</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Community health workers (CHWs) in remote areas face a brutal choice when they encounter a patient with a concerning wound or rash: send a photo to a distant doctor and wait days for a reply, or make a decision with limited training and no specialist backup.&lt;/p&gt;

&lt;p&gt;1 billion people live in areas with fewer than 1 physician per 10,000. Smartphone penetration in these regions is surprisingly high (often &amp;gt;60%), but reliable internet is scarce. Cloud-dependent AI tools simply don't work here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trij&lt;/strong&gt; solves this: a progressive web app that runs Google DeepMind's Gemma 4 entirely on-device, delivering AI-assisted triage in under 10 seconds — no internet required, no patient data ever leaves the phone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technical Architecture&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;The Inference Stack&lt;/strong&gt;&lt;br&gt;
The core challenge was running a meaningful LLM in the browser. We chose WebLLM with WebGPU as the primary path, with two fallbacks:&lt;/p&gt;

&lt;p&gt;Auto-detect: WebGPU available? → WebLLM (Gemma 4 E2B, ~1.5B params, quantized)&lt;br&gt;
            Ollama running locally? → Ollama API&lt;br&gt;
            Neither? → Demo mode (mock data, no real model)&lt;/p&gt;

&lt;p&gt;WebLLM loads the Gemma 4 model into the browser's GPU via WebGPU. The first load takes ~30 seconds to download and compile ~1.5GB of model weights (cached for subsequent visits). Subsequent inferences complete in under 10 seconds on devices with 4GB+ RAM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline-First Storage&lt;/strong&gt;&lt;br&gt;
All patient data is stored in IndexedDB via Dexie.js. The schema:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;// Patients&lt;br&gt;
interface Patient {&lt;br&gt;
  id: string;&lt;br&gt;
  chwUserId: string;&lt;br&gt;
  identifier: string;&lt;br&gt;
  ageYears?: number;&lt;br&gt;
  sex: 'M' | 'F' | 'other';&lt;br&gt;
  locationLat?: number;&lt;br&gt;
  locationLng?: number;&lt;br&gt;
  createdAt: string;&lt;br&gt;
  updatedAt:&lt;/code&gt;string;&lt;br&gt;
}`&lt;/p&gt;

&lt;p&gt;&lt;code&gt;// Assessments&lt;br&gt;
interface Assessment {&lt;br&gt;
  id: string;&lt;br&gt;
  patientId: string;&lt;br&gt;
  images: string[]; // base64 locally, URLs when synced&lt;br&gt;
  condition: string;&lt;br&gt;
  confidence: number;&lt;br&gt;
  urgency: 'green' | 'yellow' | 'red';&lt;br&gt;
  possibleConditions: Array&amp;lt;{ name: string; probability: number }&amp;gt;;&lt;br&gt;
  recommendation: string;&lt;br&gt;
  referralStatus: 'none' | 'pending' | 'active' | 'resolved';&lt;br&gt;
  language: string;&lt;br&gt;
  createdAt: string;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yr5v8uf5519ef47grsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yr5v8uf5519ef47grsy.png" alt=" " width="800" height="626"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvsew5vgblxxch9b46kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvsew5vgblxxch9b46kg.png" alt=" " width="800" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A background sync engine processes a queue when connectivity returns, uploading records to Supabase with last-write-wins conflict resolution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voice-Guided Assessments&lt;/strong&gt;&lt;br&gt;
Using the Web Speech API for both synthesis and recognition, the app supports 7 languages. The voice flow is a dynamic conversation tree:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;"Who is the patient? Say the ID number."&lt;/li&gt;
&lt;li&gt;Patient responds → parsed for identifier&lt;/li&gt;
&lt;li&gt;"Frame the affected area in the camera."&lt;/li&gt;
&lt;li&gt;Photo captured → analyzed&lt;/li&gt;
&lt;li&gt;"The assessment shows [condition] with [confidence]% confidence."&lt;/li&gt;
&lt;li&gt;Dynamic follow-ups based on the result
The conversation state is persistable — if the CHW is interrupted, they can resume where they left off.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Medical Document Analysis&lt;/strong&gt;&lt;br&gt;
The same Gemma 4 model handles document analysis through carefully crafted prompts. The system prompt instructs the model to:&lt;/p&gt;

&lt;p&gt;Extract structured findings from lab reports&lt;br&gt;
Highlight abnormal values&lt;br&gt;
Generate plain-language explanations&lt;br&gt;
Classify the document type (lab report, prescription, referral letter)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Challenges &amp;amp; Solutions&lt;/strong&gt;&lt;br&gt;
Challenge 1: Model Loading Time&lt;br&gt;
The 1.5GB model download on first visit is painful. We show a progress bar with percentage and estimated time, and cache aggressively via the service worker. On subsequent visits, the model loads from cache in ~5 seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge 2:&lt;/strong&gt; WebGPU Availability&lt;br&gt;
WebGPU is currently Chrome-only on desktop and Android. We detect availability upfront and show a clear message if it's not available, guiding users to Ollama or demo mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge 3:&lt;/strong&gt; Voice Recognition Accuracy&lt;br&gt;
Speech recognition in rural environments (noisy, varying accents) is unreliable. We implemented a hybrid approach: voice input plus a text fallback. Users can speak or type answers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge 4:&lt;/strong&gt; Hallucination Risk&lt;br&gt;
Like all LLMs, Gemma 4 can hallucinate. Every assessment includes:&lt;/p&gt;

&lt;p&gt;A confidence score (0-100%)&lt;br&gt;
Differential diagnoses with probability breakdown&lt;br&gt;
An auto-suggestion to refer when confidence &amp;lt; 70%&lt;br&gt;
A prominent medical disclaimer&lt;br&gt;
The Stack&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frontend:&lt;/strong&gt; React 19, TanStack Start (SSR), Vite&lt;br&gt;
AI: WebLLM + WebGPU (Gemma 4 E2B), Ollama fallback&lt;br&gt;
Styling: Tailwind CSS v4, shadcn/ui&lt;br&gt;
Offline Storage: Dexie.js (IndexedDB)&lt;br&gt;
Voice: Web Speech API&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend:&lt;/strong&gt; Supabase (Auth, PostgreSQL, Storage, RLS)&lt;br&gt;
PWA: vite-plugin-pwa (installable on Android/iOS)&lt;br&gt;
PDF Generation: jsPDF + qrcode&lt;br&gt;
Try It&lt;br&gt;
The app is live and free to use:&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://trij.vercel.app" rel="noopener noreferrer"&gt;https://trij.vercel.app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No account needed — you can use demo mode immediately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Open Source&lt;/strong&gt;&lt;br&gt;
Trij is Apache 2.0. Contributions welcome:&lt;/p&gt;

&lt;p&gt;🐙 &lt;a href="https://github.com/Mosss-OS/trij" rel="noopener noreferrer"&gt;https://github.com/Mosss-OS/trij&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We need help with:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Additional language packs&lt;/li&gt;
&lt;li&gt;UI/UX polish&lt;/li&gt;
&lt;li&gt;Real-world testing&lt;/li&gt;
&lt;li&gt;Clinical validation&lt;/li&gt;
&lt;li&gt;Performance optimization&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What's Next&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ffline map tiles for the supervisor view&lt;/li&gt;
&lt;li&gt;PWA background sync for iOS&lt;/li&gt;
&lt;li&gt;More granular condition classification&lt;/li&gt;
&lt;li&gt;Integration with common health record systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📧 &lt;a href="mailto:triij.app@gmail.com"&gt;triij.app@gmail.com&lt;/a&gt; 🐦 &lt;a href="https://x.com/Trij_app" rel="noopener noreferrer"&gt;https://x.com/Trij_app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open Source&lt;br&gt;
Trij is Apache 2.0. Contributions welcome:&lt;/p&gt;

&lt;p&gt;🐙 &lt;a href="https://github.com/Mosss-OS/trij" rel="noopener noreferrer"&gt;https://github.com/Mosss-OS/trij&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need help with:&lt;/p&gt;

&lt;p&gt;Additional language packs&lt;br&gt;
UI/UX polish&lt;br&gt;
Real-world testing&lt;br&gt;
Clinical validation&lt;br&gt;
Performance optimization&lt;br&gt;
What's Next&lt;br&gt;
Offline map tiles for the supervisor view&lt;br&gt;
PWA background sync for iOS&lt;br&gt;
More granular condition classification&lt;br&gt;
Integration with common health record systems&lt;br&gt;
Built for the Gemma 4 Good Hackathon (Kaggle x Google DeepMind). Track: Health &amp;amp; Sciences / Global Resilience.&lt;/p&gt;

&lt;p&gt;📧 &lt;a href="mailto:triij.app@gmail.com"&gt;triij.app@gmail.com&lt;/a&gt; 🐦 &lt;a href="https://x.com/Trij_app" rel="noopener noreferrer"&gt;https://x.com/Trij_app&lt;/a&gt;&lt;/p&gt;

</description>
      <category>agents</category>
      <category>opensource</category>
      <category>react</category>
      <category>healthcare</category>
    </item>
  </channel>
</rss>
