A secure, transparent, and decentralized online voting system built with blockchain technology to ensure vote integrity and prevent tampering.
- Blockchain-based Security: Custom blockchain implementation with SHA-256 hashing and proof-of-work consensus
- Email OTP Verification: Secure user registration with email-based OTP verification
- Admin Panel: Token-based administrative interface for managing organizations and voting sessions
- Organization Management: Dynamic addition and removal of participating organizations
- Real-time Vote Tracking: Live vote counting with blockchain verification
- Tamper-proof Results: Immutable vote records stored on blockchain
- Web Interface: User-friendly web interface for voting and administration
The system consists of several key components:
- FastAPI Server (
main.py
): Main application server handling voting logic - Blockchain Engine (
blockchainfolder/chain.py
): Custom blockchain implementation - User Registration (
Varified_gmail_and_password/
): Flask-based OTP verification system - Web Interface (
templates/
,static/
): HTML/CSS frontend
- User Database: JSON-based user storage with encrypted passwords
- Organization Config: Text-based configuration for participating organizations
- Blockchain Data: In-memory blockchain with persistent vote records
- Python 3.8 or higher
- Gmail account for OTP email service (or SMTP server)
- Internet connection for email verification
Linux/macOS:
git clone https://github.com/Akashbht/OVS_2.O.git
cd OVS_2.O
./setup.sh
Windows:
git clone https://github.com/Akashbht/OVS_2.O.git
cd OVS_2.O
setup.bat
-
Clone the repository
git clone https://github.com/Akashbht/OVS_2.O.git cd OVS_2.O
-
Install dependencies
pip install -r requirements.txt
-
Configure email settings
cp .env.example .env # Edit .env with your email credentials
-
Set up configuration files
cp config/organizations.example.txt config/organizations.txt cp Varified_gmail_and_password/users.example.json Varified_gmail_and_password/users.json
-
Start the main voting server
python main.py
The server will start on
http://localhost:8000
-
Start the registration server (optional, for new user registration)
cd Varified_gmail_and_password python server.py
Registration server will start on
http://localhost:5000
-
Access Admin Panel
- Navigate to
http://localhost:8000/admin
- Use the admin token displayed in the console
- Navigate to
-
Managing Organizations
- Add new organizations via the admin panel
- Delete organizations using the admin interface
-
Controlling Voting
- Start voting session: POST to
/admin/start
with admin token - Stop voting session: POST to
/admin/stop
with admin token
- Start voting session: POST to
-
User Registration (if not already registered)
- Visit registration portal
- Provide email, name, age, and password
- Verify email via OTP
-
Casting Vote
- Navigate to the main voting page
- Enter user credentials
- Select organization using organization code
- Submit vote (creates blockchain entry)
-
View Results
- Access
/getvotes
for total vote count - Access
/getvotesbyorg
for organization-wise results (after voting ends)
- Access
GET /
- Main voting interfacePOST /voter/vote
- Cast a voteGET /getOrgDetail
- Get organization details
GET /admin
- Admin panel interfacePOST /admin/login
- Admin authenticationPOST /admin/start
- Start voting sessionPOST /admin/stop
- Stop voting sessionPOST /admin/add_organization
- Add new organizationPOST /admin/delete_organization
- Remove organization
GET /getvotes
- Get total vote countGET /getvotesbyorg
- Get votes by organization
- Blockchain Integrity: Each vote creates a new block with cryptographic hash
- Proof of Work: Mining difficulty ensures computational cost for tampering
- User Authentication: Email verification and password protection
- Admin Security: Token-based administrative access
- Vote Immutability: Once cast, votes cannot be modified or deleted
OVS_2.O/
βββ main.py # Main FastAPI application
βββ requirements.txt # Python dependencies
βββ Procfile # Heroku deployment configuration
βββ blockchainfolder/
β βββ chain.py # Blockchain implementation
βββ Varified_gmail_and_password/
β βββ server.py # Flask registration server
β βββ otp.py # OTP generation and email
β βββ users.json # User database
β βββ templates/ # Registration templates
βββ templates/ # Main app HTML templates
β βββ item.html # Voting interface
β βββ confirm.html # Vote confirmation
β βββ admin_login.html # Admin login
β βββ admin_panel.html # Admin dashboard
βββ static/ # CSS and static files
β βββ style.css # Main styling
β βββ confirm.css # Confirmation page styling
βββ config/ # Configuration files
β βββ organizations.txt # Organization data
β βββ token.txt # Admin token
βββ dbfolder/
β βββ userdata.py # Additional user data
βββ utils.py # Utility functions
βββ user_data.py # User data management
βββ otp.py # OTP utilities
βββ test.py # Blockchain testing
Run the blockchain test to verify functionality:
python test.py
The application is ready for deployment on platforms like Heroku:
- Ensure
Procfile
is configured correctly - Set environment variables for email configuration
- Deploy using your preferred platform
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source and available under the MIT License.
This is an educational project demonstrating blockchain concepts in voting systems. For production use, additional security measures and extensive testing would be required.
- Akashbht - Initial work - Akashbht