MedBridge is a full‑stack app that turns complex hospital discharge notes into patient‑friendly summaries, extracts medications and red‑flag symptoms, and can deliver the summary to a patient’s phone via WhatsApp.
What This Repo Contains
- A FastAPI backend that ingests text or PDFs, simplifies discharge notes with an LLM, scores readability, and optionally sends a WhatsApp message via Twilio.
- A React + Vite frontend that provides the upload/paste UI, shows structured results, and triggers SMS/WhatsApp delivery.
Core Features
- Upload a discharge PDF or paste plain text.
- PDF text extraction with
pdfplumber, with OCR fallback via AWS Rekognition. - Discharge note simplification using Claude with a JSON‑only response format.
- Medication extraction, red‑flag symptom listing, and summary bullets.
- Readability scoring with Flesch‑Kincaid grade level.
- Optional RAG grounding from a local knowledge base.
- WhatsApp delivery via Twilio.
Architecture Overview
- Frontend collects discharge text or a PDF and calls
POST /extract-pdf(if a PDF is uploaded). - Frontend calls
POST /simplifywith the final text + language choice. - Backend retrieves guideline chunks from a FAISS vector index (if available), and calls Claude for simplification.
- Backend computes readability before/after and returns a structured response.
- Frontend renders results and can call
POST /send-smsto send the summary via WhatsApp.
Backend
Location: backend/
Endpoints
GET /health->{ "ok": true }POST /extract-pdf->{ "text": string }POST /simplify->SimplifyResponse(see schemas below)POST /send-sms->{ "status": "sent" | "mocked" }
Request/Response Schemas
SimplifyRequesttext: stringlanguage: string(default:English)SimplifyResponsesimplified_text: stringsummary_points: string[]medications: { name, dosage, time_of_day?, warning? }[]red_flags: string[]readability: { before, after }citations?: string[](RAG guideline chunks, if available)
Environment Variables
Set these in backend/.env or your shell (pydantic settings are case‑insensitive, so lowercase works too):
AWS_REGION(default:us-east-1)AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYBEDROCK_EMBED_MODEL_ID(default:amazon.titan-embed-text-v2:0)BEDROCK_MODEL_ID(defined in settings but not currently used by the generator)ANTHROPIC_API_KEYTWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENTWILIO_FROM_NUMBER(defined but not currently used)
Notes:
- If AWS credentials are not configured, PDF OCR fallback (Rekognition) is disabled.
- If Twilio credentials are not configured,
/send-smsreturns{ "status": "mocked" }. - WhatsApp delivery uses the Twilio sandbox number hardcoded in code:
whatsapp:+14155238886.
Run Backend (Local)
cd backendpython -m venv .venv.\.venv\Scripts\Activate.ps1pip install -r requirements.txtuvicorn app.main:app --reload --port 8000
Run Backend (Docker)
cd backenddocker build -t medbridge-backend .docker run --rm -p 8000:8000 --env-file .env medbridge-backend
RAG Knowledge Base (Optional)
The RAG index lives in backend/app/rag/ as index.faiss and index.json.
- Add
.txtguideline files tobackend/app/rag/knowledge_base/. - Run
python -m app.rag.ingestfrombackend/to build the index. - The simplifier will automatically use the index if it exists.
Frontend
Location: frontend/
Key Screens
InputPagefor uploading PDFs or pasting text.ResultsPagefor summaries, medications, red flags, readability, and SMS trigger.ImpactPageandHowItWorksPagefor narrative/marketing content.
Environment Variables
VITE_API_URL(default:http://localhost:8000)
Run Frontend
cd frontendnpm installnpm run dev
Tech Stack
- Frontend: React 19, Vite, Tailwind CSS, Framer Motion, Lucide icons, Axios
- Backend: FastAPI, Uvicorn, Anthropic SDK, AWS Bedrock + Rekognition, FAISS, pdfplumber, textstat, Twilio
Repo Structure
backend/FastAPI service, RAG utilities, and integrationsfrontend/React application
Known Gaps / Future Work
- Persisted audit logs and patient history
- Authentication + role‑based access
- More robust validation for phone numbers and PDF content
- Tests for RAG ingestion and end‑to‑end flows