Skip to content

bm0213/Swasthyapath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ SwasthyaPath β€” AI-Powered Emergency Response System

SwasthyaPath React Node.js MongoDB Claude AI

An AI-powered emergency medical triage system designed for rural India.
Describe symptoms in any language β†’ Get instant AI triage β†’ Find the nearest hospital.

🌐 Live Demo: swasthyapath-orcin.vercel.app


✨ Features

  • πŸ€– AI Triage β€” Claude AI analyzes symptoms in multiple languages and assesses severity (Critical / Urgent / Moderate)
  • πŸ—ΊοΈ Real GPS + Live Map β€” Finds nearest hospitals using real-time location with Leaflet maps
  • πŸš‘ Ambulance Live Tracking β€” Patient and ambulance share live locations visible on the map in real time
  • πŸ’¬ Doctor Chat β€” Real-time chat between patient and volunteer doctor via Socket.io rooms
  • πŸ“Ή Video Call β€” WebRTC-powered video consultation between patient and doctor
  • 🩹 First Aid Guide β€” Step-by-step offline first aid for 10 emergencies (Heart Attack, Snake Bite, Burns, Drowning, Choking, Fracture, Seizure, Bleeding, Unconscious, Road Accident)
  • πŸ“‹ My Triage History β€” Users can view their past triage records stored locally
  • πŸ” Admin Dashboard β€” Protected admin login with full stats, severity breakdown, symptom trends and recent activity
  • πŸ“΄ Offline Mode β€” Cached hospital data and First Aid Guide work without internet connection
  • 🌍 Multi-language β€” Supports English, Hindi, Tamil, Telugu, Bengali, Marathi
  • πŸ†˜ SOS Button β€” One-tap emergency call with location sharing
  • πŸ“± PWA Ready β€” Installable on mobile devices

πŸ› οΈ Tech Stack

Frontend

Technology Purpose
React 18 + Vite UI framework
Leaflet + React-Leaflet Interactive maps
Socket.io Client Real-time communication
WebRTC Video calls

Backend

Technology Purpose
Node.js + Express REST API server
Socket.io Real-time rooms & chat
Anthropic Claude AI AI-powered symptom triage
MongoDB Atlas + Mongoose Persistent database
Dotenv Environment variables

Deployment

Service Purpose
Vercel Frontend hosting
Render Backend hosting
MongoDB Atlas Cloud database

πŸš€ Live Demo

Service URL
🌐 Frontend swasthyapath-orcin.vercel.app
βš™οΈ Backend API swasthyapath-backend.onrender.com

βš™οΈ Local Setup

Prerequisites

  • Node.js v18+
  • MongoDB Atlas account (free)
  • Anthropic API key

1. Clone the repository

git clone https://github.com/bm0213/Swasthyapath.git
cd Swasthyapath

2. Setup Backend

cd backend
npm install

Create a .env file inside backend/:

ANTHROPIC_API_KEY=your_anthropic_api_key
PORT=4000
MONGODB_URI=your_mongodb_atlas_connection_string
ADMIN_USERNAME=your_admin_username
ADMIN_PASSWORD=your_admin_password

Start the backend:

npm run dev

3. Setup Frontend

cd ../frontend
npm install

Create a .env file inside frontend/:

VITE_BACKEND_URL=http://localhost:4000

Start the frontend:

npm run dev

4. Open in browser

http://localhost:5173

πŸ“ Project Structure

Swasthyapath/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ triage.js        # AI triage endpoint
β”‚   β”‚   β”œβ”€β”€ admin.js         # Admin stats + login endpoint
β”‚   β”‚   └── hospitals.js     # Hospital proxy endpoint
β”‚   β”œβ”€β”€ db.js                # MongoDB connection + schemas
β”‚   β”œβ”€β”€ index.js             # Express + Socket.io server
β”‚   └── package.json
β”‚
└── frontend/
    └── src/
        β”œβ”€β”€ components/
        β”‚   β”œβ”€β”€ AdminLogin.jsx      # Admin login page
        β”‚   β”œβ”€β”€ UserHistory.jsx     # User triage history
        β”‚   β”œβ”€β”€ DoctorChat.jsx      # Real-time chat + video call
        β”‚   β”œβ”€β”€ VideoCall.jsx       # WebRTC video call
        β”‚   β”œβ”€β”€ HospitalMap.jsx     # Leaflet map + ambulance tracking
        β”‚   β”œβ”€β”€ HospitalList.jsx    # Hospital results list
        β”‚   β”œβ”€β”€ SymptomInput.jsx    # Symptom input form
        β”‚   β”œβ”€β”€ TriageResult.jsx    # AI triage result display
        β”‚   β”œβ”€β”€ SOSButton.jsx       # Emergency SOS
        β”‚   └── ...
        β”œβ”€β”€ pages/
        β”‚   β”œβ”€β”€ AdminDashboard.jsx  # Admin stats dashboard (protected)
        β”‚   β”œβ”€β”€ FirstAid.jsx        # Offline first aid guide
        β”‚   └── Settings.jsx
        β”œβ”€β”€ utils/
        β”‚   β”œβ”€β”€ triage.js           # Claude AI API call
        β”‚   β”œβ”€β”€ socket.js           # Socket.io client
        β”‚   β”œβ”€β”€ location.js         # GPS utilities
        β”‚   β”œβ”€β”€ fetchHospitals.js   # Hospital fetch via backend proxy
        β”‚   └── ...
        └── App.jsx                 # Main app component

🌐 API Endpoints

Method Endpoint Description
POST /api/triage Submit symptoms for AI triage
POST /api/admin/login Admin login
GET /api/admin/stats Get admin dashboard stats
GET /api/hospitals/nearby Fetch nearby hospitals via proxy

Triage Request

{
  "symptoms": "Patient has severe chest pain and difficulty breathing",
  "location": { "lat": 13.0827, "lng": 80.2707 }
}

Triage Response

{
  "severity": "critical",
  "severityLabel": "Critical Emergency",
  "summary": "Symptoms suggest a possible cardiac event.",
  "facilities": ["ICU", "Cardiology", "Ventilator"],
  "doNow": "Keep the patient calm and seated upright. Call 112 immediately."
}

πŸ”Œ Socket.io Events

Event Direction Description
join_room Client β†’ Server Join a chat room
send_message Client β†’ Server Send a chat message
ambulance_location Client β†’ Server Share ambulance GPS
patient_location Client β†’ Server Share patient GPS
call_request Client β†’ Server Request video call
call_accepted Client β†’ Server Accept video call
call_declined Client β†’ Server Decline video call
call_ended Client β†’ Server End video call
webrtc_offer/answer/ice Client β†’ Server WebRTC signaling

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


πŸ‘¨β€πŸ’» Author

bm0213 β€” GitHub


Made with ❀️ for rural India's emergency healthcare

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors