# lucianolupo/zk-voting-semaphore-001 architecture

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

- Interactive diagram: https://gitdiagram.com/lucianolupo/zk-voting-semaphore-001
- Repository: https://github.com/lucianolupo/zk-voting-semaphore-001

## Overview

This is a Semaphore-based anonymous voting dApp. Poll creators configure polls; voters create or import a local identity, register during the registration phase, generate a membership proof to vote, and view public results. The frontend reads and writes poll state through Wagmi to the voting contract, which manages poll phases, Semaphore groups, proof verification, and nullifiers. The sampled sources show the frontend call paths; contract internals are represented from the README because Solidity excerpts were not provided.

Main entry points: [`app/app/poll/[id]/page.tsx`](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/poll/%5Bid%5D/page.tsx) (Poll participation), [`app/hooks/useVoting.ts`](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useVoting.ts) (Poll queries and actions), [`app/app/create/page.tsx`](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/create/page.tsx) (Poll creation), [`app/hooks/useIdentity.ts`](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useIdentity.ts) (Identity management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Voting frontend"]
  node_poll_listing["Poll listing<br/>[page.tsx]"]
  node_poll_creation["Poll creation<br/>[page.tsx]"]
  node_poll_detail["Poll participation<br/>[page.tsx]"]
  node_app_providers["Wallet providers<br/>[providers.tsx]"]
  node_voting_hooks["Poll queries and actions<br/>[useVoting.ts]"]
end

subgraph group_identity["Identity and proofs"]
  node_identity_hook["Identity management<br/>[useIdentity.ts]"]
  node_identity_storage[("Local identity storage<br/>[storage.ts]")]
  node_proof_generation["Proof generation<br/>[useSemaphore.ts]"]
end

subgraph group_chain["On-chain voting"]
  node_contract_binding["Contract binding<br/>[contracts.ts]"]
  node_voting_contract["Poll lifecycle and voting"]
  node_voting_abi["Voting ABI<br/>[abi.json]"]
end

node_creator(("Poll creator"))
node_voter(("Voter"))
node_semaphore["Semaphore protocol"]

node_creator -->|"creates poll"| node_poll_creation
node_poll_creation -->|"calls createPoll"| node_voting_hooks
node_poll_listing -->|"queries poll data"| node_voting_hooks
node_voter -->|"registers and votes"| node_poll_detail
node_poll_detail -->|"queries and submits"| node_voting_hooks
node_poll_detail -->|"uses identity"| node_identity_hook
node_poll_detail -->|"requests vote proof"| node_proof_generation
node_identity_hook -->|"loads and saves"| node_identity_storage
node_proof_generation -->|"generates proof"| node_semaphore
node_voting_hooks -->|"uses address and ABI"| node_contract_binding
node_contract_binding -->|"imports ABI"| node_voting_abi
node_voting_contract -->|"verifies proofs"| node_semaphore

click node_poll_listing "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/page.tsx"
click node_poll_creation "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/create/page.tsx"
click node_poll_detail "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/poll/%5Bid%5D/page.tsx"
click node_app_providers "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/providers.tsx"
click node_voting_hooks "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useVoting.ts"
click node_identity_hook "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useIdentity.ts"
click node_identity_storage "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/storage.ts"
click node_proof_generation "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useSemaphore.ts"
click node_contract_binding "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/contracts.ts"
click node_voting_contract "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/contracts/SemaphoreVoting.sol"
click node_voting_abi "https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/abi.json"

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_poll_listing,node_poll_creation,node_poll_detail,node_app_providers,node_voting_hooks toneBlue
class node_identity_hook,node_identity_storage,node_proof_generation toneAmber
class node_contract_binding,node_voting_contract,node_voting_abi toneMint
class node_creator,node_voter,node_semaphore toneIndigo
```

## Components

### Voting frontend

- [Poll listing](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/page.tsx): `app/app/page.tsx`
- [Poll creation](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/create/page.tsx): `app/app/create/page.tsx`
- [Poll participation](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/poll/%5Bid%5D/page.tsx): `app/app/poll/[id]/page.tsx`
- [Wallet providers](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/app/providers.tsx): `app/app/providers.tsx`
- [Poll queries and actions](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useVoting.ts): `app/hooks/useVoting.ts`

### Identity and proofs

- [Identity management](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useIdentity.ts): `app/hooks/useIdentity.ts`
- [Local identity storage](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/storage.ts): `app/lib/storage.ts`
- [Proof generation](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/hooks/useSemaphore.ts): `app/hooks/useSemaphore.ts`

### On-chain voting

- [Contract binding](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/contracts.ts): `app/lib/contracts.ts`
- [Poll lifecycle and voting](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/contracts/SemaphoreVoting.sol): `contracts/SemaphoreVoting.sol`
- [Voting ABI](https://github.com/lucianolupo/zk-voting-semaphore-001/blob/main/app/lib/abi.json): `app/lib/abi.json`

### Other components

- **Poll creator**
- **Voter**
- **Semaphore protocol**

## Connections

- Poll creator → Poll creation: creates poll (evidence: `app/app/create/page.tsx`)
- Poll creation → Poll queries and actions: calls createPoll (evidence: `app/app/create/page.tsx`)
- Poll listing → Poll queries and actions: queries poll data (evidence: `app/app/page.tsx`)
- Voter → Poll participation: registers and votes (evidence: `README.md`)
- Poll participation → Poll queries and actions: queries and submits (evidence: `app/app/poll/[id]/page.tsx`)
- Poll participation → Identity management: uses identity (evidence: `app/app/poll/[id]/page.tsx`)
- Poll participation → Proof generation: requests vote proof (evidence: `app/app/poll/[id]/page.tsx`)
- Identity management → Local identity storage: loads and saves (evidence: `app/hooks/useIdentity.ts`)
- Proof generation → Semaphore protocol: generates proof (evidence: `README.md`)
- Poll queries and actions → Contract binding: uses address and ABI (evidence: `app/hooks/useVoting.ts`)
- Contract binding → Voting ABI: imports ABI (evidence: `app/lib/contracts.ts`)
- Poll lifecycle and voting → Semaphore protocol: verifies proofs (evidence: `README.md`)
