A comprehensive Recall Management and Anti-Counterfeiting system for pharmaceutical blockchain applications built with React, TypeScript, Node.js, Express, Solidity, and PostgreSQL.
- Quick Recall Initiation: Create recalls with severity levels (LOW, MEDIUM, HIGH, CRITICAL)
- Batch Search & Selection: Search and select multiple batches for recall
- Distribution Chain Tracking: Track affected distribution channels
- Real-time Notifications: Notify stakeholders automatically
- Status Management: Track recall status from initiation to resolution
- Visual Security Features: QR code and hologram verification
- Authenticity Checking: Multi-layer verification system
- Suspicious Activity Reporting: Report and investigate counterfeit activities
- Real-time Verification: Instant verification status updates
- Security Feature Generation: Create unique security identifiers
- Smart Contracts: Solidity contracts for immutable record keeping
- Event Emission: Real-time blockchain events for recalls and suspicious activities
- Transparent Audit Trail: Complete transaction history
- Decentralized Verification: Distributed verification system
- React 18 with TypeScript
- Material-UI for modern UI components
- Web3.js for blockchain integration
- QR Code generation and scanning
- Data Grid for tabular data display
- Node.js with Express
- TypeScript for type safety
- PostgreSQL database
- Sequelize ORM
- Winston logging
- Joi validation
- Solidity smart contracts
- Hardhat development framework
- Web3.js for blockchain interaction
- OpenZeppelin security libraries
- Jest for unit testing
- Hardhat for smart contract testing
- Comprehensive test coverage
pharma-blockchain-system/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── RecallManagement/
│ │ │ └── AntiCounterfeit/
│ │ ├── services/ # API services
│ │ ├── types/ # TypeScript type definitions
│ │ └── App.tsx
│ └── package.json
├── backend/ # Node.js backend API
│ ├── src/
│ │ ├── services/ # Business logic services
│ │ ├── routes/ # API routes
│ │ ├── database/ # Database schema and models
│ │ ├── utils/ # Utility functions
│ │ └── index.ts
│ └── package.json
├── contracts/ # Solidity smart contracts
│ ├── contracts/ # Smart contract source code
│ ├── test/ # Smart contract tests
│ ├── scripts/ # Deployment scripts
│ └── hardhat.config.js
└── README.md
- Node.js 16+ and npm
- PostgreSQL 12+
- Git
git clone <repository-url>
cd pharma-blockchain-system# Install root dependencies
npm install
# Install frontend dependencies
cd frontend && npm install && cd ..
# Install backend dependencies
cd backend && npm install && cd ..
# Install contract dependencies
cd contracts && npm install && cd ..# Create PostgreSQL database
createdb pharma_blockchain
# Run database schema
psql -d pharma_blockchain -f backend/src/database/schema.sql# Copy environment files
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
# Edit the environment files with your configurationcd contracts
# Start local blockchain (in one terminal)
npx hardhat node
# Deploy contracts (in another terminal)
npx hardhat run scripts/deploy.js --network localhost# Start backend (in one terminal)
cd backend && npm run dev
# Start frontend (in another terminal)
cd frontend && npm startThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Health Check: http://localhost:3001/health
POST /api/recalls/initiate
Content-Type: application/json
{
"batchIds": ["BATCH-001", "BATCH-002"],
"severity": "HIGH",
"reason": "Contaminated batch detected",
"initiatedBy": "manufacturer@pharma.com"
}GET /api/recalls/{recallId}/statusPATCH /api/recalls/{recallId}/status
Content-Type: application/json
{
"status": "RESOLVED",
"resolutionNotes": "All affected batches recovered"
}POST /api/counterfeit/verify
Content-Type: application/json
{
"batchId": "BATCH-001",
"verificationType": "QR_SCAN",
"providedData": "qr_code_data"
}POST /api/counterfeit/report
Content-Type: application/json
{
"batchId": "BATCH-001",
"reporterName": "John Doe",
"reporterEmail": "john@example.com",
"reportType": "SUSPICIOUS_PACKAGING",
"description": "Packaging appears tampered with",
"evidenceUrls": ["https://example.com/evidence.jpg"],
"location": "New York, NY"
}initiateRecall(): Create new recalladdBatchToRecall(): Add batch to existing recallupdateRecallStatus(): Update recall statusrecordDistribution(): Record distribution informationgetRecall(): Get recall detailsisBatchInRecall(): Check if batch is recalled
createSecurityFeature(): Generate security featuresverifyAuthenticity(): Verify product authenticityreportSuspiciousActivity(): Report suspicious activitiesupdateReportStatus(): Update report investigation statusgetSecurityFeature(): Get security feature detailsgetFlaggedBatches(): Get list of flagged batches
- recalls: Recall information and metadata
- recall_batches: Batches affected by recalls
- distribution_tracking: Distribution chain tracking
- security_features: Product security features
- counterfeit_reports: Suspicious activity reports
- verification_logs: Authentication verification history
# Run frontend tests
cd frontend && npm test
# Run backend tests
cd backend && npm test
# Run smart contract tests
cd contracts && npm test- Unit tests for all services
- Integration tests for API endpoints
- Smart contract functionality tests
- End-to-end user flow tests
- Access control with role-based permissions
- Reentrancy protection
- Input validation and sanitization
- Event emission for transparency
- Input validation with Joi
- SQL injection prevention with Sequelize
- CORS configuration
- Helmet security headers
- Rate limiting (recommended for production)
- Input sanitization
- XSS protection
- Secure API communication
- Environment variable protection
- Set up production database
- Deploy smart contracts to mainnet/testnet
- Configure environment variables
- Set up reverse proxy (nginx)
- Enable HTTPS
- Set up monitoring and logging
# Build and run with Docker Compose
docker-compose up -d- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation
- ✅ Basic recall management
- ✅ Anti-counterfeiting verification
- ✅ Smart contract implementation
- ✅ Web interface
- 🔄 Mobile application
- 🔄 Advanced analytics dashboard
- 🔄 Integration with existing pharma systems
- 🔄 Machine learning for counterfeit detection
- 🔄 IoT device integration
- 🔄 Supply chain optimization
- 🔄 Regulatory compliance automation
- 🔄 Multi-blockchain support