Skip to content

sohail9972/CareGuide_AI

Repository files navigation

CareGuide AI - Prescription OCR & Medicine Detection

README last updated: March 9, 2026

CareGuide AI is an intelligent system that extracts text from prescription images and automatically identifies medicines using OCR and NLP technologies.

Features

  • OCR (Optical Character Recognition): Extracts text from prescription images using Tesseract or EasyOCR depending on configuration, or optionally by calling an Amazon Bedrock multimodal model when provider=aws is selected.
    • You can force a specific engine by setting OCR_ENGINE environment variable (pytesseract, easyocr, or auto)
    • Preprocessing pipeline includes denoising, contrast enhancement, CLAHE, deskewing, and morphological filtering
    • EasyOCR often provides better results on messy handwritten prescriptions
  • Medicine Detection: Identifies medicine names from extracted text using pattern matching and spaCy NER locally, or utilises a Bedrock Agent connected to a medical Knowledge Base for AWS workflows
  • Image Preprocessing: Advanced image enhancement for better OCR accuracy
  • FastAPI Backend: RESTful API for prescription processing
  • Modern Frontend: Next.js-based user interface

Project Structure

CareGuide_AI/
├── backend/                    # Python FastAPI backend
│   ├── app/
│   │   ├── main.py            # FastAPI application
│   │   ├── models.py          # Database models
│   │   ├── database.py        # Database configuration
│   │   ├── routers/           # API routes
│   │   │   └── prescription.py
│   │   └── services/          # Business logic
│   │       ├── ocr_service.py     # Tesseract OCR integration
│   │       └── nlp_service.py     # Medicine detection
│   └── requirements.txt        # Python dependencies
│
└── careguide-frontend/        # Next.js frontend
    ├── app/
    ├── components/
    └── public/

Installation

Backend Setup

  1. Install Tesseract OCR:

  2. Install Python Dependencies:

    cd backend
    pip install -r requirements.txt
    python -m spacy download en_core_web_sm
  3. Install OpenCV (for advanced image processing):

    pip install opencv-python

Frontend Setup

cd careguide-frontend
npm install
npm run dev

Running the Application

Start Backend Server

cd backend
python -m uvicorn app.main:app --reload --host 127.0.0.1 --port 8000

Access the API documentation at: http://127.0.0.1:8000/docs

Start Frontend

cd careguide-frontend
npm run dev

API Endpoints

Upload Prescription

  • Endpoint: POST /upload-prescription
  • Content-Type: multipart/form-data
  • Parameter: file (image file)
  • Response:
    {
      "extracted_text": "...",
      "medicines_detected": ["aspirin", "paracetamol", ...]
    }

Technologies Used

Backend

  • FastAPI: Modern Python web framework
  • Tesseract OCR: Optical character recognition
  • Spacy: NLP for entity recognition
  • SQLAlchemy: ORM for database operations
  • OpenCV: Advanced image processing

Frontend

  • Next.js: React framework
  • TypeScript: Type-safe JavaScript
  • Tailwind CSS: Utility-first CSS framework

Configuration

Tesseract Path

If Tesseract is installed in a custom location, set the environment variable:

$env:TESSERACT_PATH = "C:\Program Files\Tessract_OCR\tesseract.exe"

Future Enhancements

  • Cloud storage integration for prescriptions
  • Document management system
  • User authentication and profiles
  • Prescription history tracking
  • Export reports (PDF, CSV)
  • Mobile app support

Recent Changes

This project has seen a major update on March 9, 2026 which included:

  • Added comprehensive AWS documentation and setup guides (AWS_*.md).
  • Introduced new backend services:
    • aws_service.py for AWS interactions.
    • aws_lambda_handler.py for Lambda deployment.
    • Updated OCR service and prescription router logic.
  • Included SQLite database placeholder (careguide.db) and CloudFormation template (template.yaml).
  • Expanded frontend with authentication, dashboard, and diet-plan pages.
  • Added Tailwind configuration for styling.
  • Added various helper scripts for AWS setup and knowledge-base ingestion.
  • Added design and requirement specifications under specs/.

These additions bring AWS deployment, improved UI features, and a more structured development workflow.

License

MIT License - feel free to use this project for personal or educational purposes.

Author

Sohail (@sohail9972)

Support

For issues, questions, or suggestions, please open an issue on GitHub.

Custom OCR Models

If you have a specialized OCR model (for example, a trained Tesseract language pack or a deep learning model), you can integrate it by modifying backend/app/services/ocr_service.py. The code already supports an OCR_ENGINE environment variable and will use EasyOCR by default if available. Feel free to supply your model code here and I can help wire it in.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors