Skip to content

A blockchain-powered Online Voting System (OVS 2.0) enabling secure, transparent, and tamper-proof digital elections. Leverages smart contracts for vote integrity, cryptographic authentication for voter privacy, and decentralized architecture to eliminate single points of failure.

License

Notifications You must be signed in to change notification settings

ayush01-dev/Online_voting_system_BlockChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OVS 2.0 - Online Voting System using Blockchain

A secure, transparent, and decentralized online voting system built with blockchain technology to ensure vote integrity and prevent tampering.

πŸš€ Features

  • 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

πŸ—οΈ Architecture

The system consists of several key components:

Core 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

Data Storage

  • 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

πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • Gmail account for OTP email service (or SMTP server)
  • Internet connection for email verification

πŸ› οΈ Installation

Quick Setup (Recommended)

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

Manual Installation

  1. Clone the repository

    git clone https://github.com/Akashbht/OVS_2.O.git
    cd OVS_2.O
  2. Install dependencies

    pip install -r requirements.txt
  3. Configure email settings

    cp .env.example .env
    # Edit .env with your email credentials
  4. 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

πŸš€ Usage

Starting the Application

  1. Start the main voting server

    python main.py

    The server will start on http://localhost:8000

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

Admin Operations

  1. Access Admin Panel

    • Navigate to http://localhost:8000/admin
    • Use the admin token displayed in the console
  2. Managing Organizations

    • Add new organizations via the admin panel
    • Delete organizations using the admin interface
  3. Controlling Voting

    • Start voting session: POST to /admin/start with admin token
    • Stop voting session: POST to /admin/stop with admin token

Voting Process

  1. User Registration (if not already registered)

    • Visit registration portal
    • Provide email, name, age, and password
    • Verify email via OTP
  2. Casting Vote

    • Navigate to the main voting page
    • Enter user credentials
    • Select organization using organization code
    • Submit vote (creates blockchain entry)
  3. View Results

    • Access /getvotes for total vote count
    • Access /getvotesbyorg for organization-wise results (after voting ends)

πŸ”§ API Endpoints

Voting Endpoints

  • GET / - Main voting interface
  • POST /voter/vote - Cast a vote
  • GET /getOrgDetail - Get organization details

Admin Endpoints

  • GET /admin - Admin panel interface
  • POST /admin/login - Admin authentication
  • POST /admin/start - Start voting session
  • POST /admin/stop - Stop voting session
  • POST /admin/add_organization - Add new organization
  • POST /admin/delete_organization - Remove organization

Results Endpoints

  • GET /getvotes - Get total vote count
  • GET /getvotesbyorg - Get votes by organization

πŸ” Security Features

  • 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

πŸ“ Project Structure

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

πŸ§ͺ Testing

Run the blockchain test to verify functionality:

python test.py

🌐 Deployment

The application is ready for deployment on platforms like Heroku:

  1. Ensure Procfile is configured correctly
  2. Set environment variables for email configuration
  3. Deploy using your preferred platform

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

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

πŸ›‘οΈ Disclaimer

This is an educational project demonstrating blockchain concepts in voting systems. For production use, additional security measures and extensive testing would be required.

πŸ‘₯ Authors

πŸ”— Links

About

A blockchain-powered Online Voting System (OVS 2.0) enabling secure, transparent, and tamper-proof digital elections. Leverages smart contracts for vote integrity, cryptographic authentication for voter privacy, and decentralized architecture to eliminate single points of failure.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •