A Flask-based web application that validates medicine barcodes using real-time API detection from OpenFDA, RxNorm, and product databases.
- OpenFoodFacts API - Global product barcode lookup
- OpenFDA API - FDA drug database verification
- RxNorm API - NIH medicine validation
- UPC Database - Alternative product lookup
- π· Live barcode scanning using device camera
- π Medicine name search across multiple databases
- π Expiry date validation with color-coded alerts
- β Multi-source verification for authenticity
- π± Responsive design - works on all devices
- π¨ Beautiful UI with real-time updates
medicine-validator/
β
βββ app.py                      # Flask backend with API integration
βββ requirements.txt            # Python dependencies
βββ README.md                   # This file
β
βββ templates/
β   βββ index.html             # Frontend HTML
β
βββ static/
    βββ style.css              # CSS styling
    βββ script.js              # JavaScript logic
- Python 3.7 or higher
- pip (Python package manager)
- Modern web browser (Chrome, Firefox, Safari, Edge)
mkdir medicine-validator
cd medicine-validatormkdir templates
mkdir staticCreate the following files in their respective locations:
Root directory:
- app.py
- requirements.txt
- README.md
templates/ folder:
- index.html
static/ folder:
- style.css
- script.js
pip install -r requirements.txtOr install manually:
pip install Flask==3.0.0 flask-cors==4.0.0 requests==2.31.0python app.pyOpen your browser and navigate to:
http://localhost:5000
- Click "Start Camera" button
- Point camera at medicine barcode
- App automatically scans and validates
- View detailed results
- Enter barcode number in the input field
- Optionally add expiry date
- Click "Scan" button
- View results
- Enter medicine name (e.g., "Aspirin")
- Click "Search" button
- View FDA and RxNorm data
Try these real product barcodes:
| Barcode | Description | 
|---|---|
| 5000112576306 | Paracetamol (UK) | 
| 0363824792170 | US Medicine Product | 
| 8901030835506 | Indian Product | 
- Aspirin - Pain reliever
- Ibuprofen - Anti-inflammatory
- Amoxicillin - Antibiotic
- Metformin - Diabetes medication
Scan and validate a barcode
Request:
{
  "barcode": "5000112576306",
  "expiry_date": "2026-12-31"
}Response:
{
  "success": true,
  "barcode": "5000112576306",
  "barcode_lookup": {
    "found": true,
    "name": "Paracetamol 500mg",
    "source": "OpenFoodFacts"
  },
  "fda_data": {
    "found": true,
    "brand_name": "Paracetamol",
    "manufacturer": "Generic Pharma"
  },
  "rxnorm": {
    "validated": true,
    "rxcui": "161",
    "name": "Acetaminophen"
  },
  "expiry_status": {
    "status": "valid",
    "message": "β
 Valid for 750 days",
    "days_remaining": 750
  }
}Search medicine by name
Request:
{
  "name": "Aspirin"
}Response:
{
  "success": true,
  "medicine_name": "Aspirin",
  "fda_data": { ... },
  "rxnorm": { ... }
}The app provides color-coded expiry status:
| Color | Status | Description | 
|---|---|---|
| π’ Green | Valid | More than 90 days remaining | 
| π‘ Yellow | Warning | 30-90 days remaining | 
| π Orange | Expiring Soon | Less than 30 days | 
| π΄ Red | Expired | Past expiry date | 
Edit app.py, last line:
app.run(debug=True, host='0.0.0.0', port=8080)  # Change port hereModify timeout in app.py:
response = requests.get(url, timeout=10)  # Increase timeout- URL: https://api.fda.gov/drug/ndc.json
- Limit: 240 requests per minute
- Documentation: https://open.fda.gov/apis/
- URL: https://rxnav.nlm.nih.gov/REST
- Free to use
- Documentation: https://rxnav.nlm.nih.gov/
- URL: https://world.openfoodfacts.org/api
- Free and open source
- Documentation: https://wiki.openfoodfacts.org/
- β No data stored on server
- β CORS enabled for API calls
- β Input validation on all endpoints
- β Error handling for API failures
- Disable Debug Mode
app.run(debug=False)- Add Rate Limiting
from flask_limiter import Limiter
limiter = Limiter(app, default_limits=["100 per hour"])- Use Environment Variables
import os
SECRET_KEY = os.getenv('SECRET_KEY')- Enable HTTPS
gunicorn --certfile=cert.pem --keyfile=key.pem app:apppip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:apppip install waitress
waitress-serve --port=5000 app:appCreate Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]Build and run:
docker build -t medicine-validator .
docker run -p 5000:5000 medicine-validator- Issue: Browser blocks camera access
- Solution:
- Use HTTPS (required for camera on most browsers)
- Check browser permissions
- Try different browser (Chrome recommended)
 
- Issue: APIs not responding
- Solution:
- Check internet connection
- Increase timeout in code
- APIs might be temporarily down
 
- Issue: Product not in databases
- Solution:
- Try different barcode
- Use medicine name search instead
- Some products may not be in global databases
 
- Issue: Port 5000 occupied
- Solution:
# Linux/Mac
lsof -ti:5000 | xargs kill
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F- User authentication system
- Database integration (PostgreSQL/MongoDB)
- Medicine interaction checker
- Batch recall notifications
- Multi-language support
- Mobile app (React Native)
- QR code generation for custom medicines
- Export reports to PDF
- Analytics dashboard
- Push notifications for expiry alerts
Contributions are welcome! Please:
- Fork the repository
- Create feature branch
- Commit changes
- Push to branch
- Open pull request
This project is open source and available for educational purposes.
For issues or questions:
- Open an issue on GitHub
- Check documentation
- Review troubleshooting section
This application is for educational and informational purposes only.
Important Notes:
- Not a substitute for professional medical advice
- Always consult healthcare professionals
- Verify medicine information with official sources
- Use at your own risk
- OpenFDA - FDA drug database
- RxNorm - NIH medicine database
- OpenFoodFacts - Open product database
- html5-qrcode - Barcode scanning library
Built with β€οΈ using Flask, Python, and Open APIs
Version: 1.0.0
Last Updated: 2025