# hashmith017/securevote architecture

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

- Interactive diagram: https://gitdiagram.com/hashmith017/securevote
- Repository: https://github.com/hashmith017/securevote

## Overview

SECUREVote is a web voting application whose main flow is password login, OTP verification, role-based access, and— for voters—casting one time-window-restricted vote. Administrators configure elections and candidates, monitor turnout and results, export CSV, reset election state, and inspect the hash-linked audit ledger. The backend keeps election and user data in memory; the blockchain module provides vote-block hashing and chain validation. Edges reflect calls shown in excerpts or capabilities explicitly documented in the README. Registration is shown calling an API endpoint, but the sampled backend excerpt does not establish that endpoint’s implementation.

Main entry points: [`backend/server.js`](https://github.com/hashmith017/securevote/blob/main/backend/server.js) (Auth API), [`frontend/client.js`](https://github.com/hashmith017/securevote/blob/main/frontend/client.js) (Voting Interface), [`frontend/admin.js`](https://github.com/hashmith017/securevote/blob/main/frontend/admin.js) (Admin Panel), [`frontend/login.js`](https://github.com/hashmith017/securevote/blob/main/frontend/login.js) (Login Form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authentication"]
  node_login["Login Form<br/>[login.js]"]
  node_registration["Registration Form<br/>[register.js]"]
  node_otp["OTP Verification<br/>[otp.js]"]
  node_auth_api["Auth API<br/>[server.js]"]
end

subgraph group_voting["Voting"]
  node_voting_ui["Voting Interface<br/>[client.js]"]
  node_election_api["Election API<br/>[server.js]"]
  node_election_state[("Election State<br/>[server.js]")]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin Panel<br/>[admin.js]"]
  node_admin_api["Admin Operations<br/>[server.js]"]
  node_user_directory[("User Directory<br/>[server.js]")]
  node_results_export["Results Export<br/>[server.js]"]
end

subgraph group_audit["Audit Ledger"]
  node_vote_ledger[("Vote Ledger<br/>[blockchain.js]")]
end

node_voter(("Voter"))
node_administrator(("Administrator"))

node_voter -->|"starts login"| node_login
node_administrator -->|"starts login"| node_login
node_login -->|"submits credentials"| node_auth_api
node_auth_api -->|"requests verification"| node_otp
node_otp -->|"submits OTP"| node_auth_api
node_auth_api -->|"checks credentials"| node_user_directory
node_registration -->|"requests registration"| node_auth_api
node_voter -->|"casts ballot"| node_voting_ui
node_voting_ui -->|"fetches election"| node_election_api
node_voting_ui -->|"submits vote"| node_election_api
node_election_api -->|"reads and updates"| node_election_state
node_election_api -->|"appends vote block"| node_vote_ledger
node_administrator -->|"manages election"| node_admin_ui
node_admin_ui -->|"requests management"| node_admin_api
node_admin_api -->|"configures and reports"| node_election_state
node_admin_api -->|"searches users"| node_user_directory
node_admin_ui -->|"downloads CSV"| node_results_export
node_admin_api -->|"reads and validates chain"| node_vote_ledger

click node_login "https://github.com/hashmith017/securevote/blob/main/frontend/login.js"
click node_registration "https://github.com/hashmith017/securevote/blob/main/frontend/register.js"
click node_otp "https://github.com/hashmith017/securevote/blob/main/frontend/otp.js"
click node_auth_api "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_voting_ui "https://github.com/hashmith017/securevote/blob/main/frontend/client.js"
click node_election_api "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_election_state "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_admin_ui "https://github.com/hashmith017/securevote/blob/main/frontend/admin.js"
click node_admin_api "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_user_directory "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_results_export "https://github.com/hashmith017/securevote/blob/main/backend/server.js"
click node_vote_ledger "https://github.com/hashmith017/securevote/blob/main/backend/blockchain.js"

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_login,node_registration,node_otp,node_auth_api toneBlue
class node_voting_ui,node_election_api,node_election_state toneAmber
class node_admin_ui,node_admin_api,node_user_directory,node_results_export toneMint
class node_vote_ledger toneRose
class node_voter,node_administrator toneIndigo
```

## Components

### Authentication

- [Login Form](https://github.com/hashmith017/securevote/blob/main/frontend/login.js): `frontend/login.js`
- [Registration Form](https://github.com/hashmith017/securevote/blob/main/frontend/register.js): `frontend/register.js`
- [OTP Verification](https://github.com/hashmith017/securevote/blob/main/frontend/otp.js): `frontend/otp.js`
- [Auth API](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`

### Voting

- [Voting Interface](https://github.com/hashmith017/securevote/blob/main/frontend/client.js): `frontend/client.js`
- [Election API](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`
- [Election State](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`

### Administration

- [Admin Panel](https://github.com/hashmith017/securevote/blob/main/frontend/admin.js): `frontend/admin.js`
- [Admin Operations](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`
- [User Directory](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`
- [Results Export](https://github.com/hashmith017/securevote/blob/main/backend/server.js): `backend/server.js`

### Audit Ledger

- [Vote Ledger](https://github.com/hashmith017/securevote/blob/main/backend/blockchain.js): `backend/blockchain.js`

### Other components

- **Voter**
- **Administrator**

## Connections

- Voter → Login Form: starts login (evidence: `README.md`)
- Administrator → Login Form: starts login (evidence: `README.md`)
- Login Form → Auth API: submits credentials (evidence: `frontend/login.js`)
- Auth API → OTP Verification: requests verification (evidence: `README.md`)
- OTP Verification → Auth API: submits OTP (evidence: `frontend/otp.js`)
- Auth API → User Directory: checks credentials (evidence: `backend/server.js`)
- Registration Form → Auth API: requests registration (evidence: `frontend/register.js`)
- Voter → Voting Interface: casts ballot (evidence: `README.md`)
- Voting Interface → Election API: fetches election (evidence: `frontend/client.js`)
- Voting Interface → Election API: submits vote (evidence: `frontend/client.js`)
- Election API → Election State: reads and updates (evidence: `backend/server.js`)
- Election API → Vote Ledger: appends vote block (evidence: `backend/server.js`)
- Administrator → Admin Panel: manages election (evidence: `README.md`)
- Admin Panel → Admin Operations: requests management (evidence: `frontend/admin.js`)
- Admin Operations → Election State: configures and reports (evidence: `backend/server.js`)
- Admin Operations → User Directory: searches users (evidence: `backend/server.js`)
- Admin Panel → Results Export: downloads CSV (evidence: `frontend/admin.js`)
- Admin Operations → Vote Ledger: reads and validates chain (evidence: `backend/server.js`)
