# krazzyjoshh/anhsvotingsystem architecture

> Architecture diagram of the GitHub repository krazzyjoshh/anhsvotingsystem, 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/krazzyjoshh/anhsvotingsystem
- Repository: https://github.com/krazzyjoshh/anhsvotingsystem

## Overview

ANHS Vote is a school-election system combining an admin portal, student and candidate management, token or verified-email voter access, ballot submission, receipts, public results, and Solana Devnet integration. The workflow runs from election setup and voter preparation through publication, voting, and result review. The graph separates the active web client, API workflows, shared server state, and chain integration. Source excerpts show key route and storage relationships; unsampled capabilities are included where documented, but their internal calls are not inferred.

Main entry points: [`server/src/index.js`](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/index.js) (HTTP API server), [`server/src/database.js`](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/database.js) (SQLite database), [`server/src/routes/voter.js`](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/voter.js) (Voter access and ballots), [`server/src/chain.js`](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/chain.js) (Solana client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Active web client"]
  node_admin["Admin portal<br/>[App.jsx]"]
  node_admin_ui["Admin UI utilities<br/>[admin.jsx]"]
  node_web_api["Web API client<br/>[api.js]"]
  node_voter_ui["Voter ballot flow<br/>[Vote.jsx]"]
end

subgraph group_api["Election API"]
  node_admin_routes["Admin operations<br/>[admin.js]"]
  node_voter_routes["Voter access and ballots<br/>[voter.js]"]
  node_chain_routes["Election publishing<br/>[blockchain.js]"]
  node_public_routes["Public election views<br/>[public.js]"]
  node_ledger_routes["Election ledger<br/>[ledger.js]"]
  node_api_server["HTTP API server<br/>[index.js]"]
end

subgraph group_state["Server state"]
  node_auth["Admin authentication<br/>[auth.js]"]
  node_sessions["Voter sessions<br/>[voter-sessions.js]"]
  node_election["Election state logic<br/>[election.js]"]
  node_models["Election data models<br/>[models.js]"]
  node_settings["Election settings<br/>[settings.js]"]
  node_database[("SQLite database<br/>[database.js]")]
end

subgraph group_chain["Blockchain"]
  node_chain_client["Solana client<br/>[chain.js]"]
  node_program["Voting program<br/>[lib.rs]"]
end

node_voter(("Student voter"))
node_administrator(("Election administrator"))
node_solana[("Solana Devnet")]

node_administrator -->|"uses portal"| node_admin
node_voter -->|"casts ballot"| node_voter_ui
node_admin -->|"requests data"| node_web_api
node_voter_ui -->|"submits votes"| node_web_api
node_admin -->|"uses utilities"| node_admin_ui
node_web_api -.->|"calls HTTP API"| node_api_server
node_api_server -->|"mounts routes"| node_admin_routes
node_api_server -->|"mounts routes"| node_chain_routes
node_api_server -->|"mounts routes"| node_ledger_routes
node_api_server -->|"mounts routes"| node_voter_routes
node_api_server -->|"mounts routes"| node_public_routes
node_api_server -->|"checks admins"| node_auth
node_admin_routes -->|"uses models"| node_models
node_admin_routes -->|"checks election state"| node_settings
node_admin_routes -->|"reads and writes"| node_database
node_voter_routes -->|"manages sessions"| node_sessions
node_voter_routes -->|"checks election"| node_election
node_voter_routes -->|"submits vote"| node_chain_client
node_voter_routes -->|"reads and writes"| node_database
node_chain_routes -->|"gets snapshot"| node_election
node_chain_routes -->|"publishes election"| node_chain_client
node_chain_routes -->|"stores election state"| node_database
node_election -->|"reads settings"| node_settings
node_election -->|"reads chain"| node_chain_client
node_models -->|"uses database"| node_database
node_settings -->|"reads and writes"| node_database
node_sessions -->|"stores sessions"| node_database
node_chain_client -->|"uses Devnet"| node_solana
node_chain_client -.->|"calls program"| node_program

click node_admin "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/App.jsx"
click node_admin_ui "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/admin.jsx"
click node_web_api "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/api.js"
click node_voter_ui "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/pages/Vote.jsx"
click node_admin_routes "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/admin.js"
click node_voter_routes "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/voter.js"
click node_chain_routes "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/blockchain.js"
click node_public_routes "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/public.js"
click node_ledger_routes "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/ledger.js"
click node_api_server "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/index.js"
click node_auth "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/auth.js"
click node_sessions "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/voter-sessions.js"
click node_election "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/election.js"
click node_models "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/models.js"
click node_settings "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/settings.js"
click node_database "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/database.js"
click node_chain_client "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/chain.js"
click node_program "https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/chain/programs/voting-system/src/lib.rs"

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_admin_ui,node_web_api,node_voter_ui toneBlue
class node_admin_routes,node_voter_routes,node_chain_routes,node_public_routes,node_ledger_routes,node_api_server,node_solana toneAmber
class node_auth,node_sessions,node_election,node_models,node_settings,node_database toneMint
class node_chain_client,node_program toneRose
class node_voter,node_administrator toneIndigo
```

## Components

### Active web client

- [Admin portal](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/App.jsx): `web/src/App.jsx`
- [Admin UI utilities](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/admin.jsx): `web/src/admin.jsx`
- [Web API client](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/api.js): `web/src/api.js`
- [Voter ballot flow](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/web/src/pages/Vote.jsx): `web/src/pages/Vote.jsx`

### Election API

- [Admin operations](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/admin.js): `server/src/routes/admin.js`
- [Voter access and ballots](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/voter.js): `server/src/routes/voter.js`
- [Election publishing](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/blockchain.js): `server/src/routes/blockchain.js`
- [Public election views](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/public.js): `server/src/routes/public.js`
- [Election ledger](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/routes/ledger.js): `server/src/routes/ledger.js`
- [HTTP API server](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/index.js): `server/src/index.js`

### Server state

- [Admin authentication](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/auth.js): `server/src/auth.js`
- [Voter sessions](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/voter-sessions.js): `server/src/voter-sessions.js`
- [Election state logic](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/election.js): `server/src/election.js`
- [Election data models](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/models.js): `server/src/models.js`
- [Election settings](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/settings.js): `server/src/settings.js`
- [SQLite database](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/database.js): `server/src/database.js`

### Blockchain

- [Solana client](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/server/src/chain.js): `server/src/chain.js`
- [Voting program](https://github.com/krazzyjoshh/anhsvotingsystem/blob/main/chain/programs/voting-system/src/lib.rs): `chain/programs/voting-system/src/lib.rs`

### Other components

- **Student voter**
- **Election administrator**
- **Solana Devnet**

## Connections

- Election administrator → Admin portal: uses portal (evidence: `README.md`)
- Student voter → Voter ballot flow: casts ballot (evidence: `README.md`)
- Admin portal → Web API client: requests data (evidence: `web/src/api.js`)
- Voter ballot flow → Web API client: submits votes (evidence: `web/src/pages/Vote.jsx`)
- Admin portal → Admin UI utilities: uses utilities (evidence: `web/src/App.jsx`)
- Web API client → HTTP API server: calls HTTP API
- HTTP API server → Admin operations: mounts routes (evidence: `server/src/index.js`)
- HTTP API server → Election publishing: mounts routes (evidence: `server/src/index.js`)
- HTTP API server → Election ledger: mounts routes (evidence: `server/src/index.js`)
- HTTP API server → Voter access and ballots: mounts routes (evidence: `server/src/index.js`)
- HTTP API server → Public election views: mounts routes (evidence: `server/src/index.js`)
- HTTP API server → Admin authentication: checks admins (evidence: `server/src/index.js`)
- Admin operations → Election data models: uses models (evidence: `server/src/routes/admin.js`)
- Admin operations → Election settings: checks election state (evidence: `server/src/routes/admin.js`)
- Admin operations → SQLite database: reads and writes (evidence: `server/src/routes/admin.js`)
- Voter access and ballots → Voter sessions: manages sessions (evidence: `server/src/routes/voter.js`)
- Voter access and ballots → Election state logic: checks election (evidence: `server/src/routes/voter.js`)
- Voter access and ballots → Solana client: submits vote (evidence: `server/src/routes/voter.js`)
- Voter access and ballots → SQLite database: reads and writes (evidence: `server/src/routes/voter.js`)
- Election publishing → Election state logic: gets snapshot (evidence: `server/src/routes/blockchain.js`)
- Election publishing → Solana client: publishes election (evidence: `server/src/routes/blockchain.js`)
- Election publishing → SQLite database: stores election state (evidence: `server/src/routes/blockchain.js`)
- Election state logic → Election settings: reads settings (evidence: `server/src/election.js`)
- Election state logic → Solana client: reads chain (evidence: `server/src/election.js`)
- Election data models → SQLite database: uses database (evidence: `server/src/models.js`)
- Election settings → SQLite database: reads and writes (evidence: `server/src/settings.js`)
- Voter sessions → SQLite database: stores sessions (evidence: `server/src/voter-sessions.js`)
- Solana client → Solana Devnet: uses Devnet (evidence: `README.md`)
- Solana client → Voting program: calls program
