MedGuard AI is an intelligent, Django-based web application designed to combat the severe challenge of counterfeit and substandard drugs. It provides a fast, reliable, and multi-modal solution for real-time drug authentication directly at the point of care
The system uses an Agentic AI Workflow to verify medicine authenticity and automatically check for expiry, empowering consumers and healthcare professionals to make informed, instantaneous decisions
Users can verify a drug using three flexible input modes:
- Text Search (Entering the medicine name)
- Image Upload (Uploading a photo of the medicine package)
- Barcode/QR Code Scan (Enabling rapid product identifier retrieval)
The system is built on specialized, cooperating AI agents orchestrated by the Intake Agent (views.py)
- OCR Agent: Uses Google Cloud Vision API to accurately extract text from complex packaging.
- Barcode Agent: Decodes 1D/2D barcodes/QR codes and cross-verifies identifiers with
MajorProjectDataset.csvfor authenticity - Extraction Agent: Uses Regular Expressions (Regex) to isolate key data: MFG Date, EXP Date, and Price (MRP)
- Search Agent: Employs TheFuzz library for fuzzy string matching, handling spelling or OCR errors
- Summary Agent: Uses a Local LLM (Ollama - phi-3) to generate a concise, structured summary (8-point or 5-point) of the verified data
- The system automatically compares the extracted Expiry Date against the current date
- If expired, a clear "
β οΈ EXPIRED MEDICINE" warning is issued
- Includes secure login and signup.
- Offers personalized search history management, allowing users to revisit or delete past verifications
| Category | Technology | Purpose / Library |
|---|---|---|
| Backend | Django Framework (Python 3.10+) | Multi-user web application foundation |
| OCR / Vision | Google Vision API | Image-based text detection |
| Barcode | Pyzbar / OpenCV | Decoding 1D/2D Barcodes and QR Codes |
| LLM / AI | Ollama (phi-3-mini) | Local LLM for summary generation and RAG core |
| Fuzzy Matching | TheFuzz | Handling spelling errors and variations |
| Data Processing | Pandas, NumPy, Regex | Data extraction, matching, and manipulation |
| Database | SQLite3 / PostgreSQL | Data storage and history tracking |
| Frontend | HTML, CSS, JavaScript, Bootstrap | User Interface design |
This project follows a standard Django structure, organized around the main project folder (medguard_project) and the primary application (medicinebot). The Agentic AI workflow logic is contained within the medicinebot/agents/ directory.
MEDGUARD_AI/ βββ medguard_project/ # Main Django Project Configuration β βββ init.py β βββ asgi.py β βββ settings.py β βββ urls.py β βββ wsgi.py βββ medicinebot/ # Primary Django Application (The core logic) β βββ agents/ # Agentic AI Workflow Implementation β β βββ barcode_agent.py # Decodes and verifies barcodes/QR codes β β βββ extraction_agent.py # Regex for MFG, EXP, and Price data β β βββ ocr_agent.py # Google Cloud Vision API integration β β βββ search_agent.py # TheFuzz fuzzy matching logic β β βββ summary_agent.py # Ollama LLM summarization logic β βββ management/ β β βββ commands/ β βββ migrations/ β βββ static/ β β βββ medicinebot/ β β βββ images/ β β βββ logo.png β βββ templates/ β β βββ medicinebot/ β β βββ account-history.html β β βββ base.html β β βββ home.html # Tri-input interface β β βββ login.html β β βββ signup.html β βββ admin.py β βββ apps.py β βββ forms.py β βββ models.py # Database schemas (e.g., Search History, User) β βββ tests.py β βββ urls.py β βββ views.py # Intake Agent (The Orchestrator) βββ ScreenShots/ # Project output and testing screenshots βββ .gitattributes βββ .gitignore βββ gcloud_key.json # Google Cloud Vision API Credentials βββ MajorProjectDataset.csv # Local knowledge base for verification βββ db.sqlite3 # Local Development Database βββ manage.py # Django Command Utility βββ requirements.txt # Python Dependencies βββ venv/ # Python Virtual Environment
This repository is licensed under the All Rights Reserved terms.
You are free to view the code, but reproduction, modification, or reuse is not permitted without permission.
Credits Built by Sai Jagdale β¨