Skip to content

swetank18/MedBios-AI

Repository files navigation

MedBios AI

MedBios AI

AI-Powered Clinical Report Intelligence Platform
Transforming medical reports into actionable health insights for humanity

Python FastAPI React Tailwind License CI

Live Demo · Features · Architecture · Getting Started


What is MedBios AI?

MedBios AI is an open-source clinical intelligence platform that analyzes medical lab reports using AI. Upload a PDF lab report, and MedBios extracts every lab value via OCR, detects abnormalities against 100+ reference ranges, reasons about clinical conditions using 20 clinical rules, maps findings to a medical knowledge graph, checks 30 drug interaction pairs, and generates personalized health recommendations — all in seconds.

Built for humanity. Free and open source.


Features

🔬 Core Analysis Engine

  • OCR Extraction — Extracts lab values from PDF reports with intelligent multi-pattern parsing
  • 100+ Lab Test References — Comprehensive database with 130+ name aliases for high OCR accuracy
  • Multi-Level Severity Scoring — Every abnormal value gets a 0-100 severity score with percentage deviation
  • 20 Clinical Reasoning Rules — Detects conditions: metabolic syndrome, anemia, thyroid disorders, cardiac risk, coagulation abnormalities, pancreatic injury, PSA screening, and more

🧠 AI Intelligence

  • Knowledge Graph — Medical ontology linking diseases, symptoms, lab tests, and medications
  • Smart Health Recommendations — 15+ condition-specific databases generating personalized diet, exercise, supplement, and follow-up plans
  • AI Chat Assistant — Context-aware chat about your report findings in natural language
  • Drug Interaction Checker30 clinically significant drug-drug pairs with 65+ medication aliases covering macrolides, aminoglycosides, PDE5 inhibitors, nitrates, anticonvulsants, and more

🎨 Premium Visualization

  • Animated Health Score Ring — 60fps SVG donut with decorative tick marks, glow effects, end-dot cursor, inner rings, and risk-coded descriptions
  • Organ System Radar Chart — Spider chart mapping risk across all body systems
  • Biomarker Heatmap — Dense color-coded grid of all lab values with hover tooltips
  • Interactive Organ System Map — SVG body silhouette with hover-activated glowing indicators, detail panels, and animated pulse rings for high-risk organs
  • Critical Alert Banners — Dismissible severity-coded banners for critical findings
  • Severity Ring Chart — SVG donut visualizing drug interaction severity distribution
  • Animated Patient Summary — Counter animations, 6-metric strip, mini progress bar

🔐 Authentication System

  • Premium Login Page — Gradient background, branded card, platform highlights, form validation
  • Sign Up Page — 6-role selector, password strength indicator, confirm password with real-time match indicator
  • Auth Context — localStorage session persistence, protected routes, user avatar dropdown
  • Settings & Profile — Appearance customization, notification preferences, keyboard shortcuts, account management

📄 Professional Output

  • Doctor-Ready PDF Reports — Generated clinical reports with ReportLab
  • Patient Summary Cards — Gradient avatar, animated counters, risk badges, stacked progress bar
  • Trend Analysis — Track health progression across multiple reports
  • Print-Optimized Styles — Clean print output for physical copies

Architecture

┌─────────────────────────────────────────────────────────┐
│                    React 19 Frontend                      │
│  Dashboard · Upload · Results · Drug Checker · Settings   │
│  25+ Premium Components · Tailwind CSS v4                 │
├─────────────────────────────────────────────────────────┤
│                    FastAPI Backend                         │
│  REST API · SQLAlchemy ORM · Async I/O                    │
├──────────────┬─────────────────┬────────────────────────┤
│  OCR Engine  │  NLP Pipeline   │  Knowledge Graph         │
│  PyMuPDF     │  Reference      │  Medical Ontology        │
│  Tesseract   │  Ranges (100+)  │  Diseases/Symptoms       │
├──────────────┴─────────────────┴────────────────────────┤
│               AI Services Layer                           │
│  20 Clinical Rules · 30 Drug Pairs · Risk Scoring         │
│  Recommendations · Trend Analysis · Report Generation     │
├─────────────────────────────────────────────────────────┤
│               SQLite / PostgreSQL                         │
│  Patients · Reports · Lab Results · Insights              │
└─────────────────────────────────────────────────────────┘

Tech Stack

Layer Technology
Frontend React 19, Vite, Tailwind CSS v4, Recharts, Axios
Backend Python 3.12+, FastAPI, SQLAlchemy (async), Pydantic
OCR PyMuPDF (fitz), Tesseract OCR
Database SQLite (dev), PostgreSQL (prod)
PDF Export ReportLab
Auth Session-based (frontend), JWT-ready (backend)
Deployment Vercel (frontend), Render (backend), Docker
CI/CD GitHub Actions (lint, test, build, security audit)

Getting Started

Prerequisites

  • Python 3.12+
  • Node.js 20+
  • Tesseract OCR (optional, for scanned PDFs)

Backend Setup

cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend Setup

cd frontend
npm install
npm run dev

Visit http://localhost:5173 — the frontend connects to the backend automatically.

Run Tests

