Skip to content

nikkvijay/Health-Lab-Report-Analyzer

Repository files navigation

Health Lab Report Analyzer (HLRA)

Python FastAPI React TypeScript License

Frontend Deploy Backend Deploy API Docs

A comprehensive web application for analyzing and managing health laboratory reports with OCR capabilities, family profile management, and data visualization.

πŸš€ Live Demo: https://health-lab-report-analyzer.vercel.app
πŸ“š API Docs: https://health-lab-report-analyzer.onrender.com/docs

Features β€’ Live Demo β€’ Installation β€’ API Documentation β€’ Contributing

πŸ“‹ Table of Contents

πŸš€ Live Demo

Frontend Application

URL: https://health-lab-report-analyzer.vercel.app

Experience the full HLRA application with:

  • User registration and authentication
  • Family profile management
  • Health report upload and OCR processing
  • Data visualization and trends
  • Report sharing capabilities

Backend API

URL: https://health-lab-report-analyzer.onrender.com
Interactive Docs: https://health-lab-report-analyzer.onrender.com/docs

Explore the complete API documentation with:

  • All available endpoints
  • Request/response schemas
  • Interactive testing interface
  • Authentication examples

Quick Test

  1. Visit: https://health-lab-report-analyzer.vercel.app
  2. Register a new account or login
  3. Create a family profile
  4. Upload a sample health report (PDF/image)
  5. View the processed data and insights

Note: The backend may take a few seconds to wake up on first request (Render free tier)

✨ Features

Core Features

  • πŸ“„ Document Processing: Upload and analyze PDF, JPG, PNG health reports using OCR
  • πŸ‘₯ Family Profile Management: Create and manage multiple family member profiles
  • πŸ“Š Data Visualization: Interactive charts and trends for health metrics
  • πŸ”— Report Sharing: Secure sharing of health reports with customizable access
  • πŸ”” Notifications: Real-time notifications for report updates and sharing
  • πŸŒ™ Dark/Light Mode: Toggle between dark and light themes
  • πŸ“± Responsive Design: Mobile-friendly interface

Technical Features

  • πŸ” JWT Authentication: Secure user authentication and authorization
  • πŸ“ File Upload: Drag-and-drop file upload with progress tracking
  • πŸ” OCR Integration: Extract text from medical documents using Tesseract
  • πŸ’Ύ MongoDB Integration: Robust data storage and retrieval
  • ⚑ Real-time Updates: Live data synchronization
  • 🎯 Type Safety: Full TypeScript implementation
  • πŸ§ͺ Comprehensive Testing: Unit and integration tests

πŸ›  Technology Stack

Backend

  • Framework: FastAPI 0.104+
  • Language: Python 3.11+
  • Database: MongoDB with Motor (async driver)
  • Authentication: JWT with python-jose
  • OCR: Tesseract with pytesseract
  • PDF Processing: PyPDF2, pdfplumber, pdf2image
  • Testing: pytest, pytest-asyncio

Frontend

  • Framework: React 19+ with TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • UI Components: Radix UI
  • State Management: TanStack Query, React Context
  • Form Handling: React Hook Form with Zod validation
  • Charts: Recharts
  • Testing: Vitest, React Testing Library

DevOps & Deployment

  • Backend Hosting: Render
  • Frontend Hosting: Vercel
  • Containerization: Docker
  • CI/CD: GitHub Actions (optional)

πŸ“ Project Structure

Health-Lab-Report-Analyzer/
β”œβ”€β”€ HLRA-backend/                 # FastAPI Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/v1/              # API endpoints
β”‚   β”‚   β”œβ”€β”€ core/                # Core configurations
β”‚   β”‚   β”œβ”€β”€ database/            # Database connection
β”‚   β”‚   β”œβ”€β”€ models/              # Pydantic models
β”‚   β”‚   β”œβ”€β”€ schemas/             # Request/Response schemas
β”‚   β”‚   β”œβ”€β”€ services/            # Business logic
β”‚   β”‚   └── utils/               # Utility functions
β”‚   β”œβ”€β”€ tests/                   # Backend tests
β”‚   β”œβ”€β”€ uploads/                 # File upload directory
β”‚   β”œβ”€β”€ requirements.txt         # Python dependencies
β”‚   β”œβ”€β”€ Dockerfile              # Container configuration
β”‚   └── render.yaml             # Render deployment config
β”œβ”€β”€ HLRA-frontend/               # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”œβ”€β”€ pages/              # Page components
β”‚   β”‚   β”œβ”€β”€ contexts/           # React contexts
β”‚   β”‚   β”œβ”€β”€ hooks/              # Custom hooks
β”‚   β”‚   β”œβ”€β”€ services/           # API services
β”‚   β”‚   β”œβ”€β”€ types/              # TypeScript types
β”‚   β”‚   └── utils/              # Utility functions
β”‚   β”œβ”€β”€ public/                 # Static assets
β”‚   β”œβ”€β”€ package.json            # Node dependencies
β”‚   β”œβ”€β”€ vercel.json            # Vercel deployment config
β”‚   └── vite.config.ts         # Vite configuration
β”œβ”€β”€ DEPLOYMENT.md               # Deployment guide
└── README.md                   # This file

πŸš€ Installation

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • MongoDB (local or Atlas)
  • Tesseract OCR (for document processing)

