# vinaykumarng/majorprojectmain architecture

> Architecture diagram of the GitHub repository vinaykumarng/majorprojectmain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinaykumarng/majorprojectmain
- Repository: https://github.com/vinaykumarng/majorprojectmain

## Overview

This is an agricultural supply-chain traceability dApp: participants register product batches, transfer custody through supply-chain stages, and inspect batch histories; administrators manage participants. The frontend connects wallets and presents these workflows against a Solidity contract. A MongoDB-backed API and blockchain synchronizer provide an additional indexing/query layer. The README is empty, so capabilities are inferred from the tree and sampled files; page-to-contract calls and API-client wiring are not shown and are left unasserted.

Main entry points: [`agri-supply-chain/frontend/src/App.jsx`](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/App.jsx) (Routed application), [`agri-supply-chain/frontend/src/hooks/useContract.js`](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/hooks/useContract.js) (Contract connection), [`agri-supply-chain/backend/server.js`](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/server.js) (REST query API), [`agri-supply-chain/backend/scripts/syncBlockchain.js`](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/scripts/syncBlockchain.js) (Blockchain synchronizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Routed application<br/>[App.jsx]"]
  node_wallet["Wallet session<br/>[useWallet.js]"]
  node_contract_hook["Contract connection<br/>[useContract.js]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_registration["Batch registration<br/>[RegisterBatch.jsx]"]
  node_custody["Custody transfer"]
  node_trace["Product tracing<br/>[TraceProduct.jsx]"]
  node_admin["Participant admin<br/>[AdminPanel.jsx]"]
  node_demo["Demo loader<br/>[DemoLoader.jsx]"]
  node_timeline["History timeline<br/>[Timeline.jsx]"]
  node_tx_status["Transaction status<br/>[TxStatus.jsx]"]
  node_formatters["Roles and formatting<br/>[formatters.js]"]
  node_role_defs["Role definitions<br/>[roles.js]"]
end

subgraph group_chain["Blockchain ledger"]
  node_ledger["Supply-chain contract"]
end

subgraph group_backend["Query and indexing"]
  node_api["REST query API<br/>[server.js]"]
  node_sync["Blockchain synchronizer<br/>[syncBlockchain.js]"]
  node_mongo[("MongoDB<br/>[connection.js]")]
  node_batches[("Batch records<br/>[Batch.js]")]
  node_transfers[("Transfer records<br/>[Transfer.js]")]
  node_participants_db[("Participant records<br/>[Participant.js]")]
  node_events[("Event records<br/>[Event.js]")]
end

subgraph group_types["Contract bindings"]
  node_typed_contract["Typed contract interface"]
  node_factory["Contract factory"]
  node_common_types["Ethers shared types<br/>[common.ts]"]
end

node_participants(("Supply-chain participants"))

node_participants -->|"use workflows"| node_app
node_app -->|"creates session"| node_wallet
node_app -->|"creates connection"| node_contract_hook
node_wallet -->|"provides signer"| node_contract_hook
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_registration
node_app -->|"routes to"| node_custody
node_app -->|"routes to"| node_trace
node_app -->|"routes to"| node_admin
node_app -->|"routes to"| node_demo
node_registration -->|"renders"| node_tx_status
node_custody -->|"renders"| node_tx_status
node_admin -->|"renders"| node_tx_status
node_trace -->|"renders"| node_timeline
node_dashboard -->|"uses"| node_formatters
node_trace -->|"uses"| node_formatters
node_formatters -->|"uses"| node_role_defs
node_contract_hook -.->|"connects to"| node_ledger
node_registration -.->|"submits batch"| node_contract_hook
node_custody -.->|"transfers custody"| node_contract_hook
node_trace -.->|"reads history"| node_contract_hook
node_admin -.->|"manages access"| node_contract_hook
node_demo -.->|"loads demo data"| node_contract_hook
node_api -->|"connects"| node_mongo
node_api -->|"queries"| node_batches
node_api -->|"queries"| node_transfers
node_api -->|"queries"| node_participants_db
node_api -->|"queries"| node_events
node_sync -->|"updates"| node_batches
node_sync -->|"updates"| node_transfers
node_sync -->|"updates"| node_participants_db
node_sync -->|"updates"| node_events
node_sync -.->|"reads events"| node_ledger
node_factory -->|"types"| node_typed_contract
node_typed_contract -->|"uses types"| node_common_types
node_factory -->|"uses types"| node_common_types

click node_app "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/App.jsx"
click node_wallet "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/hooks/useWallet.js"
click node_contract_hook "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/hooks/useContract.js"
click node_dashboard "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/Dashboard.jsx"
click node_registration "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/RegisterBatch.jsx"
click node_custody "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/TransferCustody.jsx"
click node_trace "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/TraceProduct.jsx"
click node_admin "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/AdminPanel.jsx"
click node_demo "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/DemoLoader.jsx"
click node_timeline "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/components/Timeline.jsx"
click node_tx_status "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/components/TxStatus.jsx"
click node_formatters "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/utils/formatters.js"
click node_role_defs "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/utils/roles.js"
click node_ledger "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/contracts/AgriculturalSupplyChain.sol"
click node_api "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/server.js"
click node_sync "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/scripts/syncBlockchain.js"
click node_mongo "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/db/connection.js"
click node_batches "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Batch.js"
click node_transfers "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Transfer.js"
click node_participants_db "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Participant.js"
click node_events "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Event.js"
click node_typed_contract "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/AgriculturalSupplyChain.ts"
click node_factory "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/factories/AgriculturalSupplyChain__factory.ts"
click node_common_types "https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/common.ts"

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_app,node_wallet,node_contract_hook,node_dashboard,node_registration,node_custody,node_trace,node_admin,node_demo,node_timeline,node_tx_status,node_formatters,node_role_defs toneBlue
class node_ledger toneAmber
class node_api,node_sync,node_mongo,node_batches,node_transfers,node_participants_db,node_events toneMint
class node_typed_contract,node_factory,node_common_types toneRose
class node_participants toneIndigo
```

## Components

### Web application

- [Routed application](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/App.jsx): `agri-supply-chain/frontend/src/App.jsx`
- [Wallet session](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/hooks/useWallet.js): `agri-supply-chain/frontend/src/hooks/useWallet.js`
- [Contract connection](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/hooks/useContract.js): `agri-supply-chain/frontend/src/hooks/useContract.js`
- [Dashboard](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/Dashboard.jsx): `agri-supply-chain/frontend/src/pages/Dashboard.jsx`
- [Batch registration](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/RegisterBatch.jsx): `agri-supply-chain/frontend/src/pages/RegisterBatch.jsx`
- [Custody transfer](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/TransferCustody.jsx): `agri-supply-chain/frontend/src/pages/TransferCustody.jsx`
- [Product tracing](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/TraceProduct.jsx): `agri-supply-chain/frontend/src/pages/TraceProduct.jsx`
- [Participant admin](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/AdminPanel.jsx): `agri-supply-chain/frontend/src/pages/AdminPanel.jsx`
- [Demo loader](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/pages/DemoLoader.jsx): `agri-supply-chain/frontend/src/pages/DemoLoader.jsx`
- [History timeline](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/components/Timeline.jsx): `agri-supply-chain/frontend/src/components/Timeline.jsx`
- [Transaction status](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/components/TxStatus.jsx): `agri-supply-chain/frontend/src/components/TxStatus.jsx`
- [Roles and formatting](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/utils/formatters.js): `agri-supply-chain/frontend/src/utils/formatters.js`
- [Role definitions](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/frontend/src/utils/roles.js): `agri-supply-chain/frontend/src/utils/roles.js`

### Blockchain ledger

- [Supply-chain contract](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/contracts/AgriculturalSupplyChain.sol): `agri-supply-chain/contracts/AgriculturalSupplyChain.sol`

### Query and indexing

- [REST query API](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/server.js): `agri-supply-chain/backend/server.js`
- [Blockchain synchronizer](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/scripts/syncBlockchain.js): `agri-supply-chain/backend/scripts/syncBlockchain.js`
- [MongoDB](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/db/connection.js): `agri-supply-chain/backend/db/connection.js`
- [Batch records](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Batch.js): `agri-supply-chain/backend/models/Batch.js`
- [Transfer records](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Transfer.js): `agri-supply-chain/backend/models/Transfer.js`
- [Participant records](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Participant.js): `agri-supply-chain/backend/models/Participant.js`
- [Event records](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/backend/models/Event.js): `agri-supply-chain/backend/models/Event.js`

### Contract bindings

- [Typed contract interface](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/AgriculturalSupplyChain.ts): `agri-supply-chain/types/ethers-contracts/AgriculturalSupplyChain.ts`
- [Contract factory](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/factories/AgriculturalSupplyChain__factory.ts): `agri-supply-chain/types/ethers-contracts/factories/AgriculturalSupplyChain__factory.ts`
- [Ethers shared types](https://github.com/vinaykumarng/majorprojectmain/blob/main/agri-supply-chain/types/ethers-contracts/common.ts): `agri-supply-chain/types/ethers-contracts/common.ts`

### Other components

- **Supply-chain participants**

## Connections

- Supply-chain participants → Routed application: use workflows (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Wallet session: creates session (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Contract connection: creates connection (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Wallet session → Contract connection: provides signer (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Dashboard: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Batch registration: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Custody transfer: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Product tracing: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Participant admin: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Routed application → Demo loader: routes to (evidence: `agri-supply-chain/frontend/src/App.jsx`)
- Batch registration → Transaction status: renders (evidence: `agri-supply-chain/frontend/src/pages/RegisterBatch.jsx`)
- Custody transfer → Transaction status: renders (evidence: `agri-supply-chain/frontend/src/pages/TransferCustody.jsx`)
- Participant admin → Transaction status: renders (evidence: `agri-supply-chain/frontend/src/pages/AdminPanel.jsx`)
- Product tracing → History timeline: renders (evidence: `agri-supply-chain/frontend/src/pages/TraceProduct.jsx`)
- Dashboard → Roles and formatting: uses (evidence: `agri-supply-chain/frontend/src/pages/Dashboard.jsx`)
- Product tracing → Roles and formatting: uses (evidence: `agri-supply-chain/frontend/src/pages/TraceProduct.jsx`)
- Roles and formatting → Role definitions: uses (evidence: `agri-supply-chain/frontend/src/utils/formatters.js`)
- Contract connection → Supply-chain contract: connects to
- Batch registration → Contract connection: submits batch
- Custody transfer → Contract connection: transfers custody
- Product tracing → Contract connection: reads history
- Participant admin → Contract connection: manages access
- Demo loader → Contract connection: loads demo data
- REST query API → MongoDB: connects (evidence: `agri-supply-chain/backend/server.js`)
- REST query API → Batch records: queries (evidence: `agri-supply-chain/backend/server.js`)
- REST query API → Transfer records: queries (evidence: `agri-supply-chain/backend/server.js`)
- REST query API → Participant records: queries (evidence: `agri-supply-chain/backend/server.js`)
- REST query API → Event records: queries (evidence: `agri-supply-chain/backend/server.js`)
- Blockchain synchronizer → Batch records: updates (evidence: `agri-supply-chain/backend/scripts/syncBlockchain.js`)
- Blockchain synchronizer → Transfer records: updates (evidence: `agri-supply-chain/backend/scripts/syncBlockchain.js`)
- Blockchain synchronizer → Participant records: updates (evidence: `agri-supply-chain/backend/scripts/syncBlockchain.js`)
- Blockchain synchronizer → Event records: updates (evidence: `agri-supply-chain/backend/scripts/syncBlockchain.js`)
- Blockchain synchronizer → Supply-chain contract: reads events
- Contract factory → Typed contract interface: types (evidence: `agri-supply-chain/types/ethers-contracts/factories/AgriculturalSupplyChain__factory.ts`)
- Typed contract interface → Ethers shared types: uses types (evidence: `agri-supply-chain/types/ethers-contracts/AgriculturalSupplyChain.ts`)
- Contract factory → Ethers shared types: uses types (evidence: `agri-supply-chain/types/ethers-contracts/factories/AgriculturalSupplyChain__factory.ts`)
