# akkupy/z-vote architecture

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

- Interactive diagram: https://gitdiagram.com/akkupy/z-vote
- Repository: https://github.com/akkupy/z-vote

## Overview

Z-Vote is a Django blockchain-based voting prototype. A voter registers against an administrator-provisioned voter list, receives an OTP, obtains a secret passphrase, logs in, signs a ballot, and stores it as a vote. Every five votes are sealed into a Merkle-backed proof-of-work block. After voting closes, users can verify block integrity and view counted results. The sampled views, helper modules, URL mappings, README, and settings support this workflow; unsampled model details are represented only at their exact tree path.

Main entry points: [`poll/urls.py`](https://github.com/akkupy/z-vote/blob/main/poll/urls.py) (Web Routes), [`poll/models.py`](https://github.com/akkupy/z-vote/blob/main/poll/models.py) (Election Configuration), [`poll/views.py`](https://github.com/akkupy/z-vote/blob/main/poll/views.py) (Ballot Handler), [`poll/xtra.py`](https://github.com/akkupy/z-vote/blob/main/poll/xtra.py) (Security Helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; Identity"]
  node_django_routes["Web Routes<br/>[urls.py]"]
  node_registration["Registration Flow<br/>[views.py]"]
  node_security_helpers["Security Helpers<br/>[xtra.py]"]
  node_twilio["Twilio SMS"]
  node_api_ninja["API Ninjas"]
  node_login["Login Flow<br/>[views.py]"]
end

subgraph group_election["Election Operations"]
  node_admin_console["Admin Console<br/>[admin.py]"]
  node_election_config["Election Configuration<br/>[models.py]"]
  node_ballot_handler["Ballot Handler<br/>[views.py]"]
end

subgraph group_blockchain["Blockchain Processing"]
  node_crypto_signing["Ballot Signing<br/>[views.py]"]
  node_merkle_tree["Merkle Tree<br/>[merkleTree.py]"]
  node_block_sealer["Block Sealer<br/>[views.py]"]
end

subgraph group_integrity["Verification &amp; Results"]
  node_integrity_checker["Integrity Checker<br/>[views.py]"]
  node_results_handler["Results Handler<br/>[views.py]"]
end

subgraph group_persistence["Application Storage"]
  node_vote_store[("Vote Records<br/>[models.py]")]
  node_block_store[("Block Records<br/>[models.py]")]
  node_candidate_store[("Candidate Records<br/>[models.py]")]
  node_sqlite[("SQLite Database<br/>[settings.py]")]
end

node_voter(("Voter"))
node_administrator(("Election Admin"))

node_voter -->|"opens voting site"| node_django_routes
node_administrator -->|"configures election"| node_admin_console
node_django_routes -->|"dispatches registration"| node_registration
node_django_routes -->|"dispatches login"| node_login
node_django_routes -->|"dispatches ballot"| node_ballot_handler
node_django_routes -->|"dispatches sealing"| node_block_sealer
node_django_routes -->|"dispatches verification"| node_integrity_checker
node_django_routes -->|"dispatches results"| node_results_handler
node_registration -->|"checks voter list"| node_election_config
node_registration -->|"generates credentials"| node_security_helpers
node_security_helpers -.->|"sends OTP"| node_twilio
node_security_helpers -.->|"requests passphrase"| node_api_ninja
node_registration -->|"stores voter identity"| node_election_config
node_login -->|"authenticates voter"| node_election_config
node_admin_console -->|"writes election settings"| node_election_config
node_ballot_handler -->|"decrypts key"| node_security_helpers
node_ballot_handler -->|"signs ballot"| node_crypto_signing
node_ballot_handler -->|"stores signed vote"| node_vote_store
node_ballot_handler -->|"marks voter voted"| node_election_config
node_block_sealer -->|"reads five votes"| node_vote_store
node_block_sealer -->|"builds Merkle root"| node_merkle_tree
node_block_sealer -->|"writes mined block"| node_block_store
node_block_sealer -->|"updates chain hash"| node_election_config
node_integrity_checker -->|"reads blocks"| node_block_store
node_integrity_checker -->|"reads transactions"| node_vote_store
node_integrity_checker -->|"recomputes roots"| node_merkle_tree
node_results_handler -->|"reads votes"| node_vote_store
node_results_handler -->|"increments counts"| node_candidate_store
node_results_handler -->|"reads standings"| node_candidate_store
node_election_config -->|"persists election data"| node_sqlite
node_vote_store -->|"persists votes"| node_sqlite
node_block_store -->|"persists blocks"| node_sqlite
node_candidate_store -->|"persists candidates"| node_sqlite

click node_django_routes "https://github.com/akkupy/z-vote/blob/main/poll/urls.py"
click node_registration "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_security_helpers "https://github.com/akkupy/z-vote/blob/main/poll/xtra.py"
click node_login "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_admin_console "https://github.com/akkupy/z-vote/blob/main/poll/admin.py"
click node_election_config "https://github.com/akkupy/z-vote/blob/main/poll/models.py"
click node_ballot_handler "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_vote_store "https://github.com/akkupy/z-vote/blob/main/poll/models.py"
click node_crypto_signing "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_merkle_tree "https://github.com/akkupy/z-vote/blob/main/poll/merkleTree/merkleTree.py"
click node_block_sealer "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_block_store "https://github.com/akkupy/z-vote/blob/main/poll/models.py"
click node_integrity_checker "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_results_handler "https://github.com/akkupy/z-vote/blob/main/poll/views.py"
click node_candidate_store "https://github.com/akkupy/z-vote/blob/main/poll/models.py"
click node_sqlite "https://github.com/akkupy/z-vote/blob/main/blockchain_voting/settings.py"

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_django_routes,node_registration,node_security_helpers,node_twilio,node_api_ninja,node_login toneBlue
class node_admin_console,node_election_config,node_ballot_handler toneAmber
class node_crypto_signing,node_merkle_tree,node_block_sealer toneMint
class node_integrity_checker,node_results_handler toneRose
class node_vote_store,node_block_store,node_candidate_store,node_sqlite,node_voter,node_administrator toneIndigo
```

## Components

### Access & Identity

- [Web Routes](https://github.com/akkupy/z-vote/blob/main/poll/urls.py): `poll/urls.py`
- [Registration Flow](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`
- [Security Helpers](https://github.com/akkupy/z-vote/blob/main/poll/xtra.py): `poll/xtra.py`
- **Twilio SMS**
- **API Ninjas**
- [Login Flow](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`

### Election Operations

- [Admin Console](https://github.com/akkupy/z-vote/blob/main/poll/admin.py): `poll/admin.py`
- [Election Configuration](https://github.com/akkupy/z-vote/blob/main/poll/models.py): `poll/models.py`
- [Ballot Handler](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`

### Blockchain Processing

- [Ballot Signing](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`
- [Merkle Tree](https://github.com/akkupy/z-vote/blob/main/poll/merkleTree/merkleTree.py): `poll/merkleTree/merkleTree.py`
- [Block Sealer](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`

### Verification & Results

- [Integrity Checker](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`
- [Results Handler](https://github.com/akkupy/z-vote/blob/main/poll/views.py): `poll/views.py`

### Application Storage

- [Vote Records](https://github.com/akkupy/z-vote/blob/main/poll/models.py): `poll/models.py`
- [Block Records](https://github.com/akkupy/z-vote/blob/main/poll/models.py): `poll/models.py`
- [Candidate Records](https://github.com/akkupy/z-vote/blob/main/poll/models.py): `poll/models.py`
- [SQLite Database](https://github.com/akkupy/z-vote/blob/main/blockchain_voting/settings.py): `blockchain_voting/settings.py`

### Other components

- **Voter**
- **Election Admin**

## Connections

- Voter → Web Routes: opens voting site
- Election Admin → Admin Console: configures election
- Web Routes → Registration Flow: dispatches registration
- Web Routes → Login Flow: dispatches login
- Web Routes → Ballot Handler: dispatches ballot
- Web Routes → Block Sealer: dispatches sealing
- Web Routes → Integrity Checker: dispatches verification
- Web Routes → Results Handler: dispatches results
- Registration Flow → Election Configuration: checks voter list
- Registration Flow → Security Helpers: generates credentials
- Security Helpers → Twilio SMS: sends OTP
- Security Helpers → API Ninjas: requests passphrase
- Registration Flow → Election Configuration: stores voter identity
- Login Flow → Election Configuration: authenticates voter
- Admin Console → Election Configuration: writes election settings
- Ballot Handler → Security Helpers: decrypts key
- Ballot Handler → Ballot Signing: signs ballot
- Ballot Handler → Vote Records: stores signed vote
- Ballot Handler → Election Configuration: marks voter voted
- Block Sealer → Vote Records: reads five votes
- Block Sealer → Merkle Tree: builds Merkle root
- Block Sealer → Block Records: writes mined block
- Block Sealer → Election Configuration: updates chain hash
- Integrity Checker → Block Records: reads blocks
- Integrity Checker → Vote Records: reads transactions
- Integrity Checker → Merkle Tree: recomputes roots
- Results Handler → Vote Records: reads votes
- Results Handler → Candidate Records: increments counts
- Results Handler → Candidate Records: reads standings
- Election Configuration → SQLite Database: persists election data
- Vote Records → SQLite Database: persists votes
- Block Records → SQLite Database: persists blocks
- Candidate Records → SQLite Database: persists candidates
