SecureVote is an enterprise-grade full-stack Java web application designed for secure, transparent, and tamper-proof electronic elections. The system utilizes an anonymous SHA-256 vote chain ledger (blockchain-inspired) to guarantee absolute vote secrecy, single-ballot enforcement per voter, verifiable digital receipts, real-time result analytics, and automated cryptographic audit verification.
- Immutable Block Sequence: Each cast vote is cryptographically linked to the previous vote block hash (
previousHash->voteHash), forming a tamper-proof chain. - Salted Voter Anonymization: Voters produce a salted hash
sha256(voterId + electionId + positionId + salt)to prevent double voting while ensuring candidate choices remain completely unlinked from voter identities. - Verifiable Digital Receipts: Voters receive a unique receipt code (e.g.,
VOTE-REC-D46D519D-9389) to publicly verify that their vote block exists in the ledger without exposing their ballot choices.
- Block-by-Block Audit Engine: Scans every ledger block to verify cryptographic parent links and payload hashes.
- Tamper Detection: If database records are illegally altered, the Auditor Portal immediately flags the broken block index and alerts security personnel.
- System Activity Logs: Logs system-wide actions with timestamps, actor IDs, actions, and IP addresses.
- 4-Step Guided Voting:
- Voter Verification: Authorization & constituency check.
- Ballot Selection: Interactive candidate cards with party manifestos and photos.
- Review & Cryptographic Sign: Final selection review before ledger signing.
- Cryptographic Receipt Ticket: Printable digital receipt with block hash details.
- Dynamic Chart.js Integration: Live visual bar charts showing vote shares per candidate.
- Metrics Panel: Instant updates for total votes cast, turnout percentage, and leading candidate indicators.
- Candidate Tally Table: Detailed percentage breakdown per office.
- Voter: View elections, cast ballots in active elections, verify receipt codes.
- Administrator: Create elections, add positions/candidates, toggle election states (
UPCOMING,ACTIVE,PAUSED,CLOSED). - Auditor: Execute SHA-256 cryptographic chain audits and review security logs.
ββββββββββββββββββββββββββββββββββββββββ
β SecureVote Web Portal (Frontend) β
β HTML5 / Glassmorphism CSS / App.js β
ββββββββββββββββββββ¬ββββββββββββββββββββ
β REST API (JSON)
ββββββββββββββββββββΌββββββββββββββββββββ
β Spring Boot 3 Web Application β
β ββββββββββββββββββββββββββββββββββββ β
β β Controllers (Auth, Election, Vote)β β
β ββββββββββββββββββββββββββββββββββββ€ β
β β Services (Crypto, Ledger, Audit) β β
β ββββββββββββββββββββββββββββββββββββ€ β
β β Repositories (Spring Data JPA) β β
β ββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββ¬ββββββββββββββββββββ
β H2 Persistence
ββββββββββββββββββββΌββββββββββββββββββββ
β H2 Embedded Database / Ledger DB β
ββββββββββββββββββββββββββββββββββββββββ
- Backend: Java 21, Spring Boot 3.3.4, Spring Web, Spring Data JPA
- Database: H2 In-Memory Database (with H2 Web Console)
- Frontend: HTML5, Vanilla CSS3 (Custom Glassmorphism Design System), JavaScript (ES6+), Chart.js (CDN)
- Build Tool: Apache Maven
ElectronicVotingSystem/
βββ pom.xml
βββ README.md
βββ src/
βββ main/
β βββ java/com/evoting/app/
β β βββ ElectronicVotingSystemApplication.java
β β βββ controller/
β β β βββ AdminController.java
β β β βββ AuditController.java
β β β βββ AuthController.java
β β β βββ ElectionController.java
β β β βββ VotingController.java
β β βββ model/
β β β βββ AuditLog.java
β β β βββ Candidate.java
β β β βββ Election.java
β β β βββ Position.java
β β β βββ User.java
β β β βββ VoteLedger.java
β β βββ repository/
β β β βββ AuditLogRepository.java
β β β βββ CandidateRepository.java
β β β βββ ElectionRepository.java
β β β βββ PositionRepository.java
β β β βββ UserRepository.java
β β β βββ VoteLedgerRepository.java
β β βββ service/
β β βββ AuditService.java
β β βββ AuthService.java
β β βββ CryptoService.java
β β βββ DataInitializer.java
β β βββ ElectionService.java
β β βββ VotingService.java
β βββ resources/
β βββ application.properties
β βββ static/
β βββ css/
β β βββ styles.css
β βββ js/
β β βββ app.js
β βββ index.html
- Java Development Kit (JDK 21 or higher)
- Apache Maven 3.8+
git clone https://github.com/NKumar-B/Electronic_voting_system.git
cd Electronic_voting_system
# Compile project using Maven
mvn clean compilemvn spring-boot:runOnce started, access the Web Portal in your browser:
- Web Portal: http://localhost:8080
- H2 Database Console: http://localhost:8080/h2-console
- JDBC URL:
jdbc:h2:mem:evotingdb - Username:
sa - Password: (leave blank)
- JDBC URL:
The application auto-seeds initial demo users, active elections, candidates, and initial cryptographic vote blocks on startup:
| Role | Voter ID | Password | Access Rights | |
|---|---|---|---|---|
| Voter 1 | VOTER-1001 |
alice@example.com |
voter123 |
Digital Voting Booth, Receipt Verification |
| Voter 2 | VOTER-1002 |
bob@example.com |
voter123 |
Digital Voting Booth, Receipt Verification |
| Admin | VOTER-ADMIN-001 |
admin@securevote.gov |
admin123 |
Create Elections, Manage Candidates, Toggle Status |
| Auditor | VOTER-AUDIT-001 |
auditor@securevote.gov |
audit123 |
Run SHA-256 Chain Verification, Inspect Audit Logs |
POST /api/auth/login: Authenticate user session.POST /api/auth/register: Register new voter.GET /api/auth/users: List registered users.
GET /api/elections: Fetch all system elections.GET /api/elections/{id}/ballot: Fetch positions, candidates, and total votes cast for an election.POST /api/elections: Create new election (Admin).PUT /api/elections/{id}/status: Toggle election status (ACTIVE,CLOSED,PAUSED) (Admin).POST /api/elections/positions/{positionId}/candidates: Add candidate to position (Admin).
POST /api/vote/cast: Atomically record vote in SHA-256 chain ledger.GET /api/vote/check: Check if voter has cast ballot for position.GET /api/vote/verify-receipt/{receiptCode}: Verify receipt code in cryptographic chain.
GET /api/audit/verify-chain: Trigger full SHA-256 block chain verification.GET /api/audit/logs: Retrieve system activity audit logs.
Block N-1: [Hash: 6f8c4e...] <ββββ
β Parent Link
Block N: [Prev: 6f8c4e... | Election: 1 | VoterHash: a3b... | Candidate: 2 | Timestamp]
ββββΊ Block Hash (SHA-256): a01f37...
- Chain Integrity: Changing any field in a past block alters its
voteHash, causing all subsequent blocks to fail verification. - Double-Voting Prevention: The
existsByElectionIdAndPositionIdAndVoterHashcheck prevents duplicate votes without identifying the voter's candidate selection. - Concurrency Safety:
VotingService.castVote()uses synchronized transactions to prevent race conditions during vote registration.
This project is open-source and available under the MIT License.