$ cd ~/projects

Curago

updated 13 days agosource

// how it works

> **Curago** is an end-to-end "Phygital" (Physical + Digital) healthcare platform built to bring primary healthcare, intelligent voice triage, real-time doctor oversight, and last-mile medicine delivery to rural and underserved communities. --- ## The 4-Phase Care Delivery Flow ```mermaid flowchart LR A[ 1. Voice Intake\nPatient Calls In] --> B[ 2. AI Triage\nGroq / NIM Extraction] B --> C[‍️ 3. Doctor Dashboard\nReview & Approve] C --> D[ 4. Last-Mile Logistics\nField Agent Delivery] D --> E[ 5. Auto Follow-up\nSMS Check-in or AI Voice Call] E --> F[ 6. Physical Vital

Curago is an end-to-end "Phygital" (Physical + Digital) healthcare platform built to bring primary healthcare, intelligent voice triage, real-time doctor oversight, and last-mile medicine delivery to rural and underserved communities.


The 4-Phase Care Delivery Flow

flowchart LR
    A[ 1. Voice Intake\nPatient Calls In] --> B[ 2. AI Triage\nGroq / NIM Extraction]
    B --> C[‍️ 3. Doctor Dashboard\nReview & Approve]
    C --> D[ 4. Last-Mile Logistics\nField Agent Delivery]
    D --> E[ 5. Auto Follow-up\nSMS Check-in or AI Voice Call]
    E --> F[ 6. Physical Vitals Check\nTrainee Escalates to Doctor]

1. ️ Multilingual Voice AI Intake

  • Patients call a single toll-free helpline.
  • Powered by Vapi / Twilio / Sarvam AI / Groq LLaMA 3.3 70B.
  • Speaks and understands regional languages (Marathi, Hindi, English).
  • Cross-examines patients sequentially (symptoms, duration, age, village) and detects emergency severity.
  • See the exact AI instructions here: Vapi System Prompt

2. Realtime Doctor & Trainee Dashboard

  • Instant Triage Queue: Incoming patient tickets populate in real-time via Supabase Realtime.
  • AI-Recommended Medicines: Suggests prescriptions matched to available local inventory (L1/L2 stock).
  • One-Click Approval & Dispatch: Doctors can approve prescriptions, adjust dosages, or trigger an instant call-back.
  • Specialist Camp Escalation: Severe or unresolvable cases are directly escalated to upcoming physical specialist health camps.

3. Last-Mile Delivery (Flutter Field App)

  • Field agents and village trainees receive approved prescription dispatch orders.
  • Dynamic inventory routing:
    • L1 (Village Level): Common over-the-counter and essential medicines.
    • L2 (Cluster Level): Temperature-sensitive or advanced medicines.
    • L3 (District Level): Specialized therapeutics.
  • Built-in payment collection (Cash, Pre-paid, Digital QR).

4. Resolution & Automated Safety Net

  • SMS Follow-ups: Automated SMS triggers verify recovery. If the patient replies "NO", a trainee is auto-assigned for an in-person vitals check.
  • Context-Aware AI Calls: Patients calling the helpline for follow-ups are identified. Vapi queries the get_patient_history tool so the AI dynamically remembers their past symptoms.
  • Vitals Escalation: When a trainee inputs patient vitals via the Field App, Groq AI diagnoses the severity. If critical, the ticket is instantly escalated back to doctor_review on the Doctor Dashboard.

️ Architecture

flowchart TD
    subgraph Voice ["️ Voice & Telephony Layer"]
        P[Patient Phone] <--> Twilio[Twilio / Telephony]
        Twilio <--> Vapi[Vapi Voice AI / STT / TTS]
    end

    subgraph Backend [" Backend & AI Intelligence"]
        Vapi -->|Tool: get_patient_history| Fast["FastAPI Backend (:8002)"]
        Vapi -->|End-of-Call Webhook| Fast
        Fast <--> Groq["Groq LLaMA 3.3 70B (Extraction & Vitals Diag)"]
        Fast <--> RAG["Gemini Embeddings (Medical Guidelines RAG)"]
        Twilio <-->|SMS Webhooks| Fast
    end

    subgraph Data ["️ Database & Realtime"]
        Fast <--> DB[("Supabase PostgreSQL + pgvector")]
    end

    subgraph Frontends [" Applications & Dashboards"]
        DB <-->|Realtime Sync| DoctorDash["Doctor & Trainee Dashboard (React/Vite)"]
        DB <--> FlutterApp["Curago Field App (Flutter)"]
        DoctorDash -->|Approve & Trigger Order| Fast
        FlutterApp -->|Submit Vitals| Fast
    end

Repository Structure

