MedSecure is a HIPAA-compliant medical document summarization platform with:
- Backend: FastAPI + MongoDB (Python)
- Frontend: Next.js (JavaScript/React)
- Security: RBAC, PII masking, encryption
┌─────────────────────┐
│ Next.js Frontend │ (Port 3000)
│ - Upload UI │
│ - Results Display │
└──────────┬──────────┘
│ HTTP/JSON
▼
┌─────────────────────┐
│ FastAPI Backend │ (Port 8000)
│ - API Endpoints │
│ - RBAC Security │
│ - PII Masking │
│ - NER Service │
│ - LLM Summarizer │
│ - Verification │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ MongoDB │ (Port 27017)
│ - Document Store │
│ - Summary Cache │
└─────────────────────┘
cd c:\Users\DELL\Medsecure
# Start MongoDB
docker-compose up -d mongo
# Start FastAPI
uvicorn app.main:app --reload --port 8000cd c:\Users\DELL\Medsecure\frontend
# Install dependencies (first time only)
npm install
# Start development server
npm run dev# In backend directory
pytest -v tests/- Frontend: http://localhost:3000
- API Docs: http://localhost:8000/docs
- Database: mongodb://localhost:27017
- Drag-and-drop file upload
- Real-time validation
- Processing indicator
- Error handling
- Masked Document — PII removed with tags
- Generated Summary — AI-powered summary
- Extracted Entities — Medical terms identified
- Verification Status — Hallucination check result
- Quality Metrics — Summary statistics
- RBAC via X-User header
- Client-side error handling
- Secure API communication
- No sensitive data in localStorage
Submit a medical document for processing.
Request:
{
"text": "Patient John Doe...",
"document_id": "optional-id"
}Response:
{
"summary_id": "507f1f77bcf86cd799439011",
"masked_text": "Patient [NAME]...",
"summary": "Patient with...",
"verified": true,
"entities": [{"text": "diabetes", "label": "CONDITION"}]
}Retrieve a previously processed summary.
MONGO_URI=mongodb://localhost:27017
MONGO_DB=medsecure
RBAC_EDITOR_USERS=editor@example.com
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_USER_EMAIL=editor@example.com
docker-compose upStarts:
- MongoDB on port 27017
- FastAPI on port 8000
- Frontend on port 3000
Backend (Docker):
docker build -t medsecure-api .
docker run -p 8000:8000 -e MONGO_URI=mongodb://mongo:27017 medsecure-apiFrontend (Docker):
cd frontend
docker build -t medsecure-frontend .
docker run -p 3000:3000 medsecure-frontend-
Backend Changes
- Edit files in
app/ - FastAPI reloads automatically (--reload)
- Check http://localhost:8000/docs
- Edit files in
-
Frontend Changes
- Edit files in
frontend/pages/,frontend/components/ - Next.js reloads automatically
- Check http://localhost:3000
- Edit files in
-
Adding Features
- Backend: Add service in
app/services/ - Backend: Add endpoint in
app/api/routes.py - Frontend: Update
lib/api.jsand components
- Backend: Add service in
pytest -v tests/bandit -r app
pip-auditnpm run lint
npm run buildMedSecure/
├── app/ # FastAPI backend
├── frontend/ # Next.js frontend
│ ├── pages/
│ │ ├── index.js # Main upload page
│ │ ├── _app.js
│ │ └── _document.js
│ ├── components/
│ │ ├── Header.jsx
│ │ ├── FileUpload.jsx
│ │ ├── ResultsDisplay.jsx
│ │ └── LoadingSpinner.jsx
│ ├── lib/
│ │ └── api.js # API client
│ ├── styles/
│ │ └── globals.css # Tailwind
│ └── package.json
├── docker-compose.yml
├── Dockerfile
└── README.md
- Check backend is running:
http://localhost:8000/docs - Verify
NEXT_PUBLIC_API_URLis correct - Check CORS settings in backend if needed
- Check browser console for errors
docker-compose up -d mongo
mongosh # Connect to test# Frontend
npm run dev -- -p 3001
# Backend
uvicorn app.main:app --reload --port 8001cd frontend
rm -rf node_modules package-lock.json
npm install- ✅ Backend API is running
- ✅ Frontend is running
- Try uploading a test document
- Review results
- Implement Phase 1-3 enhancements in EXECUTION_PIPELINE.md
- Upload: Frontend file reading is instant
- Processing: Backend pipeline typically 1-3 seconds
- Display: Results render immediately
- Scalability: Can optimize with task queue (Celery)
- All PII is masked on the backend (not frontend)
- RBAC is enforced via X-User header (implement OAuth2 for production)
- Encryption keys should be in secure vaults (not .env in production)
- HTTPS required for production deployment
See individual READMEs:
- Backend README — FastAPI setup
- Frontend README — Next.js setup
- EXECUTION_PIPELINE.md — Development phases