<🚧Under Construction🚧>
AI-Assisted Rural PHC Operating System & Triage Queue
⚠️ CLINICAL DISCLAIMER: Sanjeevani OS is an AI-assisted triage and workflow optimization tool. The AI DOES NOT DIAGNOSE OR PRESCRIBE. The final medical decision and legal liability always remain with the certified human doctor.
| Service Component | Live URL | Tech Stack |
|---|---|---|
| 🤒 Patient Intake Portal | Open Patient UI | React + Vite, Tailwind CSS |
| 👨⚕️ Doctor Dashboard | Open Doctor UI | React + Vite, WebSockets |
| 🧠 AI Triage Agent API | View API Docs | Python, FastAPI, Groq LPU |
| ⚙️ Core Backend Hub | View Health Check | Node.js, Express, SQLite |
Free-tier cloud instances may take ~45 seconds to spin up from a cold sleep — please allow the first request to process.
In rural India, the doctor-to-patient ratio heavily burdens Primary Health Centres (PHCs). Doctors spend up to 80% of consultation time gathering basic medical history instead of actually treating patients.
Sanjeevani OS fixes this by:
- Offloading repetitive patient intake to a conversational AI agent
- Passing every AI output through a deterministic safety layer before it ever reaches a doctor
- Organizing patients into a live, severity-based priority queue doctors can act on instantly
To guarantee zero latency and prevent any single component from blocking the rest of the system, AI processing is fully decoupled from the core backend. The Node.js server acts as the central hub for all WebSocket and REST traffic.
graph TD
classDef frontend fill:#1e1e1e,stroke:#00e5ff,stroke-width:2px,color:#fff;
classDef backend fill:#1e1e1e,stroke:#39ff14,stroke-width:2px,color:#fff;
classDef ai fill:#1e1e1e,stroke:#ff003c,stroke-width:2px,color:#fff;
classDef db fill:#1e1e1e,stroke:#f0f0f0,stroke-width:2px,color:#fff;
P([🗣️ Patient Text/Voice]) -->|Web Speech API| F1
F1[📱 Patient PWA<br>React/Vite]:::frontend -->|REST POST /api/cases| B[⚙️ Node.js API Hub<br>Express Server]:::backend
B -->|REST POST /agent/respond| A[🧠 AI Agent Service<br>FastAPI]:::ai
A -->|LLM Chat & Extraction| G[(Groq LPU<br>Llama 3.3 70B)]:::ai
G -->|Structured JSON Summary| A
A -->|Structured Data| B
B -->|Persists Data| DB[(🗄️ SQLite / PostgreSQL)]:::db
B -->|⚡ WebSocket: NEW_CASE| F2[💻 Doctor Dashboard<br>React/Vite]:::frontend
F2 -->|Reviews XAI Scorecard| MD([👨⚕️ Medical Decision])
MD -->|Submits Prescription| B
B -->|⚡ WebSocket: UPDATE| F1
We built this system by acknowledging real-world failure modes and neutralizing them at the architectural level — not with prompt engineering alone.
| Identified Risk | Sanjeevani OS Architectural Solution |
|---|---|
| Low bandwidth in villages | Dropped heavy video streaming. Ultra-fast Groq LPU inference cuts AI response latency from ~3.0s to ~350ms. |
| LLM hallucination | AI extraction is fully decoupled from medical action. The LLM strictly outputs a rigid JSON payload via a dedicated <<<SUMMARY>>> regex parser — no free-form data ever reaches the database. |
| Triage inaccuracy | A rule-based safety layer sits on top of the LLM. Fatal keywords (e.g. "chest pain", "severe bleeding", "can't breathe") instantly trigger an emergency escalation, bypassing the standard queue entirely. |
| Alert fatigue for doctors | High-priority tags are strictly capped to clinically-defined critical anomalies. The dashboard stays actionable and color-coded, never noisy. |
The patient interface never talks to the AI model directly — every request is proxied through the Node backend, which protects API keys and enforces rate limits.
sequenceDiagram
autonumber
participant P as Patient UI
participant Hub as Node.js Backend
participant AI as FastAPI Agent
participant DB as Database
participant D as Doctor UI
P->>Hub: POST /api/cases/chat (Symptoms)
activate Hub
Hub->>AI: Forward payload to /agent/respond
activate AI
Note right of AI: Groq Llama 3.3 extracts<br>duration, severity, urgency
AI-->>Hub: Returns structured JSON
deactivate AI
Hub->>DB: Save case & status
Hub-->>P: Status: "Agent is reviewing..."
Hub->>D: ⚡ WebSocket (Alert: NEW_CASE)
deactivate Hub
activate D
Note right of D: Doctor reviews summary & raw chat
D->>Hub: POST /api/cases/{id}/decision
deactivate D
activate Hub
Hub->>DB: Update case (prescription added)
Hub->>P: ⚡ WebSocket (Alert: REVIEWED)
deactivate Hub
| Layer | Tech |
|---|---|
| Frontend (Patient & Doctor) | React, Vite, Tailwind CSS |
| Core Backend (The Hub) | Node.js, Express.js |
| AI Microservice | Python, FastAPI, Pydantic |
| AI Model & Compute | Llama-3.3-70B on Groq LPU hardware |
| Real-Time Comms | WebSockets (wss://) for live triage queue updates |
| Database | Better-SQLite3 (dev) → PostgreSQL (production-ready) |
The full stack runs across 4 separate terminals simultaneously — one per service. Open each terminal, cd into the project root first, then follow the block for that terminal.
💡 Type each command and press Enter individually — don't paste multiple lines at once, especially on Windows PowerShell, to avoid commands getting garbled together.
Windows (PowerShell):
cd backend/agent-service
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
$env:GROQ_API_KEY = "your_groq_key_here"
uvicorn main:app --port 8001macOS / Linux:
cd backend/agent-service
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export GROQ_API_KEY="your_groq_key_here"
uvicorn main:app --port 8001✅ Success looks like: Uvicorn running on http://127.0.0.1:8001
Windows & macOS/Linux (same):
cd backend
npm install
npm run dev✅ Success looks like: RuralCare backend running on http://localhost:4000
cd patient-frontend
npm install
npm run dev✅ Runs at http://localhost:5173 (or the next free port)
cd doctor-frontend
npm install
npm run dev✅ Runs at http://localhost:5174 (or the next free port)
| File | Needed? | What goes in it |
|---|---|---|
backend/agent-service/.env (optional) |
Set GROQ_API_KEY here for convenience, or export it per terminal session as shown above |
GROQ_API_KEY=gsk_... |
patient-frontend/.env |
Required — copy from .env.example |
VITE_API_URL=http://localhost:4000VITE_WS_URL=ws://localhost:4000 |
doctor-frontend/.env |
Required — copy from .env.example |
VITE_API_URL=http://localhost:4000VITE_WS_URL=ws://localhost:4000 |
AGENT_URL only needs to be set on the backend when the agent service is not running at the default http://localhost:8001.
.env files or API keys. They're already git-ignored — keep it that way.
Architected for scale. Built for rural India. Developed for Smart India Hackathon 2026.