Dhanvantari is a modern, secure, and intelligent Progressive Web Application (PWA) designed to combat pharmaceutical counterfeiting. It provides a transparent supply chain ecosystem connecting Manufacturers, Consumers, and Administrators. By leveraging Blockchain (Web3), Artificial Intelligence (AI), and Cloud Infrastructure, it ensures medicine authenticity, provides deep ingredient insights, and facilitates regulatory oversight.
- Framework: React 19 with Vite (for lightning-fast Hot Module Replacement and optimized builds).
- Styling & UI: Tailwind CSS v4, enhanced with
shadcnprinciples. - Icons:
lucide-reactand FontAwesome. - Animations & 3D Elements: Framer Motion (page transitions), GSAP (complex timeline animations), React Three Fiber & Drei (interactive 3D landing page elements).
- Progressive Web App (PWA):
vite-plugin-pwaenabling offline capabilities and "install to home screen" functionality.
- Infrastructure: Firebase ecosystem (Firebase v11).
- Authentication: Firebase Authentication (Google OAuth provider).
- Database: Cloud Firestore (NoSQL database for user profiles, medicine metadata, licenses, and complaints).
- Storage: Firebase Cloud Storage (for medicine images and complaint evidence photos).
- Hosting: Firebase Hosting.
- Network: Polygon Amoy Testnet (Fast, low-cost Layer 2 Ethereum scaling solution).
- Smart Contracts: Solidity, built using OpenZeppelin ERC-721 standard (NFTs representing unique medicine batches).
- Development Environment: Hardhat (for compiling, testing, and deploying contracts).
- Frontend Web3 Integration:
ethers.js(v6) for blockchain read/write operations, and@metamask/sdk-reactfor wallet connections.
- Engine: Google Gemini API (
@google/generative-ai). - Purpose: Ingredient analysis, safety warnings, and layperson explanations of complex medical compositions.
- QR Scanning:
html5-qrcode(device camera integration). - QR Generation:
qrcode.react,jszip, andfile-saver(batch QR code generation and downloading). - Notifications:
sonnerfor toast notifications. - Charts & Analytics:
rechartsfor dashboard statistics.
Tech Used: Firebase Auth, React Router DOM, React Context API.
- Users authenticate via Google Sign-In using Firebase.
- The system checks the Firestore
userscollection to determine the user's role (Admin, Manufacturer, or Consumer). - React Context (
AuthContext) establishes separate session tokens inlocalStorage, allowing strict protected routing via React Router DOM. This prevents a consumer from accessing manufacturer tools and vice versa.
Tech Used: Firestore, React Forms.
- A new manufacturer submits their company details, registration numbers, and compliance documents.
- This data is stored in Firestore with a status of
pending. - The Admin Portal (protected by an Admin Private Key) queries Firestore, allowing admins to review and
approveorrejectthe license.
Tech Used: Ethers.js, MetaMask SDK, Solidity Smart Contracts, Firestore.
- An approved manufacturer enters details for a new batch of medicine (name, ingredients, expiry date, image).
- The image is uploaded to Firebase Storage to get a public URL.
- The manufacturer connects their Web3 wallet via MetaMask SDK.
- The frontend uses Ethers.js to invoke the
mintMedicinefunction on the Dhanvantari Smart Contract on the Polygon network. - Once the blockchain transaction confirms (creating an immutable, timestamped record of authenticity), the detailed, non-critical metadata (like high-res images and long descriptions) is saved to Firestore, linked to the newly minted token ID.
Tech Used: qrcode.react, jszip, file-saver.
- The manufacturer selects the newly minted batch and clicks "Generate QR Codes".
- The system generates unique QR codes encoding the smart contract address and the specific Token ID.
- These are packaged into a
.zipfile using JSZip and downloaded to the manufacturer's device via FileSaver.js, ready to be printed and pasted onto physical medicine packaging.
Tech Used: html5-qrcode, Ethers.js, Firestore.
- A consumer opens the Dhanvantari app (PWA) on their phone and navigates to the Scanner.
- html5-qrcode accesses the device camera and decodes the QR code on the medicine box.
- The app extracts the Token ID and queries the Polygon Blockchain (via public RPC/Ethers.js, no wallet required for consumers) to check if the token exists and who the original minter (manufacturer) was.
- It simultaneously queries Firestore to retrieve the image and detailed ingredients.
- If the token is valid, the app displays a green "Authentic" screen. If the smart contract returns an error (or the token was marked recalled), it flags it as "Counterfeit" or "Recalled".
Tech Used: Google Gemini API (@google/generative-ai).
- On the Verification Results page, a consumer can click "Analyze Ingredients with AI".
- The app takes the medicine's ingredient list (fetched from Firestore) and constructs a precise prompt.
- The Gemini API streams back a structured response detailing what the medicine is used for, potential side effects, and safety warnings in easy-to-understand language.
Tech Used: Firebase Storage, Firestore.
- If a consumer experiences adverse effects or suspects tampering, they can file a complaint.
- They upload a photo of the medicine (saved to Firebase Storage) and describe the issue.
- The complaint is logged in Firestore.
- Administrators use the Admin Portal to review these complaints and, if necessary, take action (e.g., initiating a blockchain-level recall of a specific batch).
Dhanvantari utilizes React/Vite for a highly responsive, app-like frontend. It relies on Firebase for rapid data synchronization, secure authentication, and media storage. It uses the Polygon Blockchain to establish an unbreakable, immutable chain of custody for pharmaceuticals, and it integrates Google Gemini AI to empower consumers with accessible medical knowledge.