DiagonWise is a modern web application that helps users understand their medical lab reports through AI-powered analysis. Upload your PDF or image lab reports, and get instant insights with clear explanations of test results, reference ranges, and clinical summaries.
- Smart Document Processing: Extracts text and structured data from PDFs and images using OCR
- AI-Powered Analysis: Leverages advanced AI to provide clinical summaries and explain test results in plain language
- Visual Analytics: Interactive charts showing test distributions, status breakdowns, and reference range comparisons
- Privacy-Focused: Files are processed temporarily and can be removed after analysis
- Export Capabilities: Download comprehensive PDF reports with AI summaries
- Responsive Design: Works seamlessly on desktop and mobile devices
- Secure & Local: No data storage - analysis happens in your browser session
- Upload: Drag & drop or select your lab report (PDF or image format)
- Extract: Advanced OCR extracts text and identifies test values, units, and reference ranges
- Analyze: AI analyzes the data and generates clinical insights
- Visualize: Interactive charts and tables display results with status indicators
- Export: Download a professional PDF report for your records
- Python 3.10+
- pip (Python package manager)
- Git
-
Clone the repository
git clone https://github.com/twi-exe/diagon-wise.git cd diagon-wise -
Set up virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env and add your OPENROUTER_API_KEY -
Run the development server
flask --debug run # Visit http://127.0.0.1:5000/ in your browser
For production deployment, use Gunicorn as the WSGI server:
-
Install Gunicorn
pip install gunicorn
-
Run with Gunicorn
gunicorn --bind 0.0.0.0:8000 app:app # Access at http://localhost:8000 -
Advanced Gunicorn configuration
gunicorn --workers 4 --bind 0.0.0.0:8000 --timeout 120 app:app
Build and run with Docker:
-
Build the Docker image
docker build -t diagon-wise . -
Run the container
docker run -p 5000:5000 --env-file .env diagon-wise # Access at http://localhost:5000 -
Docker Compose (alternative)
# docker-compose.yml version: '3.8' services: diagon-wise: build: . ports: - "5000:5000" env_file: - .env
docker-compose up
DiagonWise is deployed and accessible online at: https://diagon-wise.onrender.com/
The live deployment uses Render's free tier and may have cold start delays. For consistent performance, consider running locally or deploying to your preferred platform.
The application requires an AI API key for analysis features:
OPENROUTER_API_KEY— API key for OpenRouter-compatible AI service (required for AI summaries)
Local development:
export OPENROUTER_API_KEY="your-api-key-here"Codespaces (recommended):
- Go to repository Settings → Secrets and variables → Codespaces
- Add
OPENROUTER_API_KEYas a repository secret - Restart your Codespace
GitHub Actions:
- Repository Settings → Secrets and variables → Actions
- Add
OPENROUTER_API_KEYas a repository secret
The app provides a /health endpoint to verify AI service connectivity:
curl https://diagon-wise.onrender.com/healthResponse:
{
"status": "ok",
"ai_service_ok": true,
"api_key_masked": "****61f8"
}Run the test suite with pytest:
pytest -qTo test the Docker build and deployment:
-
Build the image
docker build -t diagon-wise:local . -
Run the container
docker run --rm -e OPENROUTER_API_KEY="$OPENROUTER_API_KEY" -p 5000:5000 diagon-wise:local -
Test health endpoint (in another terminal)
curl -sS http://127.0.0.1:5000/health | jq .
Expected response:
{ "status": "ok", "ai_service_ok": true, "api_key_masked": "****d084" } -
Test full app (visit
http://127.0.0.1:5000in browser and upload a test file)
- No Data Storage: Files are processed in memory and not stored permanently
- Client-Side Processing: Analysis happens on the server during your session
- API Key Protection: Keys are masked in logs and health checks
- Secure Practices: Follow security checklist for key management
diagon-wise/
├── app.py # Flask application and routes
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── pytest.ini # Test configuration
├── utils/ # Helper modules
│ ├── ocr.py # OCR text extraction
│ ├── extract.py # Test data extraction
│ ├── summarizer.py # AI analysis
│ └── pdf_export.py # PDF generation
├── templates/ # Jinja2 templates
│ ├── DiagonWise.html # Main upload page
│ └── result.html # Results display page
├── static/ # Static assets
│ └── style.css # Stylesheet
├── tests/ # Unit tests
└── uploads/ # Temporary file storage
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
When adding new features that require environment variables, update .env.example and this README.
This project is licensed under the MIT License. See LICENSE for details.
DiagonWise is for informational purposes only and should not replace professional medical advice. Always consult with qualified healthcare providers for medical decisions and interpretation of lab results.