curago/
├── backend/                  # FastAPI Python Backend
│   ├── app/
│   │   ├── core/             # Supabase & environment configuration
│   │   ├── routers/          # Webhooks, Doctor, Trainee, Orders endpoints
│   │   └── services/         # LLM extraction, Gemini RAG, SMS services
│   ├── main.py               # Application entry point
│   ├── total_monitor.py      # Real-time webhook & database diagnostic monitor
│   └── requirements.txt      # Python dependencies
│
├── frontend/                 # React 18 + Vite Web Application
│   ├── src/
│   │   ├── pages/            # DoctorDashboard, TraineeDashboard, LoginLanding
│   │   └── lib/              # Supabase client & state management
│   ├── package.json
│   └── vite.config.js
│
├── curago_field_app/         # Flutter Mobile Application
│   ├── lib/                  # Delivery management & payment screens
│   └── pubspec.yaml
│
└── docs/                     # Architecture diagrams & technical specifications

Quickstart & Local Setup

Prerequisites

  • Python 3.10+
  • Node.js 18+ & npm
  • Flutter SDK (for the delivery app)
  • Supabase Account & Groq / OpenAI API Keys

1. Backend Setup

cd backend

# Create & activate virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1   # On Windows
# source venv/bin/activate    # On Linux/macOS

# Install dependencies
pip install -r requirements.txt

# Create .env file with your credentials
# (SUPABASE_URL, SUPABASE_KEY, GROQ_API_KEY, GEMINI_API_KEY, etc.)

# Start FastAPI server
uvicorn app.main:app --port 8002 --reload

2. Frontend Setup (Doctor & Trainee Dashboard)

cd frontend

# Install dependencies
npm install

# Start Vite dev server
npm run dev

Open **local dev server in your browser.

Demo Credentials:

Role Email Password
Doctor doctor@curago.com Password123!
Trainee trainee@curago.com Password123!

3. Curago Field Mobile App (Flutter)

cd curago_field_app

# Get dependencies
flutter pub get

# Run on emulator / connected device
flutter run

4. Realtime Diagnostic Monitor

To monitor live voice webhook payloads, Groq data extractions, and Supabase ticket creation in real-time:

cd backend
python total_monitor.py

️ Cloud Deployment (Render Free Tier)

Curago Backend is configured for easy 1-click deployment on Render.

  1. Create a free account on Render.com.
  2. Click New -> Blueprint.
  3. Connect your GitHub repository. Render will automatically detect the render.yaml file.
  4. Click Apply.
  5. Go to your new Web Service dashboard -> Environment and add the following keys from your .env:
    • SUPABASE_URL
    • SUPABASE_KEY
    • GEMINI_API_KEY
    • NVIDIA_NIM_API_KEY
    • GROQ_API_KEY
    • TWILIO_ACCOUNT_SID
    • TWILIO_AUTH_TOKEN
    • TWILIO_PHONE_NUMBER

Note on Cold Starts: Render's free tier spins down after 15 minutes of inactivity. To ensure Vapi calls don't timeout during a cold start, set up a free pinging service (like cron-job.org) to hit your https://<YOUR-RENDER-URL>.onrender.com/ endpoint every 10 minutes.


Data Science Module (ds/)

Datasets Used (all publicly available)

Dataset Source License Usage
NHAMCS ED 2019 CDC/NCHS FTP US Public Domain Triage severity classifier training
Pharma Sales Data Kaggle CC-BY-NC 4.0 Medicine demand forecasting (notebook-only)
IncOVID19 District Data data.incovid19.org Open Outbreak anomaly detection (if used)

External Tools Acknowledged

Tool Purpose Our Contribution
Groq/OpenAI LLM inference for symptom extraction We built the extraction prompt, fallback chain, and JSON parser
Vapi Voice AI for patient calls We designed the system prompt, tool-call integration, and webhook pipeline
Supabase Database + vector search We designed the schema, RAG pipeline, and all queries
Google Gemini Embeddings for RAG We built the knowledge base and similarity search

Our Contribution (what we built vs external)

  1. Triage Severity Classifier: Trained on real CDC NHAMCS data (n=~25,000), XGBoost with class weighting, 5-fold CV, SHAP explainability. Under-triage rate measured and reported.
  2. Outbreak Detection: Statistical z-score anomaly detection on ticket clusters by village, with alert severity levels.
  3. End-to-End System: Voice call → AI triage → Doctor dashboard → Medicine ordering → Delivery tracking. Every integration point is our code.
  4. Data Flywheel Architecture: Models retrain on Curago's own ticket data as it accumulates. CDC/Kaggle data demonstrates the pipeline; production data improves it.

Reproducing Results

cd ds
pip install -r requirements.txt
jupyter notebook notebooks/01_triage_severity.ipynb  # Kernel → Restart & Run All

Security & Privacy

  • Data Isolation: Patient identifiable information (PII) is encrypted and access-controlled through Supabase Row-Level Security (RLS).
  • Environment Safety: All API keys, database credentials, and session tokens are strictly managed via environment variables and excluded from version control.

License

This project was developed for healthcare hackathon demonstration purposes.

// stack

FastAPIReactSupabaseFlutterGroqVapiTwilio