cd backend
python -m pytest tests/ -v --tb=short

Environment Variables

# Backend
DATABASE_URL=sqlite+aiosqlite:///./medbios.db
CORS_ORIGINS=http://localhost:5173,https://your-domain.com
GOOGLE_API_KEY=your-gemini-key  # Optional: for AI chat features

# Frontend (Vercel)
VITE_API_URL=https://your-backend.onrender.com

API Endpoints

Method Endpoint Description
POST /api/reports/upload Upload PDF for analysis
GET /api/reports/ List all reports
GET /api/reports/{id} Get report details
GET /api/reports/{id}/recommendations AI health recommendations
POST /api/reports/{id}/chat Chat with report
POST /api/reports/drug-interactions/check Drug interaction check
GET /api/reports/analytics/dashboard Dashboard analytics
GET /api/reports/export/{id}/pdf Download PDF report
GET /api/reports/knowledge-graph/stats Knowledge graph statistics

Component Library (25+)

Component Description
HealthScoreRing Multi-ring SVG donut with tick marks, glow, and end-dot cursor
SystemRadarChart Recharts radar chart for organ system risks
BiomarkerHeatmap Color-coded grid with hover tooltips
CriticalAlerts Dismissible severity-coded alert banners
PatientSummaryCard Animated counters, 6 metrics, stacked progress bar
OrganSystemVis Interactive SVG body map with hover detail panels
HealthRecommendations Expandable accordion with diet/exercise/supplements
ReportChat Floating AI chat panel with typing indicators
AbnormalFindings Sortable lab table with severity bars
ClinicalInsights Evidence-based clinical condition cards
RiskScores System-level risk progress bars with animated filling
KnowledgeGraphViz Interactive knowledge graph visualization
DoctorReport Comprehensive clinical report with 20-rule + 30-pair stats
SkeletonLoader 6 types: card, stats, hero, table, heatmap, profile, chat
ToastProvider 4-type notification system
SeverityRing SVG donut for drug interaction severity distribution
Login Premium login with gradient orbs and platform highlights
Signup Premium signup with password strength and role selector
Settings 5-section settings: Profile, Appearance, Notifications, Shortcuts, About

Deployment

Render (Backend + PostgreSQL)

Deploy to Render

  1. Push this repo to GitHub
  2. Go to render.comNewBlueprint
  3. Connect your GitHub repo — Render auto-reads render.yaml and provisions:
    • A free PostgreSQL database (medbios-db)
    • A free Python web service (medbios-ai-backend) with all env vars wired up
  4. After deploy, note your backend URL: https://medbios-ai-backend.onrender.com

Manual setup (without Blueprint):

  1. Connect GitHub repo → set root directory to backend
  2. Build command: pip install -r requirements.txt
  3. Start command: uvicorn main:app --host 0.0.0.0 --port $PORT
  4. Health check path: /health
  5. Add env vars (see table below)

Vercel (Frontend)

Deploy with Vercel

  1. Connect GitHub repo → set root directory to frontend
  2. Framework preset: Vite
  3. Add environment variable: VITE_API_URL=https://medbios-ai-backend.onrender.com/api
  4. Deploy — frontend/vercel.json handles SPA routing and security headers automatically

Required Environment Variables

Variable Where Description How to Generate
DATABASE_URL Render PostgreSQL connection string Auto-injected by Render Blueprint
JWT_SECRET_KEY Render JWT signing secret python -c "import secrets; print(secrets.token_hex(32))"
MEDBIOS_ENCRYPTION_KEY Render Fernet encryption key python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
CORS_ORIGINS Render Comma-separated allowed origins https://your-app.vercel.app,http://localhost:5173
GOOGLE_API_KEY Render Gemini Vision OCR (optional) Google AI Studio
VITE_API_URL Vercel Backend API base URL https://medbios-ai-backend.onrender.com/api
VITE_WS_URL Vercel WebSocket base URL wss://medbios-ai-backend.onrender.com

Local Development

# 1. Clone
git clone https://github.com/your-username/MedBios-AI.git
cd MedBios-AI

# 2. Backend
cd backend
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp ../.env.example .env         # edit .env with your values
uvicorn main:app --reload --port 8000

# 3. Frontend (new terminal)
cd frontend
npm install
npm run dev
# Visit http://localhost:5173

# 4. Generate secrets (first-time setup)
python -c "import secrets; print(secrets.token_hex(32))"
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

CI/CD Pipeline

The project includes a comprehensive GitHub Actions workflow:

  • Backend: Python lint (Ruff), tests (pytest), type checking (pyright)
  • Frontend: ESLint, production build with artifact upload
  • Security: npm audit + safety checks
  • Deployment gate: All checks must pass before release

License

MIT License — free to use, modify, and distribute.


Built with AI, for humanity.
MedBios AI is for informational purposes only. Always consult your healthcare provider.

About

MedBios is an AI-powered clinical report intelligence platform that analyzes medical reports and converts them into structured, explainable insights. By combining OCR, clinical NLP, and medical knowledge reasoning, the system extracts key lab values, detects abnormalities, and generates physician-ready summaries with evidence mapping.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors