A comprehensive Django-based pharmacy management system with shopping cart functionality and OCR (Optical Character Recognition) capabilities for prescription processing.
Try the demo immediately after setup:
- Run the development server:
python manage.py runserver - Go to admin panel:
http://127.0.0.1:8000/admin/ - Login with: Username:
admin| Password:1234 - Explore the pharmacy management features!
- Product Management: Add, view, update, and remove pharmaceutical products
- Inventory Tracking: Monitor stock levels and expiry dates
- Shopping Cart: Add products to cart, manage quantities, and checkout
- OCR Integration: Extract text from prescription images using Tesseract
- Low Stock Alerts: Identify products with low inventory
- Expiry Monitoring: Track products nearing expiration
- Patient Information: Capture customer details during checkout
- Invoice Generation: Generate invoices for completed orders
- Admin Panel: Django admin interface for system management
- Backend: Django 5.0.6
- Database: MySQL
- OCR Engine: Tesseract OCR with pytesseract
- Image Processing: Pillow (PIL)
- Server: Gunicorn
- Frontend: HTML templates with Django templating
- Environment: Python virtual environment
Before running this project, make sure you have the following installed:
- Python 3.8+
- MySQL Server
- Tesseract OCR
- pip (Python package manager)
Windows:
- Download from: https://github.com/UB-Mannheim/tesseract/wiki
- Install and note the installation path
- Update the tesseract path in
products/views.pyif needed
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install tesseract-ocrmacOS:
brew install tesseractgit clone https://github.com/saikrishna-avskr/rtfp-1.git
cd rtfp-1python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatecd pharmassit
pip install -r requirements.txtCreate a .env file in the root directory with the following variables:
# Database Configuration
DB_ENGINE=django.db.backends.mysql
DB_NAME=pharmassist
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=3306
# Django Configuration
SECRET_KEY=your_secret_key_here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1# Create database migrations
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Create superuser (admin)
python manage.py createsuperuserpython manage.py runserverThe application will be available at http://127.0.0.1:8000
For demonstration purposes, use the following credentials to access the admin panel:
Admin Login:
- Username:
admin - Password:
Admin@1234
Note: These are demo credentials for testing purposes only. In production, use strong, unique passwords.
rtfp-1/
βββ .env # Environment variables
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
βββ pharmassit/ # Main Django project
β βββ manage.py # Django management script
β βββ requirements.txt # Python dependencies
β βββ pharmassit/ # Project configuration
β β βββ settings.py # Django settings
β β βββ urls.py # Main URL configuration
β β βββ wsgi.py # WSGI configuration
β β βββ asgi.py # ASGI configuration
β βββ products/ # Products app
β β βββ models.py # Product data models
β β βββ views.py # Product views & OCR logic
β β βββ urls.py # Product URL patterns
β β βββ templates/ # Product HTML templates
β βββ cart/ # Shopping cart app
β βββ models.py # Cart data models
β βββ views.py # Cart functionality
β βββ urls.py # Cart URL patterns
β βββ templates/ # Cart HTML templates
βββ tobeadded/ # Additional OCR scripts
βββ ocr.py # Camera-based OCR
βββ ocr2.py # Enhanced OCR functionality
βββ ... # Other OCR implementations
class Product(models.Model):
pid = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
generic_name = models.CharField(max_length=255)
expiry_date = models.DateField()
price = models.FloatField()
stock = models.IntegerField()
storage_loc = models.CharField(max_length=255)
image = models.CharField(max_length=2083)class Cart(models.Model):
product = models.OneToOneField(Product, on_delete=models.CASCADE)
pid = models.IntegerField(null=True)
quantity = models.IntegerField(null=True)
price = models.FloatField(null=True)
tot_price = models.FloatField(null=True)/- Home page/products/details/- Product listing and search/products/find_exp_items/- Find expiring products/products/find_low_stock/- Find low stock items/products/remove_product/<int:pid>/- Remove product/products/show_upload/- Upload prescription form/products/upload_report/- Process uploaded prescription
/cart/add/<int:pid>/- Add product to cart/cart/remove/<int:pid>/- Remove product from cart/cart/show/- View cart contents/cart/update/<int:product_id>/- Update cart quantity/cart/clear/- Clear entire cart/cart/checkout/- Checkout process/cart/order/- Process order
The system includes OCR capabilities to process prescription images:
- Upload Prescription: Users can upload prescription images
- Text Extraction: Tesseract OCR extracts text from images
- Product Matching: System matches extracted text with product database
- Auto-Add to Cart: Matching products are automatically added to cart
Update the Tesseract path in products/views.py:
pytesseract.pytesseract.tesseract_cmd = 'path/to/tesseract.exe'- Access Django admin panel at
/admin/ - Demo Login: Username:
admin, Password:1234 - Manage products, inventory, and system settings
- View reports and analytics
- Browse products
- Add items to cart
- Process orders
- Upload prescriptions
- Set
DEBUG=Falsein environment variables - Configure proper
ALLOWED_HOSTS - Use production database (PostgreSQL recommended)
- Configure static files serving
- Use Gunicorn for WSGI server
gunicorn pharmassit.wsgi:application --bind 0.0.0.0:8000Run tests using Django's test framework:
python manage.py test- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
-
Tesseract Not Found
- Ensure Tesseract is installed and path is correctly set
- Update the tesseract_cmd path in views.py
-
Database Connection Error
- Verify MySQL is running
- Check database credentials in .env file
- Ensure database exists
-
Import Errors
- Activate virtual environment
- Install all requirements:
pip install -r requirements.txt
-
Static Files Not Loading
- Run:
python manage.py collectstatic - Check STATIC_ROOT and STATIC_URL settings
- Run:
For support and questions:
- Create an issue on GitHub
- Contact: saikrishnaavskr@gmail.com
- Django Community for the excellent framework
- Tesseract OCR team for OCR capabilities
- Contributors and testers
Note: This is a development version. For production use, please implement proper security measures, error handling, and testing.