PharmaSentinel is a secure, blockchain-based web application designed to detect and prevent counterfeit medicines in the pharmaceutical supply chain.
Fake and substandard medicines pose a serious global health risk. Traditional supply chain systems rely on centralized databases that can be easily manipulated. PharmaSentinel solves this by assigning each medicine batch its own private blockchain, where every transaction is permanently recorded using SHA-256 hashing and HMAC digital signatures β making all data tamper-proof and fully traceable.
- π JWT-Based Role Authentication β Secure login for 6 roles: Manufacturer, Distributor, Wholesaler, Shopkeeper, Consumer, and Regulatory Authority
- βοΈ Custom Private Blockchain β Each medicine batch has its own blockchain with hash chaining and digital signatures
- π¦ End-to-End Medicine Tracking β Full lifecycle traceability from manufacturer to consumer
- π Counterfeit Detection β Automatic blockchain validation to detect tampering and duplicate transactions
- π± QR Code / Batch ID Verification β Consumers can verify medicine authenticity without login
- ποΈ Regulatory Admin Dashboard β Central control panel for monitoring supply chain compliance
- π Logging & Monitoring β System activity tracking using Python's logging module
| Layer | Technology |
|---|---|
| Backend | Python, Django, Django REST Framework |
| Frontend | React JS, Bootstrap |
| Database | PostgreSQL |
| Authentication | JWT (JSON Web Tokens) |
| Blockchain | Custom Private Blockchain Implementation |
| Cryptography | SHA-256 Hashing, HMAC Digital Signatures |
| Monitoring | Python Logging Module |
Consumer / Stakeholder
β
React JS Frontend
β
Django REST Framework (APIs)
β
JWT Authentication
β
Business Logic Layer
β β
PostgreSQL Custom Blockchain
(User/Batch (Transaction
Data) Records)
| Role | Permissions |
|---|---|
| Regulatory Authority | Full system access, user management, compliance monitoring |
| Manufacturer | Create medicine batches, initiate blockchain |
| Distributor | Receive and transfer medicine batches |
| Wholesaler | Receive and forward medicine batches |
| Shopkeeper | Receive medicines, mark as sold |
| Consumer | Verify medicine authenticity via Batch ID or QR Code |
Each medicine batch gets its own blockchain where every transaction is stored as a block:
Block Structure:
{
"block_index" : 1,
"timestamp" : "2025-01-01 10:00:00",
"transaction_data": { batch_id, action, actor, location },
"previous_hash" : "abc123...",
"hash" : "def456...",
"digital_signature": "hmac_signature"
}
- SHA-256 generates a unique hash for every block
- HMAC digital signatures verify data integrity
- Any tampering breaks the hash chain and is immediately detected
- Python 3.8+
- Node.js & npm
- PostgreSQL
1. Clone the repository
git clone https://github.com/Fizza-Mukhtar/PharmaSentinel.git
cd PharmaSentinel2. Backend Setup
cd backend
pip install -r requirements.txt3. Configure Database
Create a .env file in the backend folder:
DATABASE_NAME=pharmasentinel
DATABASE_USER=your_db_user
DATABASE_PASSWORD=your_db_password
DATABASE_HOST=localhost
DATABASE_PORT=5432
SECRET_KEY=your_django_secret_key4. Run Migrations
python manage.py makemigrations
python manage.py migrate5. Start Backend Server
python manage.py runserver6. Frontend Setup
cd frontend
npm install
npm startThe app will be running at http://localhost:3000
PharmaSentinel/
βββ backend/
β βββ authentication/ # JWT auth & user roles
β βββ blockchain/ # Custom blockchain logic
β βββ medicines/ # Medicine batch management
β βββ supply_chain/ # Transfer & tracking APIs
β βββ dashboard/ # Regulatory admin panel
β βββ manage.py
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Role-based pages
β β βββ App.js
β βββ package.json
βββ README.md
- All passwords are hashed using Django's built-in security
- JWT tokens expire automatically for session safety
- Blockchain hash chaining detects any data tampering
- HMAC signatures verify block integrity
- Role-based access ensures users can only perform authorized actions
- Integration with public blockchain (Ethereum)
- AI-based anomaly detection in supply chain
- SMS/Email alerts for suspicious activity
- Multi-language support
This project is for academic purposes.
"Ensuring every medicine that reaches a patient is genuine β because health cannot be compromised."