https://github.com/danieladdisonorg/healthcare-ai-voice-agent
A comprehensive full-stack healthcare application that leverages AI-powered voice interactions for patient triage, symptom analysis, specialist mapping, and appointment booking. It is built with modern technologies including FastAPI, PostgreSQL, React, and integrated with leading AI models like Gemini and GPT-4.
https://github.com/danieladdisonorg/healthcare-ai-voice-agent
fastapi gemini gpt-4 langgraph postgreql python razorpay react uvicorn
Last synced: 4 days ago
JSON representation
A comprehensive full-stack healthcare application that leverages AI-powered voice interactions for patient triage, symptom analysis, specialist mapping, and appointment booking. It is built with modern technologies including FastAPI, PostgreSQL, React, and integrated with leading AI models like Gemini and GPT-4.
- Host: GitHub
- URL: https://github.com/danieladdisonorg/healthcare-ai-voice-agent
- Owner: danieladdisonorg
- License: mit
- Created: 2025-06-20T19:08:21.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-06-20T19:28:54.000Z (4 months ago)
- Last Synced: 2025-06-20T20:39:38.828Z (4 months ago)
- Topics: fastapi, gemini, gpt-4, langgraph, postgreql, python, razorpay, react, uvicorn
- Language: JavaScript
- Homepage:
- Size: 69.3 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฉบ AI Healthcare Voice Assistant
A comprehensive full-stack healthcare application that leverages AI-powered voice interactions for patient triage, symptom analysis, specialist mapping, and appointment booking. Built with modern technologies including FastAPI, PostgreSQL, React, and integrated with leading AI models.
---
## ๐ System Architecture & User Flow
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค VOICE-ENABLED USER INTERFACE โ
โ (React Frontend) โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ USER AUTHENTICATION โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ User Login โโโโโถโ FastAPI Backend โโโโโถโ PostgreSQL Database โ โ
โ โ (Email/Password)โ โ sp_login_user โ โ (users table) โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐๏ธ VOICE SYMPTOM COLLECTION โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Web Speech API โโโโโถโ Speech-to-Text โโโโโถโ Symptom Phrases Array โ โ
โ โ (Microphone) โ โ Conversion โ โ ["headache", "fever", ...] โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ค AI-POWERED SYMPTOM ANALYSIS โ
โ (LangGraph Workflow) โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Raw Symptoms โโโโโถโ Gemini/GPT-4 โโโโโถโ Normalized Symptoms โ โ
โ โ Processing โ โ AI Analysis โ โ ["migraine", "pyrexia", ...] โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Specialist โโโโโโ AI Mapping โโโโโโ Symptom Analysis โ โ
โ โ Recommendation โ โ Algorithm โ โ & Classification โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฅ DOCTOR MATCHING & RETRIEVAL โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Specialist โโโโโถโ FastAPI โโโโโถโ PostgreSQL Query โ โ
โ โ Types โ โsp_get_doctors_by โ โ (doctors table filter) โ โ
โ โ ["cardiology", โ โ _specialist โ โ โ โ
โ โ "neurology"] โ โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Available โโโโโโ Doctor List โโโโโโ Available Time Slots โ โ
โ โ Doctors โ โ with Slots โ โ & Schedules โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ APPOINTMENT BOOKING โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ User Selects โโโโโถโ Patient โโโโโถโ Appointment โ โ
โ โ Doctor & Slot โ โ Information โ โ Confirmation โ โ
โ โ โ โsp_get_patient_ โ โ sp_create_appointment โ โ
โ โ โ โ details โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ณ PAYMENT PROCESSING โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Razorpay โโโโโถโ Secure Payment โโโโโถโ Booking Confirmation โ โ
โ โ Gateway โ โ Processing โ โ & Notification โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ COMPLETE HEALTHCARE JOURNEY โ
โ โ
โ ๐ค Voice Input โ ๐ค AI Analysis โ ๐ฅ Doctor Match โ ๐ Booking โ ๐ณ Payment โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```## ๐ Detailed Component Interaction Flow
### 1. **User Authentication Flow**
```
User Input (Email/Password) โ FastAPI Login Endpoint โ PostgreSQL sp_login_user โ JWT Token/Session
```### 2. **Voice Processing Pipeline**
```
Microphone โ Web Speech API โ Text Conversion โ Phrase Array โ LangGraph Processing
```### 3. **AI Analysis Workflow**
```
Raw Symptoms โ Gemini/GPT-4 โ Normalized Symptoms โ Specialist Mapping โ Doctor Recommendations
```### 4. **Database Integration Pattern**
```
FastAPI Endpoints โ PostgreSQL Stored Procedures โ Data Retrieval โ JSON Response โ Frontend Display
```### 5. **Appointment Booking Chain**
```
Doctor Selection โ Patient Details Fetch โ Slot Validation โ Appointment Creation โ Payment Processing
```---
## ๐๏ธ Technical Architecture Overview
```
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ โ โ
โ FRONTEND โโโโโถโ BACKEND โโโโโถโ DATABASE โโโโโถโ EXTERNAL โ
โ โ โ โ โ โ โ SERVICES โ
โ โข React โ โ โข FastAPI โ โ โข PostgreSQL โ โ โข Gemini API โ
โ โข Web Speech โ โ โข LangGraph โ โ โข Stored Procs โ โ โข OpenAI API โ
โ โข JavaScript โ โ โข Python โ โ โข Functions โ โ โข Razorpay โ
โ โ โ โ โ โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
HTTP/REST API SQL Queries
(JSON Data Exchange) (Stored Procedures)
```---
## ๐ Overview
This healthcare AI assistant streamlines the patient care journey by providing:
- **Intelligent Voice Triage**: Natural language symptom collection and analysis
- **AI-Powered Diagnosis**: Advanced symptom normalization and specialist recommendation
- **Smart Doctor Matching**: Automated healthcare provider lookup based on specialization
- **Seamless Booking**: Integrated appointment scheduling with payment processing
- **Conversational Interface**: Intuitive voice-enabled user experience---
## โจ Key Features
### ๐ค Voice-Enabled Interaction
- Real-time speech-to-text conversion using Web Speech API
- Natural language processing for symptom collection
- Voice-guided patient triage workflow### ๐ค AI-Powered Medical Intelligence
- Integration with Gemini and GPT-4 for symptom analysis
- LangGraph-based symptom normalization
- Intelligent specialist mapping and recommendations### ๐ฅ Healthcare Management
- Comprehensive doctor database with specialization filtering
- PostgreSQL-powered efficient data retrieval
- Automated appointment scheduling system### ๐ณ Payment Integration
- Secure payment processing via Razorpay
- Test mode support for development
- Transaction management and tracking---
## ๐ ๏ธ Technology Stack
| Component | Technology | Purpose |
|-----------|------------|---------|
| **Frontend** | React, CSS, JavaScript | User interface and voice interactions |
| **Backend** | FastAPI, Python | API services and business logic |
| **AI/ML** | Gemini, GPT-4, LangGraph | Natural language processing and AI agents |
| **Database** | PostgreSQL | Data persistence and stored procedures |
| **Voice** | Web Speech API | Speech recognition and synthesis |
| **Payments** | Razorpay | Payment processing and gateway |
| **Deployment** | Uvicorn, Vite | Development and production servers |---
## ๐ Project Architecture
```
healthcare-ai-assistant/
โโโ backend/ # FastAPI backend services
โ โโโ main.py # Application entry point
โ โโโ agents/ # LangGraph AI agents
โ โโโ db/ # Database connections and queries
โ โโโ models.py # Data models and schemas
โ โโโ config.py # Configuration management
โ โโโ .env # Environment variables (excluded from git)
โ
โโโ frontend/ # React frontend application
โ โโโ components/ # Reusable UI components
โ โโโ pages/ # Application pages/views
โ โโโ .env.local # Frontend environment variables
โ
โโโ sql/ # Database schema and functions
โ โโโ schema.sql # Database table definitions
โ โโโ functions/ # PostgreSQL stored procedures
โ โโโ create_login_function.sql
โ โโโ create_appointment_function.sql
โ โโโ get_patient_details.sql
โ โโโ get_doctors_by_specialist.sql
โ
โโโ requirements.txt # Python dependencies
โโโ package.json # Node.js dependencies
โโโ .gitignore # Git ignore rules
โโโ README.md # Project documentation
```---
## ๐ Quick Start Guide
### Prerequisites
- **Python 3.8+**
- **Node.js 16+**
- **PostgreSQL 12+**
- **Git**### 1. ๐๏ธ Database Setup
#### Create Database and User
```bash
psql -U postgres
``````sql
CREATE DATABASE healthcare;
CREATE USER fastapi_user WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE healthcare TO fastapi_user;
\q
```#### Initialize Schema and Functions
```bash
psql -U fastapi_user -d healthcare -f sql/schema.sql
``````bash
psql -U fastapi_user -d healthcare -f sql/functions/create_login_function.sql
``````bash
psql -U fastapi_user -d healthcare -f sql/functions/create_appointment_function.sql
``````bash
psql -U fastapi_user -d healthcare -f sql/functions/get_patient_details.sql
``````bash
psql -U fastapi_user -d healthcare -f sql/functions/get_doctors_by_specialist.sql
```### 2. ๐ง Backend Configuration
#### Setup Virtual Environment
```bash
cd backend
``````bash
python -m venv venv
```**Windows:**
```bash
venv\Scripts\activate
```**macOS/Linux:**
```bash
source venv/bin/activate
```#### Install Dependencies
```bash
pip install -r requirements.txt
```#### Environment Configuration
Create `.env` file in the `backend/` directory:```env
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=fastapi_user
DB_PASSWORD=your_secure_password
DB_NAME=healthcare# CORS Configuration
FRONTEND_ORIGIN=http://localhost:5173# AI API Keys
OPENAI_API_KEY=your_openai_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
```#### Start Backend Server
```bash
uvicorn main:app --reload --host 0.0.0.0 --port 8000
```### 3. ๐จ Frontend Setup
#### Install Dependencies
```bash
npm install
```#### Environment Configuration
Create `.env.local` file in the root directory:```env
# API Configuration
VITE_BACKEND_URL=http://localhost:8000
VITE_GEMINI_API_KEY=your_gemini_api_key_here# Payment Configuration
VITE_RAZORPAY_KEY_ID=your_razorpay_key_id_here
```#### Start Development Server
```bash
npm run dev
```### 4. ๐ณ Payment Setup (Optional)
1. Create a [Razorpay account](https://razorpay.com/)
2. Navigate to API Keys section in dashboard
3. Copy the Key ID and Key Secret
4. Update the payment configuration in `frontend/components/Recommendation.jsx`---
## ๐ API Keys Setup
### OpenAI API Key
1. Visit [OpenAI Platform](https://platform.openai.com/)
2. Create an account and navigate to API Keys
3. Generate a new secret key
4. Add to backend `.env` file### Google Gemini API Key
1. Go to [Google AI Studio](https://makersuite.google.com/)
2. Create a new project or select existing
3. Generate API key
4. Add to both backend `.env` and frontend `.env.local`### Razorpay Configuration
1. Sign up at [Razorpay Dashboard](https://dashboard.razorpay.com/)
2. Switch to Test Mode for development
3. Copy API keys from Settings > API Keys
4. Configure in frontend environment---
## ๐โโ๏ธ Running the Application
1. **Start PostgreSQL service**
2. **Launch Backend**: `uvicorn main:app --reload` (from `backend/` directory)
3. **Launch Frontend**: `npm run dev` (from root directory)
4. **Access Application**: Navigate to `http://localhost:5173`---
## ๐งช Testing
### Backend API Testing
```bash
curl http://localhost:8000/health
```### Database Connection Testing
```bash
python -c "from backend.db.connection import get_db_connection; print('DB Connected!' if get_db_connection() else 'DB Connection Failed!')"
```---
## ๐ Deployment
### Backend Deployment
- Configure production database credentials
- Set up environment variables on hosting platform
- Deploy using platforms like Heroku, Railway, or DigitalOcean### Frontend Deployment
- Build production bundle: `npm run build`
- Deploy to Vercel, Netlify, or similar platforms
- Update CORS settings in backend for production domain---
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit changes: `git commit -m 'Add amazing feature'`
4. Push to branch: `git push origin feature/amazing-feature`
5. Open a Pull Request---
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---
## ๐ Support
For support and questions:
- Create an issue in the GitHub repository
- Check existing documentation and FAQs
- Review the troubleshooting section below---
## ๐ง Troubleshooting
### Common Issues
**Database Connection Error**
- Verify PostgreSQL is running
- Check database credentials in `.env`
- Ensure database and user exist**Voice Recognition Not Working**
- Use HTTPS or localhost only
- Check browser microphone permissions
- Verify Web Speech API support**API Key Errors**
- Validate API keys are correctly set
- Check for trailing spaces or quotes
- Verify API key permissions and quotas---
## ๐ฎ Future Enhancements
- [ ] Multi-language support
- [ ] Mobile application development
- [ ] Advanced AI model integration
- [ ] Telemedicine video consultation
- [ ] Electronic health records integration
- [ ] Real-time chat support
- [ ] Advanced analytics dashboard---
**Built with โค๏ธ for better healthcare accessibility**