MediScan AI is a production-ready medical prescription analysis platform that uses OCR and Generative AI to extract, analyze, and structure information from prescription images.
The platform provides a complete workflow from prescription upload to OCR processing, AI-powered analysis, structured data persistence, usage tracking, history management, and risk-based alerts.
Built with modern backend engineering practices including REST APIs, PostgreSQL, Alembic migrations, Docker, automated testing, GitHub Actions CI, and cloud deployment.
π Live Demo: https://mediscan-2lzy.onrender.com
π Backend API: https://mediscan-backend-82ft.onrender.com
β€οΈ Backend Health: https://mediscan-backend-82ft.onrender.com/health
- π€ Upload prescription images
- π OCR-based text extraction
- π€ AI-powered prescription analysis using Gemini
- π Structured prescription information extraction
- π Prescription history
- π€ User authentication and isolation
- π Usage tracking and limits
- π¨ Risk-based alert generation
- π§ Optional email alert support
- ποΈ PostgreSQL database persistence
- π Alembic database migrations
- π JWT-based authentication
- π‘οΈ API security and validation
- π³ Dockerized application
- π§ͺ Automated test suite
- βοΈ GitHub Actions CI
- βοΈ Render deployment
- π Configurable CORS
- β€οΈ Backend health monitoring
User
β
βΌ
Streamlit Frontend
β
β REST API
βΌ
FastAPI Backend
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
βΌ βΌ βΌ
OCR Gemini AI PostgreSQL
Processing Analysis / Supabase
β β β
ββββββββββββββββββΌβββββββββββββββββ
β
βΌ
Alert & Usage System
β
βΌ
Email Service
Prescription Image
β
βΌ
Upload
β
βΌ
Authentication
β
βΌ
OCR
β
βΌ
Extract Prescription Text
β
βΌ
Gemini AI
β
βΌ
Structured Prescription Data
β
βΌ
Risk Analysis
β
βββββββββββββββββ
βΌ βΌ
PostgreSQL Alert System
β
βΌ
Prescription History
| Layer | Technology |
|---|---|
| Frontend | Streamlit |
| Backend | FastAPI |
| Language | Python |
| Database | PostgreSQL |
| Database Hosting | Supabase |
| ORM | SQLAlchemy |
| Migrations | Alembic |
| Authentication | JWT / Python-Jose |
| Password Hashing | Argon2 |
| OCR | RapidAPI OCR |
| AI | Google Gemini API |
| API Communication | REST |
| Validation | Pydantic |
| Testing | Pytest |
| Containerization | Docker |
| Local Orchestration | Docker Compose |
| CI/CD | GitHub Actions |
| Deployment | Render |
MediScan implements several application-level security mechanisms:
- π JWT authentication
- π Password hashing using Argon2
- π‘οΈ Protected API routes
- π€ User-level data isolation
- β Request validation using Pydantic
- π File upload validation
- π Usage limit enforcement
- π Environment-based secret management
- π CORS configuration
- π« No production secrets committed to Git
The project includes automated tests covering:
- Authentication
- Prescription processing
- Security
- User isolation
- Usage limits
- Alerts
- Alert service
- API client
- Database bootstrap
21 passed
0 failed
Regression validation also covers the previously completed application phases.
Run the complete test suite:
pytest -qMediScan uses PostgreSQL for production persistence.
Database schema changes are managed using Alembic.
python -m alembic upgrade headpython -m alembic currentThe production deployment runs database migrations before starting the backend application.
git clone https://github.com/prijithjohn/Mediscan.git
cd Mediscanpython -m venv .venv.venv\Scripts\activatesource .venv/bin/activatepip install -r requirements.txtCreate a .env file for local development.
DATABASE_URL=postgresql://username:password@host:5432/database
SECRET_KEY=your_secret_key
GEMINI_API_KEY=your_gemini_api_key
RAPIDAPI_KEY=your_rapidapi_key
RAPIDAPI_HOST=pen-to-print-handwriting-ocr.p.rapidapi.com
CORS_ALLOW_ORIGINS=http://localhost:8501Email alerts can be enabled by configuring:
SMTP_HOST=
SMTP_PORT=
SMTP_USERNAME=
SMTP_PASSWORD=
ALERT_EMAIL=
β οΈ Never commit real API keys, database passwords, JWT secrets, or SMTP credentials to Git.
Build and start the application:
docker compose up --buildThe application runs as:
Frontend:
http://localhost:8501
Backend:
http://localhost:8000
Health:
http://localhost:8000/health
docker compose downRun the complete test suite:
pytest -qExpected result:
21 passed
MediScan is deployed using:
- π³ Docker
- βοΈ Render
- ποΈ PostgreSQL
- π’ Supabase
- βοΈ GitHub Actions
- π Alembic
π https://mediscan-2lzy.onrender.com
π https://mediscan-backend-82ft.onrender.com
β€οΈ https://mediscan-backend-82ft.onrender.com/health
The backend uses Render's dynamic PORT environment variable and binds to:
0.0.0.0
Database migrations are executed during backend startup.
GitHub Actions validates the application before deployment.
The CI pipeline performs:
Push to GitHub
β
βΌ
Install Dependencies
β
βΌ
Validate Workflow
β
βΌ
Run Pytest
β
βΌ
Validate Docker Build
β
βΌ
Validate Docker Compose
β
βΌ
β
PASS
Mediscan/
β
βββ backend/
β βββ app/
β βββ api/
β β βββ routes/
β β β βββ auth.py
β β β βββ prescriptions.py
β β β βββ usage.py
β β β βββ alerts.py
β β β βββ pipeline.py
β β β
β β βββ deps.py
β β βββ
β β
β βββ core/
β β βββ config.py
β β βββ security.py
β β
β βββ db/
β β βββ models/
β β βββ base.py
β β βββ session.py
β β
β βββ schemas/
β β
β βββ services/
β β βββ ocr_service.py
β β βββ gemini_service.py
β β βββ prescription_service.py
β β βββ usage_service.py
β β βββ alert_service.py
β β βββ email_service.py
β β
β βββ main.py
β
βββ frontend/
β βββ app.py
β βββ api_client.py
β
βββ alembic/
β βββ versions/
β βββ env.py
β βββ script.py.mako
β
βββ scripts/
β βββ container_e2e.py
β βββ create_e2e_data.py
β
βββ tests/
β βββ test_auth.py
β βββ test_prescription.py
β βββ test_security.py
β βββ test_usage.py
β βββ test_alerts.py
β βββ test_alert_service.py
β βββ test_api_client.py
β βββ test_db_bootstrap.py
β
βββ .github/
β βββ workflows/
β βββ ci.yml
β
βββ Dockerfile
βββ docker-compose.yml
βββ docker-entrypoint.sh
βββ alembic.ini
βββ requirements.txt
βββ README.md
- β‘ FastAPI Backend Development
- π REST API Design
- π₯οΈ Streamlit Application Development
- π Python Backend Engineering
- ποΈ PostgreSQL
- π SQLAlchemy ORM
- π Alembic Database Migrations
- π JWT Authentication
- π‘οΈ API Security
- π OCR API Integration
- π€ Google Gemini API Integration
- π§ AI Application Development
- π³ Docker & Docker Compose
- βοΈ GitHub Actions CI
- βοΈ Cloud Deployment
- π’ Supabase
- π§ͺ Automated Testing
- π¬ End-to-End Validation
- π§ Environment Configuration
- π Production Debugging
- π GitHub: https://github.com/prijithjohn
- πΌ LinkedIn: https://www.linkedin.com/in/prijith-john-dev/
- π Portfolio: https://prijith-portfolio.vercel.app/
If you found MediScan useful, consider giving the project a β Star on GitHub.
It helps support the project and makes it easier for others to discover.
MediScan AI is an experimental software project intended for educational and demonstration purposes.
The system uses OCR and Generative AI to analyze prescription images and may produce inaccurate, incomplete, or incorrect information.
MediScan AI should not be used as a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare professional before making medical decisions.




