A decentralized, transparent, and secure voting application built on blockchain technology to ensure election integrity, voter privacy, and democratic transparency.
- Problem Statement
- Project Overview
- Features
- Tech Stack
- Installation
- Environment Variables
- Running Locally
- Folder Structure
- API Endpoints
- Deployment
- Screenshots
- Contributing
- License
Traditional voting systems face critical challenges:
- Centralized Data: Election results are vulnerable to manipulation at a single point of authority
- Lack of Transparency: Voters cannot independently verify their vote was counted correctly
- Trust Deficit: Citizens must rely entirely on government institutions without cryptographic proof
- Auditability Issues: No immutable record of voting transactions for audits or recounts
- Privacy Concerns: Identity and vote linkage creates security risks
Blockchain Voting App addresses these challenges through:
-
Immutable Records: Every vote is recorded as a cryptographic block on a distributed ledger. Once added, votes cannot be altered or deleted without leaving evidence.
-
Decentralized Verification: County nodes maintain independent copies of the blockchain. No single authority can change results—all nodes must agree.
-
End-to-End Verifiability: Voters receive a transaction hash to verify their vote was counted correctly without revealing who they voted for.
-
Cryptographic Security: Voter identity is hashed (never stored on-chain). Votes are encrypted and mathematically secure.
-
Transparent Audit Trail: Complete voting history is publicly accessible via the blockchain explorer for independent audits.
-
Reduced Election Fraud: The distributed nature and cryptographic foundations make it computationally infeasible to commit fraud at scale.
Blockchain Voting App is a web-based application that enables secure voting across multiple electoral positions in a single session. Built with scalability and security in mind, it implements blockchain consensus mechanisms to create an verifiable and transparent election system.
Key Capabilities:
- Register voters with biometric ID verification
- Cast ballots for 6 elective positions simultaneously
- Auto-mine votes into blockchain blocks
- Real-time results aggregation across 47 counties
- Independent vote verification using transaction hashes
✅ Voter Authentication
- National ID (Huduma Namba) verification
- Identity hashing (never stored on-chain)
- County and constituency-level registration
✅ Secure Voting
- Vote for 6 positions: President, Senator, Women Rep, Governor, MP, MCA
- Encrypted ballot storage
- Draft ballot auto-save functionality
✅ Blockchain Integration
- Automatic block mining after vote submission
- Distributed ledger with county node consensus
- Cryptographic hash verification
✅ Transparency & Verification
- Live results dashboard by position and county
- Blockchain explorer for transaction verification
- Vote receipt with transaction hash
✅ Privacy Protection
- Voter identity never linked to vote on-chain
- Cryptographic vote encryption
- Anonymous vote verification
✅ Accessibility
- ARIA labels and semantic HTML
- Responsive design (desktop & mobile)
- Clear error messaging and validation
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite |
| Styling | CSS3 (Grid, Flexbox, Animations) |
| State Management | React Hooks (useState, useCallback, useMemo) |
| Backend | Node.js + Express.js |
| Database | MongoDB |
| Authentication | JWT (JSON Web Tokens) |
| Cryptography | SHA-256 hashing |
| Storage | LocalStorage (client-side persistence) |
- Node.js 16.x or higher
- npm 8.x or higher
- MongoDB 5.x or higher (for backend)
- Git for version control
git clone https://github.com/yourusername/blockchain-voting-app.git
cd blockchain-voting-app# Install frontend dependencies
npm install
# Install backend dependencies (if backend is in separate folder)
cd backend
npm install
cd ..Create a .env file in the root directory:
VITE_API_URL=http://localhost:5000
VITE_APP_NAME=Blockchain Voting App
VITE_ELECTION_YEAR=2027Create a .env file in the backend directory:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/voting_app
JWT_SECRET=your_jwt_secret_key_here
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000Important: Never commit .env files to version control. Add to .gitignore:
.env
.env.local
.env.*.local
# From the root directory
npm run devThe app will be available at http://localhost:5173
# From the backend directory
cd backend
npm run devThe API will be available at http://localhost:5000
- Open
http://localhost:5173in your browser - Click "Cast Your Ballot" to begin voter registration
- Enter your details (National ID, name, county, constituency, ward)
- Vote for all 6 positions
- Confirm and submit your ballot
- Receive your transaction hash for future verification
blockchain-voting-app/
├── public/ # Static assets
│ ├── index.html
│ ├── manifest.json
│ └── robots.txt
│
├── src/
│ ├── components/ # React components
│ │ ├── LandingPage.jsx # Hero and overview
│ │ ├── RegistrationForm.jsx # Voter verification
│ │ ├── BallotScreen.jsx # Voting interface
│ │ ├── ConfirmBallot.jsx # Review & confirmation
│ │ ├── Results.jsx # Live results dashboard
│ │ ├── Receipt.jsx # Vote confirmation
│ │ ├── BlockchainExplorer.jsx # Transaction explorer
│ │ ├── Navigation.jsx # Header navigation
│ │ ├── MiningOverlay.jsx # Mining animation
│ │ └── index.js # Exports all components
│ │
│ ├── utils/ # Utility functions
│ │ ├── blockchain.js # Block generation & hashing
│ │ ├── validation.js # Form & data validation
│ │ ├── localStorage.js # Persistent storage
│ │ └── index.js # Utility exports
│ │
│ ├── App.js # Main app entry
│ ├── App-refactored.jsx # Primary app component
│ ├── App.test.js # App tests
│ ├── index.js # React DOM render
│ ├── styles.css # Global styles
│ ├── App.css # App-specific styles
│ ├── index.css # Base styles
│ ├── constants.js # Election data (candidates, positions)
│ └── setupTests.js # Test configuration
│
├── backend/ # Node.js backend (if separate)
│ ├── routes/
│ │ ├── auth.js # Authentication endpoints
│ │ ├── votes.js # Vote submission
│ │ └── blockchain.js # Blockchain endpoints
│ ├── models/
│ │ ├── Voter.js
│ │ ├── Vote.js
│ │ └── Block.js
│ ├── middleware/
│ │ ├── auth.js # JWT verification
│ │ └── validation.js # Input validation
│ ├── server.js # Express app config
│ └── package.json
│
├── .gitignore
├── package.json # Frontend dependencies
├── vite.config.js # Vite configuration
├── README.md # This file
└── LICENSE
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register voter with ID |
POST |
/api/auth/login |
Authenticate and receive JWT |
GET |
/api/auth/verify |
Verify current session |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/votes/submit |
Submit encrypted ballot |
GET |
/api/votes/status/:txHash |
Check vote status by transaction hash |
GET |
/api/votes/county/:countyId |
Get vote count by county |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/blockchain/chain |
Retrieve full blockchain |
GET |
/api/blockchain/block/:index |
Get specific block |
GET |
/api/blockchain/verify/:txHash |
Verify transaction |
GET |
/api/blockchain/stats |
Blockchain statistics |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/results/national |
National vote counts |
GET |
/api/results/county/:countyId |
County-level results |
GET |
/api/results/position/:positionId |
Results by position |
Vercel:
npm install -g vercel
vercelNetlify:
npm run build
# Upload 'dist' folder to NetlifyEnvironment Variables:
Set VITE_API_URL to your production backend URL in deployment settings.
Railway:
npm install -g @railway/cli
railway login
railway upRender:
- Connect GitHub repository
- Set environment variables in Render dashboard
- Auto-deploys on git push
Environment Variables on Production:
MONGODB_URI: Production MongoDB connection stringJWT_SECRET: Strong random secret (useopenssl rand -base64 32)NODE_ENV: "production"CORS_ORIGIN: Frontend production URL
Shows hero section with features and CTA buttons.
[Screenshot placeholder - election overview]
Secure identity verification form.
[Screenshot placeholder - registration form with 3-part name field]
Vote for all 6 elective positions.
[Screenshot placeholder - ballot voting interface]
Real-time vote aggregation dashboard.
[Screenshot placeholder - results by position and county]
Verify transactions independently.
[Screenshot placeholder - blockchain transaction explorer]
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes with clear commit messages
- Test thoroughly before submitting
- Push to your fork:
git push origin feature/your-feature-name - Open a Pull Request with a description of changes
- Follow existing code style (React hooks, functional components)
- Add tests for new features
- Update documentation if needed
- Keep commits atomic and descriptive
- No console errors or warnings
Found a bug? Open an issue with:
- Clear title and description
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
This project is licensed under the MIT License. See LICENSE file for details.
You are free to:
- Use commercially
- Modify the code
- Distribute copies
With the condition that you include the original license and copyright notice.
For questions or support:
- Email: villeowan@gmail.com
- GitHub Discussions: Start a discussion