Skip to content

Repository files navigation

MedLens 🩺📄

AI-assisted medical report explainer for patients

MedLens is a full-stack web app that helps patients understand their own medical documents.
You can securely upload reports (PDFs or images), and MedLens will:

  • Run OCR on scanned documents
  • Extract key medical entities (diagnoses, medications, lab values, etc.)
  • Generate a plain-language summary at ~6th-grade reading level
  • Show clickable citations that map each summary sentence back to the original report text

🌐 Live Demo

👉 Try MedLens here:
https://med-lens-six.vercel.app/sign-in

You can create an account and upload your own test documents.


✨ Features

  • Secure authentication

    • Email + password login with reset flow
    • Social login (Google) via BetterAuth
  • Document ingestion

    • Upload PDFs and images
    • OCR pipeline for scanned documents
    • Text normalization & sentence splitting
  • Medical NLP

    • Entity extraction (diagnoses, medications, procedures, etc.)
    • Entity context flags like present / negated / uncertain
    • Summarization optimized for patient understanding (no heavy jargon)
  • Traceable explanations

    • Summary sentences are linked back to the original report sentences
    • Citation panel explains “this summary sentence comes from these parts of the report”
  • Job queue + admin tools

    • Multi-stage background jobs (OCR → sentences → entities → summary)
    • Error tracking for failed jobs
    • Admin view to inspect / clean up problematic jobs

🧱 Tech Stack

  • Frontend & Backend: Next.js (App Router), React, TypeScript
  • Styling: Tailwind CSS + custom components
  • Auth: BetterAuth with email/password + Google OAuth
  • Database: PostgreSQL (local or hosted, e.g. Neon) via Drizzle ORM
  • AI / NLP:
    • OCR worker (Tesseract-style) for PDFs and images
    • Token classification / NER for medical entities
    • LLM summarization tuned for patient-friendly output
  • Other:
    • API routes & server actions for document processing
    • Strict TypeScript types for documents, entities, jobs, and summaries

🖼️ Core Concepts

MedLens revolves around a few key data models:

  • Document – The uploaded file (PDF or image) + basic metadata
  • Sentences – The document text split into numbered sentences
  • Entities – Extracted medical entities with labels and character spans
  • Summary – A structured summary with:
    • summary: final text
    • questions: suggested questions for the patient to ask their doctor
    • citations: mapping from summary sentences → source sentence indexes
  • Jobs – Background tasks that move a document through the pipeline

This design makes the app traceable, debuggable, and easy to extend with new AI steps.


🗂️ Project Structure (High Level)

.
├─ app/                 # Next.js App Router pages & routes
│  ├─ (auth)/           # Sign-in / sign-up / reset password screens
│  ├─ (root)/           # Main app views (dashboard, documents, admin, etc.)
│  └─ api/              # Route handlers (upload, jobs, etc.)
├─ components/          # Reusable UI components (layout, forms, document views)
├─ constants/           # Shared constants / enums (routes, statuses, etc.)
├─ database/            # Drizzle schema & database config
├─ lib/                 # Utility functions, AI pipeline, OCR, job helpers
├─ migrations/          # SQL migrations generated by Drizzle
├─ public/              # Static assets (logo, icons, favicons, etc.)
└─ types/               # Shared TypeScript types (Document, Entity, Summary, Job...)

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages