Skip to content

About

NeuroTriage is a mobile-first PWA delivering AI-powered health triage for rural communities. It supports voice input in 4 languages, works online with Gemini AI and offline via rule-based logic, provides medicine guidance, urgency classification, appointment booking, and one-tap emergency SOS access for patients, doctors, and health workers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NeuroTriage — AI-Powered Health Triage for Rural Communities

Version: 1.0
Platform: Progressive Web App (Mobile-First)
Stack: React + TypeScript + Vite + Tailwind CSS + Lovable Cloud


📋 Table of Contents

  1. Overview
  2. Problem Statement
  3. Architecture
  4. User Roles & Dashboards
  5. Core Features
  6. Technology Stack
  7. Data Flow
  8. Offline Capabilities
  9. AI Integration
  10. Database Schema
  11. File Structure
  12. Security
  13. Future Roadmap

Overview

NeuroTriage is a mobile-first health application designed to bring AI-powered medical triage, consultation, and emergency assistance to underserved rural communities. It works both online (AI-enhanced) and offline (rule-based fallback), ensuring critical health features remain accessible regardless of network connectivity.

Key Value Propositions

  • 🧠 AI-Powered Diagnosis — Gemini AI analyzes symptoms and provides specific medicine recommendations with dosages
  • 🗣️ Voice-First Interface — Speech-to-text symptom intake in 4 languages (English, Hindi, Tamil, Telugu)
  • 📴 Offline Resilient — Core triage and medical knowledge base work without internet
  • 🔋 Battery Aware — Automatically switches to lighter AI models on low battery
  • 🚨 Emergency SOS — One-tap emergency calls with GPS-based hospital finder
  • 📅 Appointment Booking — In-chat appointment scheduling through MedBot AI

Problem Statement

In rural India, patients face:

  1. Limited access to doctors — Often 1 doctor per 10,000+ people
  2. Language barriers — Many patients speak only regional languages
  3. Poor connectivity — Intermittent or no internet in remote areas
  4. Low digital literacy — Need for voice-first, simple interfaces
  5. Delayed emergency response — No structured triage before hospital visits

NeuroTriage addresses all five by providing an AI medical assistant that speaks local languages, works offline, and triages symptoms to appropriate urgency levels.


Architecture

┌─────────────────────────────────────────────────┐
│                  FRONTEND (React)                │
│                                                  │
│  Landing → Role Selection → Role Dashboard       │
│                                                  │
│  ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │
│  │ Voice    │ │ MedBot   │ │ Appointment      │ │
│  │ Triage   │ │ AI Chat  │ │ Booking          │ │
│  └────┬─────┘ └────┬─────┘ └────────┬─────────┘ │
│       │             │                │           │
│  ┌────▼─────────────▼────────────────▼─────────┐ │
│  │         Zustand State Management            │ │
│  │  (roles, profiles, triage history)          │ │
│  └─────────────────────────────────────────────┘ │
└──────────────────────┬──────────────────────────┘
                       │
            ┌──────────▼──────────┐
            │   Lovable Cloud     │
            │   (Supabase)        │
            │                     │
            │  ┌───────────────┐  │
            │  │ Edge Functions │  │
            │  │               │  │
            │  │ medical-chat  │  │
            │  │ (Gemini AI)   │  │
            │  └───────────────┘  │
            │                     │
            │  ┌───────────────┐  │
            │  │  Database     │  │
            │  │               │  │
            │  │ appointments  │  │
            │  └───────────────┘  │
            └─────────────────────┘

User Roles & Dashboards

1. 🧑‍🤒 Patient Dashboard (/dashboard)

The primary user. Features include:

Feature Description
Quick Triage One-tap access to AI voice triage
MedBot Chat AI medical assistant with streaming responses
Health Records View triage history and past consultations
Emergency SOS One-tap emergency call with GPS hospital finder
Profile Patient demographics, blood group, allergies

2. 🩺 Doctor Dashboard (/dashboard as doctor)

For healthcare professionals reviewing cases:

Feature Description
Patient Queue View triaged cases by urgency
Appointments Real-time incoming appointment list with Accept/Confirm
Case Stats Total cases, pending appointments, emergencies
Referrals Cases referred from health workers
Video Consult Telemedicine consultation link

3. 🏥 Health Worker Dashboard (/dashboard as health_worker)

For community health workers doing field triage:

Feature Description
Community Stats Triage summary for the community
Field Triage Quick symptom assessment tools
Emergency Alerts Critical cases needing escalation
Patient Registry Community patient tracking

Core Features

1. AI Voice Triage (/triage)

