Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dhanvantari Technical Architecture & Workflow Report

1. Project Overview

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.


2. Comprehensive Technology Stack

Frontend & User Interface

  • Framework: React 19 with Vite (for lightning-fast Hot Module Replacement and optimized builds).
  • Styling & UI: Tailwind CSS v4, enhanced with shadcn principles.
  • Icons: lucide-react and 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-pwa enabling offline capabilities and "install to home screen" functionality.

Backend, Database & Cloud Services

  • 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.

Web3 & Blockchain (Supply Chain Integrity)

  • 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-react for wallet connections.

Artificial Intelligence

  • Engine: Google Gemini API (@google/generative-ai).
  • Purpose: Ingredient analysis, safety warnings, and layperson explanations of complex medical compositions.

Utilities & Tools

  • QR Scanning: html5-qrcode (device camera integration).
  • QR Generation: qrcode.react, jszip, and file-saver (batch QR code generation and downloading).
  • Notifications: sonner for toast notifications.
  • Charts & Analytics: recharts for dashboard statistics.

3. Step-by-Step Workflows & Tech Involvement

Phase 1: Authentication & Role Management

Tech Used: Firebase Auth, React Router DOM, React Context API.

  • Users authenticate via Google Sign-In using Firebase.
  • The system checks the Firestore users collection to determine the user's role (Admin, Manufacturer, or Consumer).
  • React Context (AuthContext) establishes separate session tokens in localStorage, allowing strict protected routing via React Router DOM. This prevents a consumer from accessing manufacturer tools and vice versa.

Phase 2: Manufacturer Onboarding & Licensing

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 approve or reject the license.

Phase 3: Minting Medicine (The Supply Chain)

Tech Used: Ethers.js, MetaMask SDK, Solidity Smart Contracts, Firestore.

  1. An approved manufacturer enters details for a new batch of medicine (name, ingredients, expiry date, image).
  2. The image is uploaded to Firebase Storage to get a public URL.
  3. The manufacturer connects their Web3 wallet via MetaMask SDK.
  4. The frontend uses Ethers.js to invoke the mintMedicine function on the Dhanvantari Smart Contract on the Polygon network.
  5. 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.

Phase 4: QR Code Generation & Distribution

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 .zip file using JSZip and downloaded to the manufacturer's device via FileSaver.js, ready to be printed and pasted onto physical medicine packaging.

Phase 5: Consumer Verification (Anti-Counterfeiting)

Tech Used: html5-qrcode, Ethers.js, Firestore.

  1. A consumer opens the Dhanvantari app (PWA) on their phone and navigates to the Scanner.
  2. html5-qrcode accesses the device camera and decodes the QR code on the medicine box.
  3. 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.
  4. It simultaneously queries Firestore to retrieve the image and detailed ingredients.
  5. 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".

Phase 6: AI Ingredient Analysis

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.

Phase 7: Consumer Complaints & Feedback Loop

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).

Summary

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.

About

Dhanvantari is a secure, intelligent Progressive Web App (PWA) combating pharmaceutical counterfeiting. It builds a transparent supply chain linking Manufacturers, Consumers, and Administrators. By leveraging Blockchain, AI, and Cloud infrastructure, it ensures medicine authenticity, offers ingredient insights, and aids regulatory oversight.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages