An intelligent healthcare assistant platform powered by LLM
Features β’ Tech Stack β’ Getting Started β’ API Documentation β’ Contributing
MedAssist is a full-stack medical consultation platform that leverages Google's Gemini AI to provide preliminary medical advice, symptom analysis, and AI-assisted medical image interpretation. Built with a modern React frontend and FastAPI backend, it offers a seamless experience for users seeking health information and medical insights.
This platform is designed for informational purposes only and should not replace professional medical advice, diagnosis, or treatment. Always consult with qualified healthcare professionals for proper medical care.
- π¬ Medical Consultations: Get preliminary medical advice through conversational AI interaction
- π Symptom Analysis: Describe your symptoms and receive potential insights about your condition
- πΈ Medical Image Analysis: Upload X-rays, CT scans, MRI, ultrasound, and blood test images for AI-assisted analysis
- π Patient Profiles: Track patient details including name, age, gender, and chief complaints
- π PDF Report Generation: Generate professional medical reports and prescriptions with recommendations
- π Conversation History: Maintain context across multiple consultations for better AI responses
- β‘ Real-time Responses: Fast, intelligent responses powered by Gemini 2.5 Flash model
- Framework: FastAPI - Modern, fast web framework
- Language: Python 3.8+
- AI Models: Google Gemini 2.5 Flash (Chat & Vision)
- PDF Generation: ReportLab
- Image Processing: Pillow (PIL)
- APIs: FastAPI with CORS middleware
- Library: React 19.1+
- Build Tool: Vite 7.1+
- Routing: React Router 7.9+
- Markdown Rendering: React Markdown 10.1+
- Styling: CSS3 with responsive design
google-genai: Google Gemini AI integrationpython-dotenv: Environment variable managementreportlab: PDF generationpillow: Image processingcors: Cross-Origin Resource Sharing middleware
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React + Vite) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Home β’ Chat Interface β’ Patient Forms β’ Reports β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST
ββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI + Python) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β’ Chat Endpoint (/api/chat) β β
β β β’ Report Generation (/api/generate-report) β β
β β β’ X-ray Analysis (Gemini Vision) β β
β β β’ PDF Generation & Download β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββΌβββββββββ
β Google Gemini β
β AI (2.5 Flash) β
ββββββββββββββββββ
- Python 3.8+ installed on your system
- Node.js 16+ and npm for frontend development
- Google Gemini API Key (Get it here)
- Git for version control
git clone https://github.com/yourusername/MedAssist.git
cd MedAssist/back# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activatepip install fastapi uvicorn google-genai python-dotenv pillow reportlab python-multipartCreate a .env file in the back directory:
GEMINI_API_KEY=your_gemini_api_key_hereuvicorn main:app --reload --host 127.0.0.1 --port 8000The API will be available at http://127.0.0.1:8000
Interactive API Documentation: Visit http://127.0.0.1:8000/docs (Swagger UI)
cd ../frontnpm installnpm run devThe application will open at http://localhost:5173 (or specified port)
npm run build| Method | Endpoint | Purpose |
|---|---|---|
GET |
/ |
Health check and API information |
POST |
/api/chat |
Send messages and analyze medical images |
POST |
/api/generate-report |
Generate professional PDF reports |
GET |
/api/status |
System status check |
Unified Chat Endpoint - Handle both text conversations and X-ray analysis
Request (Form Data):
{
"message": "I have a persistent headache and fever",
"conversation_history": "[{\"role\": \"user\", \"content\": \"...\"}, ...]",
"xray_image": "<binary image file>"
}Response:
{
"response": "Based on your symptoms of headache and fever...",
"xray_analysis": "The X-ray shows...",
"timestamp": "2024-01-15T10:30:00.123456"
}cURL Example:
curl -X POST "http://127.0.0.1:8000/api/chat" \
-F "message=Analyze my X-ray image" \
-F "conversation_history=[]" \
-F "xray_image=@xray.jpg"PDF Report Generation - Create professional medical reports
Request (JSON):
{
"patient_name": "John Doe",
"patient_age": 35,
"patient_gender": "Male",
"symptoms": "Chest pain, shortness of breath",
"diagnosis": "Suspected acute coronary syndrome",
"xray_analysis": "Chest X-ray shows normal cardiac silhouette",
"medications": [
"Aspirin 500mg - twice daily for 5 days",
"Atorvastatin 20mg - once daily"
],
"instructions": "Rest for 48 hours, avoid strenuous activity, follow-up with cardiologist"
}Response:
- Returns a PDF file for download with formatted medical report
System Status Check - Verify API and model initialization
Response:
{
"message": "Medical Chatbot API",
"status": "running",
"version": "1.0.0",
"models": {
"gemini_client_initialized": true,
"vision_model": "gemini-2.5-flash",
"chat_model": "gemini-2.5-flash"
}
}MedAssist/
βββ back/ # Backend (FastAPI)
β βββ main.py # Main API application
β βββ requirements.txt # Python dependencies
β βββ .env # Environment variables (create this)
β
βββ front/ # Frontend (React + Vite)
β βββ src/
β β βββ components/ # Reusable React components
β β β βββ ChatInterface.jsx
β β β βββ ChatWindow.jsx
β β β βββ MessageInput.jsx
β β β βββ Navbar.jsx
β β β βββ PatientList.jsx
β β βββ pages/ # Page components
β β β βββ Home.jsx
β β β βββ Chat.jsx
β β β βββ About.jsx
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css
β βββ package.json
β βββ vite.config.js
β βββ index.html
β
βββ README.md # This file
- Hero section with welcome message
- Feature cards highlighting capabilities
- Quick-start button to begin consultations
- Patient information form (name, age, gender, symptoms)
- Real-time message display
- File upload for medical images
- Report type selection dropdown
- PDF report generation
App
βββ Home
βββ Chat
β βββ ChatInterface
β βββ ChatWindow
β βββ MessageInput
βββ About
βββ Navbar
- CORS is enabled for all origins (*)
- Environment variables for API keys
- Input validation for file uploads
- π Restrict CORS to specific frontend domain
- π Implement authentication and authorization
- π‘οΈ Add rate limiting to API endpoints
- π Validate all user inputs on backend
- π Rotate API keys regularly
- π Implement logging and monitoring
- Never commit
.envfiles to version control - Store sensitive API keys securely
- Use HTTPS in production
- Implement HIPAA compliance if handling real patient data
Backend won't start
# Clear cache and reinstall
rm -r venv
python -m venv venv
pip install -r requirements.txtAPI connection errors
- Verify backend is running:
http://127.0.0.1:8000/docs - Check vite proxy configuration in
vite.config.js - Ensure CORS middleware is properly configured
Gemini API errors
- Verify API key is correct in
.env - Check API key has proper permissions
- Ensure API is enabled in Google Cloud Console
- FastAPI Documentation
- React Documentation
- Google Gemini API Guide
- Vite Documentation
- ReportLab Documentation
Contributions are welcome! Here's how to help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use React functional components with hooks
- Include comments for complex logic
- Test changes before submitting PR
- Update documentation as needed
MedAssist is NOT a substitute for professional medical advice. This platform:
- Provides general information only
- Should not be used for diagnosis or treatment decisions
- Cannot replace consultation with licensed healthcare providers
- Is designed for educational purposes
Always consult with qualified healthcare professionals for proper medical evaluation and treatment.
MedAssist is an AI-powered medical consultation assistant that demonstrates the capabilities of modern AI in healthcare informatics. Built with modern web technologies and powered by Google's Gemini AI.
Made with β€οΈ By Avijit0001