How it works:

  1. Patient taps the microphone button and speaks symptoms in any supported language
  2. Web Speech API converts voice to text
  3. Online: Gemini AI analyzes symptoms → returns structured JSON with urgency level, possible conditions, and specific medicine recommendations
  4. Offline: Expanded rule-based engine with 20+ condition patterns matches symptoms against known patterns
  5. Results displayed with color-coded urgency (🟢 Safe / 🟡 Consult / 🔴 Emergency)

Urgency Classification:

Level Color Action
Safe 🟢 Green Home care with OTC medicines
Consult 🟡 Yellow Book doctor appointment within 24-48hrs
Emergency 🔴 Red Go to hospital NOW, call 112/108

2. MedBot AI Chat (/medbot)

An intelligent medical chatbot that:

  • Asks 2-3 follow-up questions before diagnosing
  • Provides specific medicine names with dosages (e.g., "Paracetamol 500mg, twice daily after food")
  • Supports 4 languages: English, Hindi (हिन्दी), Tamil (தமிழ்), Telugu (తెలుగు)
  • Works in text mode and voice-to-voice mode (Web Speech API)
  • Detects appointment booking intent and shows inline booking form
  • Streams responses in real-time via Server-Sent Events (SSE)

Battery-Aware AI:

  • Normal battery → google/gemini-3-flash-preview (full capability)
  • Low battery (<20%) → google/gemini-2.5-flash-lite (faster, lighter)

3. Appointment Booking (In-Chat)

Triggered when patient types "book appointment" or related keywords in MedBot:

  • Patient name, age, gender (pre-filled from profile)
  • Doctor specialty selection (General, Pediatrics, Gynecology, etc.)
  • Date picker and time slot grid
  • Symptoms auto-attached from chat context
  • Saved to database → appears in Doctor Dashboard in real-time

4. Emergency SOS (/emergency)

  • Call Emergency (112) — National emergency number
  • Call Ambulance (108) — Ambulance service
  • Find Nearest Hospital — GPS-based Google Maps hospital search
  • Pulsing red animation for urgency
  • Accessible from every screen via Emergency Button

5. Voice-to-Voice Mode

Full conversational loop using browser-native APIs:

🎙️ Listen (SpeechRecognition)
    → 🧠 Process (Gemini AI via Edge Function)
        → 🔊 Speak (SpeechSynthesis)
            → 🎙️ Listen again (continuous loop)

Supports language-specific voices for Hindi, Tamil, and Telugu.


Technology Stack

Layer Technology Purpose
Frontend React 18 + TypeScript UI framework
Bundler Vite Fast development & builds
Styling Tailwind CSS + shadcn/ui Design system
State Zustand Global state management
Animation Framer Motion Smooth transitions
Routing React Router v6 Client-side navigation
Backend Lovable Cloud (Supabase) Database + Edge Functions
AI Google Gemini (via Lovable AI Gateway) Medical reasoning
Voice Input Web Speech API (SpeechRecognition) Browser-native STT
Voice Output Web Speech API (SpeechSynthesis) Browser-native TTS
Markdown react-markdown Render AI chat responses

Data Flow

Triage Flow

Patient speaks symptoms
        │
        ▼
  SpeechRecognition API
        │
        ▼
  Text extracted
        │
        ├── Online? ──► Edge Function (medical-chat)
        │                     │
        │                     ▼
        │               Gemini AI analyzes
        │                     │
        │                     ▼
        │              Structured JSON result
        │                     │
        └── Offline? ──► Local triage-engine.ts
                              │
                              ▼
                     Pattern matching (20+ conditions)
                              │
                              ▼
                      TriageResult displayed
                              │
                              ▼
                    Saved to Zustand store

Appointment Flow

Patient says "book appointment" in MedBot
        │
        ▼
  Keyword detection triggers booking form
        │
        ▼
  Patient fills: name, date, time, doctor type
        │
        ▼
  Saved to Supabase `appointments` table
        │
        ▼
  Real-time update → Doctor Dashboard
        │
        ▼
  Doctor clicks "Accept" → status: confirmed

Offline Capabilities

Feature Online Offline
Voice Triage AI-powered (Gemini) Rule-based (20+ patterns)
MedBot Chat Streaming AI responses Offline medical knowledge base
Emergency SOS Full functionality GPS + direct phone calls
Appointment Booking ✅ Saves to database ❌ Requires internet
Voice Input ✅ SpeechRecognition ✅ SpeechRecognition
Voice Output ✅ SpeechSynthesis ✅ SpeechSynthesis

The offline medical knowledge base (src/lib/offline-medical-kb.ts) contains pre-written responses for common symptoms including fever, headache, stomach issues, skin problems, and more — with home remedies and OTC medicine suggestions.


AI Integration

Edge Function: medical-chat