Backend Setup

  1. Clone the repository

    git clone https://github.com/nikkvijay/Health-Lab-Report-Analyzer.git
    cd Health-Lab-Report-Analyzer/HLRA-backend
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp .env.example .env
    # Edit .env with your configuration
  5. Install Tesseract OCR

    • Ubuntu/Debian: sudo apt-get install tesseract-ocr
    • macOS: brew install tesseract
    • Windows: Download from GitHub releases
  6. Run the backend

    python main.py

Frontend Setup

  1. Navigate to frontend directory

    cd ../HLRA-frontend
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env
    # Edit .env with your backend URL
  4. Run the frontend

    npm run dev

Access the Application

🌐 Live Production (Deployed)

πŸ’» Local Development

πŸ“– Usage

Getting Started

  1. Register/Login: Create an account or login with existing credentials
  2. Create Family Profiles: Add family members for organized health tracking
  3. Upload Reports: Drag and drop health reports (PDF, JPG, PNG)
  4. View Analysis: Review extracted data and health metrics
  5. Share Reports: Generate shareable links for specific reports
  6. Track Trends: Monitor health metrics over time with interactive charts

File Upload Guidelines

  • Supported formats: PDF, JPG, JPEG, PNG
  • Maximum file size: 10MB
  • Best practices:
    • Ensure clear, high-resolution images
    • PDF files should have readable text or clear scanned images
    • Avoid blurry or low-contrast documents

Family Profile Management

  • Create separate profiles for each family member
  • Assign reports to specific profiles
  • View consolidated health data per profile
  • Share profile-specific reports

πŸ“š API Documentation

Authentication Endpoints

POST /api/v1/auth/register    # User registration
POST /api/v1/auth/login       # User login
POST /api/v1/auth/refresh     # Refresh access token

File Upload Endpoints

POST /api/v1/upload/file      # Upload health report
GET  /api/v1/upload/files     # List user files
GET  /api/v1/upload/file/{id} # Get specific file

Family Profile Endpoints

GET    /api/v1/family-profiles     # List profiles
POST   /api/v1/family-profiles     # Create profile
PUT    /api/v1/family-profiles/{id} # Update profile
DELETE /api/v1/family-profiles/{id} # Delete profile

Data Extraction Endpoints

POST /api/v1/extraction/process   # Process uploaded file
GET  /api/v1/extraction/results   # Get extraction results

Report Sharing Endpoints

POST /api/v1/shared-reports       # Create shareable link
GET  /api/v1/shared-reports/{id}  # Access shared report

For complete API documentation, visit /docs endpoint when running the backend.

πŸš€ Deployment

🌐 Live Deployment

Frontend (Vercel): https://health-lab-report-analyzer.vercel.app
Backend (Render): https://health-lab-report-analyzer.onrender.com
API Documentation: https://health-lab-report-analyzer.onrender.com/docs

Quick Deploy Guide

Backend (Render) βœ… DEPLOYED

  1. βœ… Push code to GitHub
  2. βœ… Create new Web Service on Render
  3. βœ… Connect repository, select HLRA-backend directory
  4. βœ… Set environment variables
  5. βœ… Deploy successful

Current Status: Live at https://health-lab-report-analyzer.onrender.com

Frontend (Vercel) βœ… DEPLOYED

  1. βœ… Create new project on Vercel
  2. βœ… Import repository, select HLRA-frontend directory
  3. βœ… Set VITE_API_BASE_URL environment variable
  4. βœ… Deploy successful

Current Status: Live at https://health-lab-report-analyzer.vercel.app

Environment Configuration

  • Backend CORS: Updated to allow frontend domain
  • Frontend API URL: Points to Render backend
  • Database: MongoDB Atlas integration active

For detailed deployment instructions, see DEPLOYMENT.md.

πŸ§ͺ Testing

Backend Tests

cd HLRA-backend
pytest tests/ -v --cov=app

Frontend Tests

cd HLRA-frontend
npm test
npm run test:ui    # UI mode
npm run test:coverage

Test Structure

  • Unit Tests: Individual component/function testing
  • Integration Tests: API endpoint testing
  • E2E Tests: Full application flow testing (planned)

πŸ“Š Performance & Monitoring

Backend Performance

  • Async/await: Non-blocking operations
  • Connection pooling: Efficient database connections
  • File streaming: Memory-efficient file handling
  • Caching: Redis integration (planned)

Frontend Performance

  • Code splitting: Lazy loading of components
  • Image optimization: WebP format support
  • Bundle optimization: Tree shaking and minification
  • Caching strategies: Service worker integration (planned)

πŸ”’ Security Features

Backend Security

  • JWT Authentication: Secure token-based auth
  • Password hashing: bcrypt implementation
  • CORS configuration: Restricted origins
  • File validation: Type and size restrictions
  • SQL injection prevention: Parameterized queries

Frontend Security

  • XSS protection: Content sanitization
  • CSRF protection: Token validation
  • Secure storage: httpOnly cookies for tokens
  • Input validation: Zod schema validation

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines.

Development Process

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Code Style

  • Backend: Follow PEP 8, use black formatter
  • Frontend: ESLint + Prettier configuration
  • Commits: Conventional commit messages
  • Documentation: Update relevant docs with changes

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • FastAPI - Modern, fast web framework for APIs
  • React - User interface library
  • Tesseract OCR - Open source OCR engine
  • MongoDB - Document database
  • Tailwind CSS - Utility-first CSS framework
  • Radix UI - Low-level UI primitives

πŸ“ž Support


Made with ❀️ by the HLRA Team

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors