# neo2701/juned architecture

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

- Interactive diagram: https://gitdiagram.com/neo2701/juned
- Repository: https://github.com/neo2701/juned

## Overview

JUNED is a Laravel/Vue e-voting application that uses browser-generated Groth16 proofs and Poseidon Merkle membership to support anonymous, eligibility-checked voting. Its main workflow is voter login, eligibility proof and encrypted ballot submission, server-side verification, then audit and public results. Admins manage elections, candidates and voters and generate the eligibility tree; audit and export are separate capabilities. The README documents browser-to-server and Node bridge behavior; sampled backend excerpts confirm verification and persistence responsibilities, while several UI and controller details were not sampled.

Main entry points: [`app/Services/VerificationService.php`](https://github.com/neo2701/juned/blob/main/app/Services/VerificationService.php) (Proof verification), [`app/Models/Suara.php`](https://github.com/neo2701/juned/blob/main/app/Models/Suara.php) (Ballot records), [`app/Models/Pemilih.php`](https://github.com/neo2701/juned/blob/main/app/Models/Pemilih.php) (Voter records), [`app/Http/Controllers/PemiluController.php`](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/PemiluController.php) (Election management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_election_admin["Election administration"]
  node_election_mgmt["Election management"]
  node_candidate_mgmt["Candidate management"]
  node_voter_registry["Voter registration"]
  node_election_store["Election records<br/>[Pemilu.php]"]
  node_voter_store["Voter records<br/>[Pemilih.php]"]
end

subgraph group_voter_flow["Voter workflow"]
  node_voter_ui["Voting booth<br/>[Dashboard.vue]"]
  node_vote_submit["Vote submission"]
  node_ballot_store["Ballot records<br/>[Suara.php]"]
end

subgraph group_crypto["Cryptographic services"]
  node_merkle_controller["Tree management API"]
  node_merkle_service["Merkle tree builder"]
  node_witness["Witness generator"]
  node_witness_calc["Witness calculator"]
  node_nullifier_service["Nullifier service"]
  node_proof_verification["Proof verification"]
  node_verify_script["Groth16 verifier<br/>[verify.js]"]
  node_merkle_script["Merkle bridge<br/>[merkle_tree.js]"]
  node_proof_store["Proof records<br/>[ZkpProof.php]"]
  node_nullifier_store["Nullifier records<br/>[Nullifier.php]"]
  node_tree_store["Merkle tree records<br/>[MerkleTree.php]"]
end

subgraph group_audit_results["Audit and results"]
  node_audit_ui["Admin audit"]
  node_public_audit["Public audit"]
  node_exports["Data exports"]
end

subgraph group_identity["Identity and access"]
  node_auth["Web authentication"]
  node_user_store["User accounts<br/>[User.php]"]
end

node_admin(("Election administrator"))
node_voter(("Voter"))
node_database[("Application database")]

node_admin -->|"manages elections"| node_election_mgmt
node_admin -->|"manages candidates"| node_candidate_mgmt
node_admin -->|"registers voters"| node_voter_registry
node_election_mgmt -->|"creates and reads"| node_election_store
node_election_mgmt -->|"counts voters"| node_voter_store
node_election_mgmt -->|"tallies votes"| node_ballot_store
node_voter_registry -.->|"registers voters"| node_voter_store
node_admin -->|"generates tree"| node_merkle_controller
node_merkle_controller -->|"builds tree"| node_merkle_service
node_merkle_service -->|"reads eligibility"| node_voter_store
node_merkle_service -->|"stores tree"| node_tree_store
node_voter -->|"signs in"| node_auth
node_voter -->|"casts ballot"| node_voter_ui
node_voter_ui -->|"fetches tree"| node_merkle_controller
node_voter_ui -.->|"generates proof"| node_witness
node_witness -.->|"computes witness"| node_witness_calc
node_voter_ui -->|"submits ballot"| node_vote_submit
node_vote_submit -->|"checks nullifier"| node_nullifier_service
node_vote_submit -->|"records ballot"| node_ballot_store
node_vote_submit -->|"records proof"| node_proof_store
node_nullifier_service -->|"checks and stores"| node_nullifier_store
node_audit_ui -->|"re-verifies votes"| node_proof_verification
node_proof_verification -->|"invokes verifier"| node_verify_script
node_proof_verification -->|"updates status"| node_ballot_store
node_proof_verification -->|"updates verification"| node_proof_store
node_proof_verification -->|"recomputes root"| node_merkle_script
node_proof_verification -->|"reads tree leaves"| node_tree_store
node_public_audit -->|"reads elections"| node_election_store
node_public_audit -->|"reads ballots"| node_ballot_store
node_public_audit -->|"reads tree"| node_tree_store
node_exports -->|"exports voters"| node_voter_store
node_exports -->|"exports results"| node_election_store
node_exports -->|"exports audit data"| node_ballot_store
node_auth -->|"authenticates account"| node_user_store
node_election_store -.->|"persists records"| node_database
node_voter_store -.->|"persists records"| node_database
node_ballot_store -.->|"persists records"| node_database
node_proof_store -.->|"persists records"| node_database
node_nullifier_store -.->|"persists records"| node_database
node_tree_store -.->|"persists records"| node_database
node_user_store -.->|"persists records"| node_database

click node_election_mgmt "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/PemiluController.php"
click node_candidate_mgmt "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/KandidatController.php"
click node_voter_registry "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/VoterRegistrationController.php"
click node_merkle_controller "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/MerkleTreeController.php"
click node_merkle_service "https://github.com/neo2701/juned/blob/main/app/Services/MerkleTreeService.php"
click node_voter_ui "https://github.com/neo2701/juned/blob/main/resources/js/Pages/Voter/Dashboard.vue"
click node_witness "https://github.com/neo2701/juned/blob/main/circuits/vote_js/generate_witness.js"
click node_witness_calc "https://github.com/neo2701/juned/blob/main/circuits/vote_js/witness_calculator.js"
click node_vote_submit "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/SuaraController.php"
click node_nullifier_service "https://github.com/neo2701/juned/blob/main/app/Services/NullifierService.php"
click node_proof_verification "https://github.com/neo2701/juned/blob/main/app/Services/VerificationService.php"
click node_verify_script "https://github.com/neo2701/juned/blob/main/scripts/verify.js"
click node_merkle_script "https://github.com/neo2701/juned/blob/main/scripts/merkle_tree.js"
click node_election_store "https://github.com/neo2701/juned/blob/main/app/Models/Pemilu.php"
click node_voter_store "https://github.com/neo2701/juned/blob/main/app/Models/Pemilih.php"
click node_ballot_store "https://github.com/neo2701/juned/blob/main/app/Models/Suara.php"
click node_proof_store "https://github.com/neo2701/juned/blob/main/app/Models/ZkpProof.php"
click node_nullifier_store "https://github.com/neo2701/juned/blob/main/app/Models/Nullifier.php"
click node_tree_store "https://github.com/neo2701/juned/blob/main/app/Models/MerkleTree.php"
click node_audit_ui "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/AuditController.php"
click node_public_audit "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/PublicAuditController.php"
click node_exports "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/ExportController.php"
click node_auth "https://github.com/neo2701/juned/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php"
click node_user_store "https://github.com/neo2701/juned/blob/main/app/Models/User.php"

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_election_mgmt,node_candidate_mgmt,node_voter_registry,node_election_store,node_voter_store toneBlue
class node_voter_ui,node_vote_submit,node_ballot_store,node_database toneAmber
class node_merkle_controller,node_merkle_service,node_witness,node_witness_calc,node_nullifier_service,node_proof_verification,node_verify_script,node_merkle_script,node_proof_store,node_nullifier_store,node_tree_store toneMint
class node_audit_ui,node_public_audit,node_exports toneRose
class node_auth,node_user_store,node_admin,node_voter toneIndigo
```

## Components

### Election administration

- [Election management](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/PemiluController.php): `app/Http/Controllers/PemiluController.php`
- [Candidate management](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/KandidatController.php): `app/Http/Controllers/KandidatController.php`
- [Voter registration](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/VoterRegistrationController.php): `app/Http/Controllers/VoterRegistrationController.php`
- [Election records](https://github.com/neo2701/juned/blob/main/app/Models/Pemilu.php): `app/Models/Pemilu.php`
- [Voter records](https://github.com/neo2701/juned/blob/main/app/Models/Pemilih.php): `app/Models/Pemilih.php`

### Voter workflow

- [Voting booth](https://github.com/neo2701/juned/blob/main/resources/js/Pages/Voter/Dashboard.vue): `resources/js/Pages/Voter/Dashboard.vue`
- [Vote submission](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/SuaraController.php): `app/Http/Controllers/SuaraController.php`
- [Ballot records](https://github.com/neo2701/juned/blob/main/app/Models/Suara.php): `app/Models/Suara.php`

### Cryptographic services

- [Tree management API](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/MerkleTreeController.php): `app/Http/Controllers/MerkleTreeController.php`
- [Merkle tree builder](https://github.com/neo2701/juned/blob/main/app/Services/MerkleTreeService.php): `app/Services/MerkleTreeService.php`
- [Witness generator](https://github.com/neo2701/juned/blob/main/circuits/vote_js/generate_witness.js): `circuits/vote_js/generate_witness.js`
- [Witness calculator](https://github.com/neo2701/juned/blob/main/circuits/vote_js/witness_calculator.js): `circuits/vote_js/witness_calculator.js`
- [Nullifier service](https://github.com/neo2701/juned/blob/main/app/Services/NullifierService.php): `app/Services/NullifierService.php`
- [Proof verification](https://github.com/neo2701/juned/blob/main/app/Services/VerificationService.php): `app/Services/VerificationService.php`
- [Groth16 verifier](https://github.com/neo2701/juned/blob/main/scripts/verify.js): `scripts/verify.js`
- [Merkle bridge](https://github.com/neo2701/juned/blob/main/scripts/merkle_tree.js): `scripts/merkle_tree.js`
- [Proof records](https://github.com/neo2701/juned/blob/main/app/Models/ZkpProof.php): `app/Models/ZkpProof.php`
- [Nullifier records](https://github.com/neo2701/juned/blob/main/app/Models/Nullifier.php): `app/Models/Nullifier.php`
- [Merkle tree records](https://github.com/neo2701/juned/blob/main/app/Models/MerkleTree.php): `app/Models/MerkleTree.php`

### Audit and results

- [Admin audit](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/AuditController.php): `app/Http/Controllers/AuditController.php`
- [Public audit](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/PublicAuditController.php): `app/Http/Controllers/PublicAuditController.php`
- [Data exports](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/ExportController.php): `app/Http/Controllers/ExportController.php`

### Identity and access

- [Web authentication](https://github.com/neo2701/juned/blob/main/app/Http/Controllers/Auth/AuthenticatedSessionController.php): `app/Http/Controllers/Auth/AuthenticatedSessionController.php`
- [User accounts](https://github.com/neo2701/juned/blob/main/app/Models/User.php): `app/Models/User.php`

### Other components

- **Election administrator**
- **Voter**
- **Application database**

## Connections

- Election administrator → Election management: manages elections
- Election administrator → Candidate management: manages candidates
- Election administrator → Voter registration: registers voters
- Election management → Election records: creates and reads (evidence: `app/Http/Controllers/PemiluController.php`)
- Election management → Voter records: counts voters (evidence: `app/Http/Controllers/PemiluController.php`)
- Election management → Ballot records: tallies votes (evidence: `app/Http/Controllers/PemiluController.php`)
- Voter registration → Voter records: registers voters
- Election administrator → Tree management API: generates tree
- Tree management API → Merkle tree builder: builds tree
- Merkle tree builder → Voter records: reads eligibility (evidence: `app/Services/MerkleTreeService.php`)
- Merkle tree builder → Merkle tree records: stores tree (evidence: `app/Services/MerkleTreeService.php`)
- Voter → Web authentication: signs in
- Voter → Voting booth: casts ballot
- Voting booth → Tree management API: fetches tree
- Voting booth → Witness generator: generates proof
- Witness generator → Witness calculator: computes witness
- Voting booth → Vote submission: submits ballot
- Vote submission → Nullifier service: checks nullifier (evidence: `app/Http/Controllers/SuaraController.php`)
- Vote submission → Ballot records: records ballot (evidence: `app/Http/Controllers/SuaraController.php`)
- Vote submission → Proof records: records proof (evidence: `app/Http/Controllers/SuaraController.php`)
- Nullifier service → Nullifier records: checks and stores (evidence: `app/Services/NullifierService.php`)
- Admin audit → Proof verification: re-verifies votes
- Proof verification → Groth16 verifier: invokes verifier (evidence: `app/Services/VerificationService.php`)
- Proof verification → Ballot records: updates status (evidence: `app/Services/VerificationService.php`)
- Proof verification → Proof records: updates verification (evidence: `app/Services/VerificationService.php`)
- Proof verification → Merkle bridge: recomputes root (evidence: `app/Services/VerificationService.php`)
- Proof verification → Merkle tree records: reads tree leaves (evidence: `app/Services/VerificationService.php`)
- Public audit → Election records: reads elections (evidence: `app/Http/Controllers/PublicAuditController.php`)
- Public audit → Ballot records: reads ballots (evidence: `app/Http/Controllers/PublicAuditController.php`)
- Public audit → Merkle tree records: reads tree (evidence: `app/Http/Controllers/PublicAuditController.php`)
- Data exports → Voter records: exports voters (evidence: `app/Http/Controllers/ExportController.php`)
- Data exports → Election records: exports results (evidence: `app/Http/Controllers/ExportController.php`)
- Data exports → Ballot records: exports audit data (evidence: `app/Http/Controllers/ExportController.php`)
- Web authentication → User accounts: authenticates account
- Election records → Application database: persists records
- Voter records → Application database: persists records
- Ballot records → Application database: persists records
- Proof records → Application database: persists records
- Nullifier records → Application database: persists records
- Merkle tree records → Application database: persists records
- User accounts → Application database: persists records
