# darshanathrava/secure-vote-chain architecture

> Architecture diagram of the GitHub repository darshanathrava/secure-vote-chain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/darshanathrava/secure-vote-chain
- Repository: https://github.com/darshanathrava/secure-vote-chain

## Overview

Secure Vote Chain is a voting platform whose primary workflow is voter registration with facial enrollment, face authentication, optional fingerprint verification, wallet-backed on-chain voting, and blockchain-derived results. The maintained React/TypeScript frontend talks to an Express/Mongoose API and an Ethereum-compatible contract; Python face verification and fingerprint scanning provide biometric steps. Admin pages manage election data through the API. The README identifies these capabilities, but contract source files are absent from the supplied tree; some frontend and integration links are therefore documented rather than source-verified.

Main entry points: [`server/main.js`](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/main.js) (API routing), [`src/lib/api.ts`](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/lib/api.ts) (API client), [`src/App.tsx`](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/App.tsx) (Page routing), [`server/Controller/voteController.js`](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/voteController.js) (Vote controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Voting frontend"]
  node_app["Page routing<br/>[App.tsx]"]
  node_registration["Voter registration<br/>[RegisterPage.tsx]"]
  node_authentication["Face authentication"]
  node_fingerprint_ui["Fingerprint capture<br/>[useFingerprint.ts]"]
  node_device_panel["Scanner panel"]
  node_voting_ui["Vote casting<br/>[VotePage.tsx]"]
  node_results_ui["Results view<br/>[ResultsPage.tsx]"]
  node_admin_ui["Admin console<br/>[AdminPage.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["REST API"]
  node_api_server["API routing<br/>[main.js]"]
  node_auth_controller["Identity controller<br/>[AuthController.js]"]
  node_vote_controller["Vote controller<br/>[voteController.js]"]
  node_admin_controller["Admin controller<br/>[adminController.js]"]
  node_fingerprint_controller["Fingerprint controller"]
end

subgraph group_biometrics["Biometric verification"]
  node_face_utils["Face integration<br/>[faceUtils.js]"]
  node_face_service["Face service"]
  node_fingerprint_service["Local scanner service"]
end

subgraph group_records["Election records"]
  node_user_model[("Voter records<br/>[User.js]")]
  node_candidate_model[("Candidate records<br/>[Candidate.js]")]
  node_election_model[("Election records<br/>[Election.js]")]
  node_mongo[("MongoDB")]
end

subgraph group_ledger["Blockchain voting"]
  node_contract_client["Contract client<br/>[contract.ts]"]
  node_ethereum[("Ethereum contract")]
  node_wallet["MetaMask wallet"]
end

node_voter(("Voter"))

node_voter -->|"opens"| node_app
node_app -->|"routes to"| node_registration
node_app -->|"routes to"| node_authentication
node_app -->|"routes to"| node_voting_ui
node_app -->|"routes to"| node_results_ui
node_app -->|"routes to"| node_admin_ui
node_registration -->|"submits enrollment"| node_api_client
node_authentication -->|"requests verification"| node_api_client
node_fingerprint_ui -->|"captures print"| node_fingerprint_service
node_device_panel -->|"uses hook"| node_fingerprint_ui
node_fingerprint_ui -->|"posts capture"| node_api_client
node_voting_ui -.->|"requests vote"| node_api_client
node_results_ui -.->|"requests results"| node_api_client
node_admin_ui -->|"manages records"| node_api_client
node_api_client -->|"calls REST"| node_api_server
node_api_server -->|"mounts routes"| node_auth_controller
node_api_server -->|"mounts routes"| node_vote_controller
node_api_server -->|"mounts routes"| node_admin_controller
node_api_server -->|"mounts routes"| node_fingerprint_controller
node_auth_controller -->|"reads voter"| node_user_model
node_auth_controller -->|"checks face"| node_face_utils
node_vote_controller -->|"checks voter"| node_user_model
node_vote_controller -->|"updates votes"| node_candidate_model
node_vote_controller -->|"verifies face"| node_face_utils
node_admin_controller -->|"manages voters"| node_user_model
node_admin_controller -->|"manages candidates"| node_candidate_model
node_admin_controller -->|"manages elections"| node_election_model
node_api_server -->|"loads candidates"| node_candidate_model
node_api_server -->|"loads elections"| node_election_model
node_api_server -->|"connects"| node_mongo
node_face_utils -->|"invokes Python"| node_face_service
node_fingerprint_controller -.->|"stores enrollment"| node_user_model
node_voting_ui -.->|"casts transaction"| node_contract_client
node_contract_client -.->|"requests signature"| node_wallet
node_contract_client -.->|"submits vote"| node_ethereum
node_results_ui -.->|"reads totals"| node_contract_client

click node_app "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/App.tsx"
click node_registration "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/RegisterPage.tsx"
click node_authentication "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/AuthenticatePage.tsx"
click node_fingerprint_ui "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/hooks/useFingerprint.ts"
click node_device_panel "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/components/FingerprintDevicePanel.tsx"
click node_voting_ui "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/VotePage.tsx"
click node_results_ui "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/ResultsPage.tsx"
click node_admin_ui "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/AdminPage.tsx"
click node_api_client "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/lib/api.ts"
click node_api_server "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/main.js"
click node_auth_controller "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/AuthController.js"
click node_vote_controller "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/voteController.js"
click node_admin_controller "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/adminController.js"
click node_fingerprint_controller "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/fingerprintController.js"
click node_face_utils "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/utils/faceUtils.js"
click node_face_service "https://github.com/darshanathrava/secure-vote-chain/tree/main/server/face_service"
click node_user_model "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/User.js"
click node_candidate_model "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/Candidate.js"
click node_election_model "https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/Election.js"
click node_contract_client "https://github.com/darshanathrava/secure-vote-chain/blob/main/src/lib/contract.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_registration,node_authentication,node_fingerprint_ui,node_device_panel,node_voting_ui,node_results_ui,node_admin_ui,node_api_client toneBlue
class node_api_server,node_auth_controller,node_vote_controller,node_admin_controller,node_fingerprint_controller toneAmber
class node_face_utils,node_face_service,node_fingerprint_service toneMint
class node_user_model,node_candidate_model,node_election_model,node_mongo toneRose
class node_contract_client,node_ethereum,node_wallet,node_voter toneIndigo
```

## Components

### Voting frontend

- [Page routing](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/App.tsx): `src/App.tsx`
- [Voter registration](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/RegisterPage.tsx): `src/pages/RegisterPage.tsx`
- [Face authentication](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/AuthenticatePage.tsx): `src/pages/AuthenticatePage.tsx`
- [Fingerprint capture](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/hooks/useFingerprint.ts): `src/hooks/useFingerprint.ts`
- [Scanner panel](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/components/FingerprintDevicePanel.tsx): `src/components/FingerprintDevicePanel.tsx`
- [Vote casting](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/VotePage.tsx): `src/pages/VotePage.tsx`
- [Results view](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/ResultsPage.tsx): `src/pages/ResultsPage.tsx`
- [Admin console](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/pages/AdminPage.tsx): `src/pages/AdminPage.tsx`
- [API client](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/lib/api.ts): `src/lib/api.ts`

### REST API

- [API routing](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/main.js): `server/main.js`
- [Identity controller](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/AuthController.js): `server/Controller/AuthController.js`
- [Vote controller](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/voteController.js): `server/Controller/voteController.js`
- [Admin controller](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/adminController.js): `server/Controller/adminController.js`
- [Fingerprint controller](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Controller/fingerprintController.js): `server/Controller/fingerprintController.js`

### Biometric verification

- [Face integration](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/utils/faceUtils.js): `server/utils/faceUtils.js`
- [Face service](https://github.com/darshanathrava/secure-vote-chain/tree/main/server/face_service): `server/face_service`
- **Local scanner service**

### Election records

- [Voter records](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/User.js): `server/Models/User.js`
- [Candidate records](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/Candidate.js): `server/Models/Candidate.js`
- [Election records](https://github.com/darshanathrava/secure-vote-chain/blob/main/server/Models/Election.js): `server/Models/Election.js`
- **MongoDB**

### Blockchain voting

- [Contract client](https://github.com/darshanathrava/secure-vote-chain/blob/main/src/lib/contract.ts): `src/lib/contract.ts`
- **Ethereum contract**
- **MetaMask wallet**

### Other components

- **Voter**

## Connections

- Voter → Page routing: opens (evidence: `src/App.tsx`)
- Page routing → Voter registration: routes to (evidence: `src/App.tsx`)
- Page routing → Face authentication: routes to (evidence: `src/App.tsx`)
- Page routing → Vote casting: routes to (evidence: `src/App.tsx`)
- Page routing → Results view: routes to (evidence: `src/App.tsx`)
- Page routing → Admin console: routes to (evidence: `src/App.tsx`)
- Voter registration → API client: submits enrollment (evidence: `src/pages/RegisterPage.tsx`)
- Face authentication → API client: requests verification (evidence: `src/pages/AuthenticatePage.tsx`)
- Fingerprint capture → Local scanner service: captures print (evidence: `src/hooks/useFingerprint.ts`)
- Scanner panel → Fingerprint capture: uses hook (evidence: `src/components/FingerprintDevicePanel.tsx`)
- Fingerprint capture → API client: posts capture (evidence: `src/hooks/useFingerprint.ts`)
- Vote casting → API client: requests vote
- Results view → API client: requests results
- Admin console → API client: manages records (evidence: `src/pages/AdminPage.tsx`)
- API client → API routing: calls REST
- API routing → Identity controller: mounts routes (evidence: `server/main.js`)
- API routing → Vote controller: mounts routes (evidence: `server/main.js`)
- API routing → Admin controller: mounts routes (evidence: `server/main.js`)
- API routing → Fingerprint controller: mounts routes (evidence: `server/main.js`)
- Identity controller → Voter records: reads voter (evidence: `server/Controller/AuthController.js`)
- Identity controller → Face integration: checks face (evidence: `server/Controller/AuthController.js`)
- Vote controller → Voter records: checks voter (evidence: `server/Controller/voteController.js`)
- Vote controller → Candidate records: updates votes (evidence: `server/Controller/voteController.js`)
- Vote controller → Face integration: verifies face (evidence: `server/Controller/voteController.js`)
- Admin controller → Voter records: manages voters (evidence: `server/Controller/adminController.js`)
- Admin controller → Candidate records: manages candidates (evidence: `server/Controller/adminController.js`)
- Admin controller → Election records: manages elections (evidence: `server/Controller/adminController.js`)
- API routing → Candidate records: loads candidates (evidence: `server/main.js`)
- API routing → Election records: loads elections (evidence: `server/main.js`)
- API routing → MongoDB: connects (evidence: `server/main.js`)
- Face integration → Face service: invokes Python
- Fingerprint controller → Voter records: stores enrollment (evidence: `server/Controller/fingerprintController.js`)
- Vote casting → Contract client: casts transaction
- Contract client → MetaMask wallet: requests signature
- Contract client → Ethereum contract: submits vote
- Results view → Contract client: reads totals
