# raviyaa27/counterfeit-medicine-checker architecture

> Architecture diagram of the GitHub repository raviyaa27/counterfeit-medicine-checker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raviyaa27/counterfeit-medicine-checker
- Repository: https://github.com/raviyaa27/counterfeit-medicine-checker

## Overview

Counterfeit Medicine Checker is a blockchain-backed medicine-authenticity product. Manufacturers register batches, the regulator approves or recalls them, supply-chain participants transfer custody, pharmacies record sales, and patients check pack serials and custody without a wallet. The frontend has role-specific pages and a public verification view; the Solidity registry is the shared on-chain source of truth. The source excerpts show verification and custody reads, transaction submission, and shared UI components; other page-to-contract actions are represented from the README’s workflow descriptions.

Main entry points: [`contracts/src/MedicineRegistry.sol`](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/contracts/src/MedicineRegistry.sol) (Medicine registry), [`frontend/app/admin/page.tsx`](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/admin/page.tsx) (Regulator page), [`frontend/lib/tx.ts`](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/tx.ts) (Transaction submission), [`frontend/components/SupplyPanel.tsx`](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/SupplyPanel.tsx) (Batch transfers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_admin["Regulator page<br/>[page.tsx]"]
  node_batch_admin["Batch approval<br/>[BatchAdmin.tsx]"]
  node_participants["Participant management"]
  node_participant_list["Participant list"]
  node_org_name["Organization names<br/>[OrgName.tsx]"]
  node_ui_providers["Wallet and query providers<br/>[providers.tsx]"]
  node_tx["Transaction submission<br/>[tx.ts]"]
  node_config["Chain configuration<br/>[config.ts]"]
  node_abi["Registry interface<br/>[registryAbi.ts]"]
end

subgraph group_operations["Supply operations"]
  node_manufacturer["Manufacturer page<br/>[page.tsx]"]
  node_batch_form["Batch registration<br/>[NewBatchForm.tsx]"]
  node_supply_page["Supply page<br/>[page.tsx]"]
  node_supply_panel["Batch transfers<br/>[SupplyPanel.tsx]"]
  node_trail["Custody trail<br/>[CustodyTrail.tsx]"]
  node_pharmacy["Pharmacy page<br/>[page.tsx]"]
  node_dispense["Record sale<br/>[DispenseForm.tsx]"]
end

subgraph group_verification["Patient verification"]
  node_verify_page["Verify page<br/>[page.tsx]"]
  node_verify_result["Verification result<br/>[VerifyResult.tsx]"]
end

subgraph group_chain["On-chain registry"]
  node_registry[("Medicine registry")]
end

node_manufacturer_actor(("Manufacturer"))
node_regulator_actor(("NMRA regulator"))
node_distributor_actor(("Distributor"))
node_pharmacy_actor(("Pharmacy"))
node_patient_actor(("Patient"))
node_chain_service{{"Ethereum network"}}

node_manufacturer_actor -->|"registers batch"| node_manufacturer
node_manufacturer -.->|"registers through"| node_batch_form
node_batch_form -->|"registers batch"| node_registry
node_regulator_actor -->|"manages registry"| node_admin
node_admin -.->|"approves or recalls"| node_batch_admin
node_batch_admin -->|"approves or recalls"| node_registry
node_admin -.->|"registers participants"| node_participants
node_participants -->|"registers participants"| node_registry
node_admin -.->|"views participants"| node_participant_list
node_distributor_actor -->|"ships batches"| node_supply_page
node_supply_page -.->|"shows transfers"| node_supply_panel
node_supply_panel -->|"transfers batches"| node_registry
node_supply_panel -->|"renders trail"| node_trail
node_supply_panel -->|"submits transfer"| node_tx
node_pharmacy_actor -->|"records sale"| node_pharmacy
node_pharmacy -.->|"marks packs sold"| node_dispense
node_dispense -->|"records sale"| node_registry
node_patient_actor -->|"scans pack code"| node_verify_page
node_verify_page -.->|"shows verdict"| node_verify_result
node_verify_result -->|"reads verification"| node_registry
node_verify_result -->|"renders trail"| node_trail
node_trail -->|"reads custody history"| node_registry
node_trail -->|"renders organizations"| node_org_name
node_verify_result -->|"renders organization"| node_org_name
node_batch_admin -->|"renders organizations"| node_org_name
node_tx -->|"uses chain settings"| node_config
node_tx -->|"encodes calls"| node_abi
node_tx -->|"submits transactions"| node_registry
node_registry -->|"stores registry state"| node_chain_service
node_ui_providers -->|"configures wallet"| node_config

click node_manufacturer "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/manufacturer/page.tsx"
click node_batch_form "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/NewBatchForm.tsx"
click node_supply_page "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/supply/page.tsx"
click node_supply_panel "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/SupplyPanel.tsx"
click node_trail "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/CustodyTrail.tsx"
click node_pharmacy "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/pharmacy/page.tsx"
click node_dispense "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/DispenseForm.tsx"
click node_admin "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/admin/page.tsx"
click node_batch_admin "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/BatchAdmin.tsx"
click node_participants "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/RegisterParticipantForm.tsx"
click node_participant_list "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/ParticipantList.tsx"
click node_verify_page "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/verify/page.tsx"
click node_verify_result "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/VerifyResult.tsx"
click node_org_name "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/OrgName.tsx"
click node_ui_providers "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/providers.tsx"
click node_tx "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/tx.ts"
click node_config "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/config.ts"
click node_abi "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/registryAbi.ts"
click node_registry "https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/contracts/src/MedicineRegistry.sol"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_admin,node_batch_admin,node_participants,node_participant_list,node_org_name,node_ui_providers,node_tx,node_config,node_abi toneBlue
class node_manufacturer,node_batch_form,node_supply_page,node_supply_panel,node_trail,node_pharmacy,node_dispense toneAmber
class node_verify_page,node_verify_result toneMint
class node_registry toneRose
class node_manufacturer_actor,node_regulator_actor,node_distributor_actor,node_pharmacy_actor,node_patient_actor,node_chain_service toneIndigo
```

## Components

### Web application

- [Regulator page](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/admin/page.tsx): `frontend/app/admin/page.tsx`
- [Batch approval](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/BatchAdmin.tsx): `frontend/components/BatchAdmin.tsx`
- [Participant management](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/RegisterParticipantForm.tsx): `frontend/components/RegisterParticipantForm.tsx`
- [Participant list](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/ParticipantList.tsx): `frontend/components/ParticipantList.tsx`
- [Organization names](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/OrgName.tsx): `frontend/components/OrgName.tsx`
- [Wallet and query providers](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/providers.tsx): `frontend/app/providers.tsx`
- [Transaction submission](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/tx.ts): `frontend/lib/tx.ts`
- [Chain configuration](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/config.ts): `frontend/lib/config.ts`
- [Registry interface](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/lib/registryAbi.ts): `frontend/lib/registryAbi.ts`

### Supply operations

- [Manufacturer page](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/manufacturer/page.tsx): `frontend/app/manufacturer/page.tsx`
- [Batch registration](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/NewBatchForm.tsx): `frontend/components/NewBatchForm.tsx`
- [Supply page](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/supply/page.tsx): `frontend/app/supply/page.tsx`
- [Batch transfers](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/SupplyPanel.tsx): `frontend/components/SupplyPanel.tsx`
- [Custody trail](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/CustodyTrail.tsx): `frontend/components/CustodyTrail.tsx`
- [Pharmacy page](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/pharmacy/page.tsx): `frontend/app/pharmacy/page.tsx`
- [Record sale](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/DispenseForm.tsx): `frontend/components/DispenseForm.tsx`

### Patient verification

- [Verify page](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/app/verify/page.tsx): `frontend/app/verify/page.tsx`
- [Verification result](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/frontend/components/VerifyResult.tsx): `frontend/components/VerifyResult.tsx`

### On-chain registry

- [Medicine registry](https://github.com/raviyaa27/counterfeit-medicine-checker/blob/main/contracts/src/MedicineRegistry.sol): `contracts/src/MedicineRegistry.sol`

### Other components

- **Manufacturer**
- **NMRA regulator**
- **Distributor**
- **Pharmacy**
- **Patient**
- **Ethereum network**

## Connections

- Manufacturer → Manufacturer page: registers batch (evidence: `README.md`)
- Manufacturer page → Batch registration: registers through
- Batch registration → Medicine registry: registers batch (evidence: `README.md`)
- NMRA regulator → Regulator page: manages registry (evidence: `README.md`)
- Regulator page → Batch approval: approves or recalls
- Batch approval → Medicine registry: approves or recalls (evidence: `README.md`)
- Regulator page → Participant management: registers participants
- Participant management → Medicine registry: registers participants (evidence: `README.md`)
- Regulator page → Participant list: views participants
- Distributor → Supply page: ships batches (evidence: `README.md`)
- Supply page → Batch transfers: shows transfers
- Batch transfers → Medicine registry: transfers batches (evidence: `README.md`)
- Batch transfers → Custody trail: renders trail (evidence: `frontend/components/SupplyPanel.tsx`)
- Batch transfers → Transaction submission: submits transfer (evidence: `frontend/components/SupplyPanel.tsx`)
- Pharmacy → Pharmacy page: records sale (evidence: `README.md`)
- Pharmacy page → Record sale: marks packs sold
- Record sale → Medicine registry: records sale (evidence: `README.md`)
- Patient → Verify page: scans pack code (evidence: `README.md`)
- Verify page → Verification result: shows verdict
- Verification result → Medicine registry: reads verification (evidence: `frontend/components/VerifyResult.tsx`)
- Verification result → Custody trail: renders trail (evidence: `frontend/components/VerifyResult.tsx`)
- Custody trail → Medicine registry: reads custody history (evidence: `frontend/components/CustodyTrail.tsx`)
- Custody trail → Organization names: renders organizations (evidence: `frontend/components/CustodyTrail.tsx`)
- Verification result → Organization names: renders organization (evidence: `frontend/components/VerifyResult.tsx`)
- Batch approval → Organization names: renders organizations (evidence: `frontend/components/BatchAdmin.tsx`)
- Transaction submission → Chain configuration: uses chain settings (evidence: `frontend/lib/tx.ts`)
- Transaction submission → Registry interface: encodes calls (evidence: `frontend/lib/tx.ts`)
- Transaction submission → Medicine registry: submits transactions (evidence: `frontend/lib/tx.ts`)
- Medicine registry → Ethereum network: stores registry state (evidence: `README.md`)
- Wallet and query providers → Chain configuration: configures wallet (evidence: `frontend/app/providers.tsx`)
