A full-stack blockchain application for tracking pharmaceutical products through the supply chain, built on Hyperledger Fabric. This project demonstrates secure, transparent, and auditable product movement from manufacturer to distributor using smart contracts, a Node.js backend, and a Vue 3 frontend.
- Overview
- Architecture
- Project Structure
- Features
- Setup & Installation
- Usage
- Smart Contract
- Backend API
- Frontend
This project simulates a pharmaceutical supply chain, allowing manufacturers to register products, and distributors to ship and track them. It leverages Hyperledger Fabric for blockchain-backed data integrity and traceability.
- Smart Contract (Chaincode): Defines product lifecycle, shipment, and verification logic on the blockchain.
- Backend (Node.js/Express): REST API server that interacts with the chaincode and manages authentication.
- Frontend (Vue 3): User interface for manufacturers and distributors to manage products and shipments.
pharma/
├── .github/ # GitHub Actions CI/CD workflows for automated deployment & network hosting
├── backend/ # Node.js/Express API server
├── contract/ # Hyperledger Fabric chaincode
├── frontend/ # Vue 3 frontend
├── fabric-samples/ # Hyperledger Fabric test network
└── README.md
- Register new pharmaceutical products (manufacturer)
- Ship products to distributors
- Track product status and history
- Role-based authentication (manufacturer/distributor)
- Blockchain-backed audit trail
- Responsive, modern UI
- CI/CD pipelines for automated deployment on a hosted environment
- Node.js (v16+ recommended)
- npm
- Docker & Docker Compose
git clone https://github.com/wyceee/pharma
cd pharmacd backend
npm installcd contract
npm installcd frontend
npm installcurl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh && chmod +x install-fabric.sh
./install-fabric.sh docker samples binary# Bring up the test network and create the channel
cd fabric-samples/test-network
docker ps # Make sure Docker is running
./network.sh down # (Optional) Remove any old network
./network.sh up createChannel -c pharmachannel -ca
# Deploy chaincode
./network.sh deployCC \
-ccn pharma \
-ccp ../../contract \
-ccl javascript \
-c pharmachannel \
-ccv 1
# Register application users
cd ../../backend/node
node registerOrg1User.js
node registerOrg2User.jsCreate a .env file in the backend directory with the following content:
SECRET_KEY=<get_this_from_admin>cd backend
node server.jscd frontend
npm run dev- Access the frontend at http://localhost:5173
- Log in as a manufacturer or distributor
- Add products, ship them, and track their status
- Check the docker logs for tx output
- Located in
contract/pharmaContract.js - Handles product registration, shipment, and verification
- Implements chaincode interface for Hyperledger Fabric
contactservice.jsin the backend provides utility functions for interacting with the chaincode
- Located in
backend/ - Key endpoints:
/api/auth- Authentication/api/product- Product management/api/distribute- Shipment management
- Uses Fabric SDK to interact with the blockchain
- Located in
frontend/ - Vue 3 + Vite + TypeScript
- Key components:
Product.vue- Product registrationShipment.vue- Shipping productsDashboard.vue- Track and view product statusAuth.vue- User authenticationapiConfig.js- API configuration for backend calls depending on environment