Skip to content

About

SecureVote is an enterprise-grade full-stack Java web application designed for secure, transparent, and tamper-proof electronic elections.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ SecureVote - Cryptographic Full-Stack Java Electronic Voting System

Java Version Spring Boot Database License

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.


🌟 Key Features

πŸ”’ 1. SHA-256 Cryptographic Chain Ledger

  • 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.

πŸ”¬ 2. Auditor & Security Oversight Center

  • 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.

πŸ—³οΈ 3. Digital Voting Booth (Interactive Wizard)

  • 4-Step Guided Voting:
    1. Voter Verification: Authorization & constituency check.
    2. Ballot Selection: Interactive candidate cards with party manifestos and photos.
    3. Review & Cryptographic Sign: Final selection review before ledger signing.
    4. Cryptographic Receipt Ticket: Printable digital receipt with block hash details.

πŸ“Š 4. Real-Time Results Analytics

  • 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.

βš™οΈ 5. Multi-Role Management

  • 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.

πŸ—οΈ System Architecture

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    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   β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’» Tech Stack

  • 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

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

  • Java Development Kit (JDK 21 or higher)
  • Apache Maven 3.8+

1. Clone & Build the Application

git clone https://github.com/NKumar-B/Electronic_voting_system.git
cd Electronic_voting_system

# Compile project using Maven
mvn clean compile

2. Run the Application

mvn spring-boot:run

Once started, access the Web Portal in your browser:


πŸ”‘ Pre-Loaded Seed Credentials

The application auto-seeds initial demo users, active elections, candidates, and initial cryptographic vote blocks on startup:

Role Voter ID Email 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

πŸ“‘ REST API Documentation

Authentication (/api/auth)

  • POST /api/auth/login: Authenticate user session.
  • POST /api/auth/register: Register new voter.
  • GET /api/auth/users: List registered users.

Elections (/api/elections)

  • 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).

Voting (/api/vote)

  • 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.

Audit & Security (/api/audit)

  • GET /api/audit/verify-chain: Trigger full SHA-256 block chain verification.
  • GET /api/audit/logs: Retrieve system activity audit logs.

πŸ›‘οΈ Security & Integrity Design

Block N-1: [Hash: 6f8c4e...] <───┐
                                  β”‚ Parent Link
Block N:   [Prev: 6f8c4e... | Election: 1 | VoterHash: a3b... | Candidate: 2 | Timestamp]
           └──► Block Hash (SHA-256): a01f37...
  1. Chain Integrity: Changing any field in a past block alters its voteHash, causing all subsequent blocks to fail verification.
  2. Double-Voting Prevention: The existsByElectionIdAndPositionIdAndVoterHash check prevents duplicate votes without identifying the voter's candidate selection.
  3. Concurrency Safety: VotingService.castVote() uses synchronized transactions to prevent race conditions during vote registration.

πŸ“œ License

This project is open-source and available under the MIT License.

About

SecureVote is an enterprise-grade full-stack Java web application designed for secure, transparent, and tamper-proof electronic elections.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages