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.
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ 🎤 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 │
└─────────────────────────────────────────────────────────────────────────────────────┘
User Input (Email/Password) → FastAPI Login Endpoint → PostgreSQL sp_login_user → JWT Token/Session
Microphone → Web Speech API → Text Conversion → Phrase Array → LangGraph Processing
Raw Symptoms → Gemini/GPT-4 → Normalized Symptoms → Specialist Mapping → Doctor Recommendations
FastAPI Endpoints → PostgreSQL Stored Procedures → Data Retrieval → JSON Response → Frontend Display
Doctor Selection → Patient Details Fetch → Slot Validation → Appointment Creation → Payment Processing
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │ │ │
│ 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)
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
- Real-time speech-to-text conversion using Web Speech API
- Natural language processing for symptom collection
- Voice-guided patient triage workflow
- Integration with Gemini and GPT-4 for symptom analysis
- LangGraph-based symptom normalization
- Intelligent specialist mapping and recommendations
- Comprehensive doctor database with specialization filtering
- PostgreSQL-powered efficient data retrieval
- Automated appointment scheduling system
- Secure payment processing via Razorpay
- Test mode support for development
- Transaction management and tracking
| 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 |
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
- Python 3.8+
- Node.js 16+
- PostgreSQL 12+
- Git
psql -U postgresCREATE DATABASE healthcare;
CREATE USER fastapi_user WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE healthcare TO fastapi_user;
\qpsql -U fastapi_user -d healthcare -f sql/schema.sqlpsql -U fastapi_user -d healthcare -f sql/functions/create_login_function.sqlpsql -U fastapi_user -d healthcare -f sql/functions/create_appointment_function.sqlpsql -U fastapi_user -d healthcare -f sql/functions/get_patient_details.sqlpsql -U fastapi_user -d healthcare -f sql/functions/get_doctors_by_specialist.sqlcd backendpython -m venv venvWindows:
venv\Scripts\activatemacOS/Linux:
source venv/bin/activatepip install -r requirements.txtCreate .env file in the backend/ directory:
# 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_hereuvicorn main:app --reload --host 0.0.0.0 --port 8000npm installCreate .env.local file in the root directory:
# 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_herenpm run dev- Create a Razorpay account
- Navigate to API Keys section in dashboard
- Copy the Key ID and Key Secret
- Update the payment configuration in
frontend/components/Recommendation.jsx
- Visit OpenAI Platform
- Create an account and navigate to API Keys
- Generate a new secret key
- Add to backend
.envfile
- Go to Google AI Studio
- Create a new project or select existing
- Generate API key
- Add to both backend
.envand frontend.env.local
- Sign up at Razorpay Dashboard
- Switch to Test Mode for development
- Copy API keys from Settings > API Keys
- Configure in frontend environment
- Start PostgreSQL service
- Launch Backend:
uvicorn main:app --reload(frombackend/directory) - Launch Frontend:
npm run dev(from root directory) - Access Application: Navigate to
http://localhost:5173
curl http://localhost:8000/healthpython -c "from backend.db.connection import get_db_connection; print('DB Connected!' if get_db_connection() else 'DB Connection Failed!')"- Configure production database credentials
- Set up environment variables on hosting platform
- Deploy using platforms like Heroku, Railway, or DigitalOcean
- Build production bundle:
npm run build - Deploy to Vercel, Netlify, or similar platforms
- Update CORS settings in backend for production domain
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
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
- 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