An end-to-end web application that transforms complex, dense medical lab reports and clinical PDFs into clean, structured, and plain-language medical intelligence using Google's state-of-the-art Gemini 3.6 Flash model and client-side privacy-first PDF parsing.
Explore Demo • Key Features • Quick Start • Architecture • Deployment
Warning
Clinical Disclaimer: This application is strictly an educational and informational tool designed to assist comprehension of medical documentation. It does not provide medical diagnoses, treatment plans, or clinical judgements. Always consult a qualified healthcare provider for medical advice.
medical_report_analyzer_demo.mp4
|
Uses |
Harnesses Google's latest multimodal LLM with ultra-fast inference and high clinical reasoning accuracy via the official |
|
Guarantees predictable, strongly-typed JSON output matching clinical taxonomy—eliminating hallucinations, parsing errors, and messy Markdown formatting. |
Automatically isolates laboratory markers, reference ranges, observed values, status flags (normal, abnormal, critical), and plain-language definitions. |
|
Highlights high-priority clinical flags and generates targeted discussion questions for patients to bring to their next clinician appointment. |
Pre-configured for Vercel Serverless Functions with tailored 60-second timeouts and automatic fallback handling. |
graph LR
A[📄 User Uploads PDF] --> B[🖥️ Browser Client: PDF.js]
B -->|Extracts Text| C[🌐 Client Web UI]
C -->|POST /api/analyze| D[⚙️ Flask Backend on Vercel]
D -->|Strict Clinical Schema| E[✨ Google Gemini 3.6 Flash]
E -->|Structured JSON| D
D -->|Validated Response| C
C -->|Renders Visual Dashboard| F[📊 Structured Clinical Cards]
- AI Model: Google Gemini 3.6 Flash via
google-genaiSDK - Backend: Python 3.10+, Flask 3.1, Flask-CORS, python-dotenv
- Frontend: Modern Vanilla JS, Semantic HTML5, CSS3 Custom Properties (Dark/Light aesthetic)
- PDF Engine: PDF.js (Mozilla) client-side extraction
- Hosting: Vercel (Serverless Python runtime with
maxDuration: 60s)
Medical-Report-Analyzer/
├── api/
│ └── index.py # Flask API routes, Gemini SDK client & schema definition
├── templates/
│ └── index.html # Responsive client application, UI & PDF.js extraction
├── requirements.txt # Frozen dependencies (google-genai, flask, etc.)
├── vercel.json # Vercel Serverless Function & routing configuration
├── .env.example # Sample environment variables template
├── .gitignore # Ignores .env, virtual environments & runtime logs
├── LICENSE # MIT License
└── README.md # Project documentation
- Python 3.10+ installed
- A free Google AI Studio API Key (Get one here)
git clone https://github.com/Poovarasan46/Medical-Report-Analyzer.git
cd Medical-Report-Analyzer# Windows (PowerShell)
python -m venv .venv
.venv\Scripts\Activate.ps1
# macOS / Linux
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
GEMINI_API_KEY="your-gemini-api-key-here"
GEMINI_MODEL="gemini-3.6-flash"python api/index.pyAccess the application in your browser:
👉 http://127.0.0.1:5000
The application can be configured via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
GEMINI_API_KEY |
Yes | — | API key generated from Google AI Studio |
GEMINI_MODEL |
No | gemini-3.6-flash |
The Gemini model identifier |
MAX_REPORT_CHARS |
No | 45000 |
Safety limit for character length sent to Gemini |
GEMINI_MAX_COMPLETION_TOKENS |
No | 8192 |
Maximum token limit for structured output response |
This repository is pre-configured with vercel.json for one-click deployment to Vercel Serverless:
- Push your code to GitHub.
- Navigate to Vercel and click Add New > Project > Import Git Repository.
- Under Settings > Environment Variables, add:
GEMINI_API_KEY: (your Google Gemini API key)
- Click Deploy.
Tip
The included vercel.json already sets maxDuration: 60, ensuring Vercel gives Gemini sufficient execution time to analyze long medical records without timing out.
The AI responds with deterministic JSON adhering to this clinical structure:
{
"summary": {
"report_type": "Orthopedic Surgical Consultation",
"overall_assessment": "Post-operative evaluation with stable progression.",
"confidence": "high",
"data_quality": "good"
},
"patient": { "name": "...", "age": "...", "gender": "..." },
"provider": { "facility": "...", "clinician": "..." },
"key_findings": [
{
"test_name": "Hemoglobin",
"value": "13.8",
"unit": "g/dL",
"reference_range": "12.0 - 16.0",
"status": "normal",
"plain_language_meaning": "Healthy red blood cell count with no signs of anemia."
}
],
"possible_concerns": [...],
"recommendations": [...],
"urgent_flags": [...],
"follow_up_questions": [...]
}Contributions are welcome! If you have suggestions or improvements:
- Fork the Project
- Create a Feature Branch (
git checkout -b feature/AmazingFeature) - Commit Changes (
git commit -m 'Add AmazingFeature') - Push to Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.