Endpoint: POST /functions/v1/medical-chat

Request:

{
  "messages": [{"role": "user", "content": "I have fever"}],
  "language": "en",
  "lightweight": false
}

Behavior:

  • System prompt instructs the AI to act as "MedBot" — a rural medical assistant
  • Asks 2-3 follow-up questions before suggesting medicine
  • No disclaimers — direct, practical advice
  • Responds in the selected language regardless of input language
  • Streams response via SSE (Server-Sent Events)

Models Used:

Condition Model
Normal battery google/gemini-3-flash-preview
Low battery (<20%) google/gemini-2.5-flash-lite
Triage classification google/gemini-2.5-flash-lite

Database Schema

appointments Table

Column Type Description
id UUID (PK) Auto-generated
patient_name TEXT Required
patient_age TEXT Optional
patient_gender TEXT Optional
symptoms TEXT Auto-filled from chat
preferred_date DATE Required
preferred_time TEXT Required
doctor_type TEXT Default: "General"
status TEXT "pending" or "confirmed"
created_at TIMESTAMPTZ Auto-set

Real-time: Enabled via supabase_realtime publication for live updates to Doctor Dashboard.


File Structure

src/
├── components/
│   ├── AppointmentBooking.tsx    # In-chat booking form
│   ├── BottomNav.tsx             # Tab navigation
│   ├── EmergencyButton.tsx       # SOS button component
│   ├── LanguageSelector.tsx      # EN/HI/TA/TE picker
│   ├── MobileLayout.tsx          # Mobile viewport wrapper
│   ├── VoiceMode.tsx             # Voice-to-voice conversation
│   └── ui/                      # shadcn/ui components
│
├── hooks/
│   ├── use-battery.ts            # Battery level detection
│   └── use-mobile.tsx            # Mobile viewport detection
│
├── lib/
│   ├── offline-medical-kb.ts     # Offline symptom responses
│   ├── store.ts                  # Zustand global state
│   ├── triage-engine.ts          # Hybrid AI + rule-based triage
│   └── utils.ts                  # Utility functions
│
├── pages/
│   ├── Landing.tsx               # Role selection screen
│   ├── Dashboard.tsx             # Patient dashboard
│   ├── DoctorDashboard.tsx       # Doctor dashboard + appointments
│   ├── HealthWorkerDashboard.tsx  # CHW dashboard
│   ├── MedBot.tsx                # AI chat interface
│   ├── Triage.tsx                # Voice triage screen
│   ├── Emergency.tsx             # Emergency SOS screen
│   ├── Records.tsx               # Health records
│   ├── Profile.tsx               # User profile
│   └── Consultation.tsx          # Telemedicine placeholder
│
├── integrations/supabase/
│   ├── client.ts                 # Supabase client (auto-generated)
│   └── types.ts                  # Database types (auto-generated)
│
└── App.tsx                       # Routes + role-based dashboard logic

supabase/functions/
├── medical-chat/index.ts         # AI chat edge function (Gemini)
└── elevenlabs-conversation-token/index.ts  # Voice agent token

Security

Measure Implementation
API Keys Stored as server-side secrets (never in client code)
AI Gateway Requests proxied through Lovable AI Gateway with auth
Database RLS Row-level security enabled on all tables
CORS Configured on edge functions
Input Sanitization User input processed server-side before AI

Future Roadmap

  • User Authentication — Email/phone login for persistent profiles
  • Patient-Doctor Video Calls — WebRTC telemedicine consultations
  • Prescription Generation — Doctors can issue digital prescriptions
  • Health Worker GPS Tracking — Field worker route optimization
  • SMS Alerts — Appointment confirmations via SMS for non-smartphone users
  • PWA Installation — Full offline-first PWA with service worker caching
  • Multi-language Voice Triage — Language selector on triage page
  • Community Health Analytics — Dashboard with disease trend charts
  • Bluetooth Relay — Mesh networking for areas with zero connectivity

Quick Start

  1. Open the app → Select your role (Patient / Doctor / Health Worker)
  2. Patient: Tap "Voice Triage" → Speak symptoms → Get AI diagnosis
  3. Patient: Open "MedBot" → Chat about symptoms → Book appointment
  4. Doctor: View incoming appointments → Accept/Confirm
  5. Emergency: Tap the red SOS button from any screen → Call 112/108

Built with ❤️ for rural healthcare accessibility

About

NeuroTriage is a mobile-first PWA delivering AI-powered health triage for rural communities. It supports voice input in 4 languages, works online with Gemini AI and offline via rule-based logic, provides medicine guidance, urgency classification, appointment booking, and one-tap emergency SOS access for patients, doctors, and health workers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages