Skip to content

aleenagibi/Blockchain-Based-Voting-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blockchain-Based Voting System

A secure, transparent, and immutable voting system built with Flask and blockchain technology.

Features

  • πŸ” Secure Authentication: Separate login systems for voters and administrators
  • πŸ—³οΈ Vote Casting: Easy-to-use interface for casting votes
  • πŸ”— Blockchain Integration: All votes are recorded in an immutable blockchain
  • πŸ“Š Real-time Dashboard: Live voting results with charts and blockchain ledger
  • πŸ›‘οΈ Vote Integrity: Each voter can only vote once
  • 🎨 Modern UI: Responsive design with Bootstrap 5

Setup Instructions

Prerequisites

  • Python 3.7 or higher
  • pip (Python package installer)

Installation

  1. Clone or download the project

    cd "Voting system"
  2. Create a virtual environment (recommended)

    python -m venv .venv
    .venv\Scripts\activate  # On Windows
    # or
    source .venv/bin/activate  # On Linux/Mac
  3. Install dependencies

    pip install -r requirements.txt
  4. Run the application

    python app.py
  5. Access the application

    • Open your browser and go to http://localhost:5000

Usage

For Voters

image
  1. Register: Click "Register Voter" and fill in your details
image
  1. Login: Use your Voter ID and password to login
image
  1. Vote: Select your preferred political party and submit
image image

For Administrators

  1. Login: Use admin credentials (default: username: admin, password: admin123)
image
  1. Dashboard: View real-time results, blockchain ledger, and winner

Real-time Results: image Blockchain Ledger: image Validator Login: image image

Security Features

  • Environment Variables: Set SECRET_KEY and ADMIN_PASSWORD environment variables for production
  • Blockchain Validation: Automatic integrity checks on the blockchain
  • One Vote Per Voter: Prevents duplicate voting
  • Session Management: Secure session handling

Production Deployment

For production deployment, set these environment variables:

export SECRET_KEY="your-secure-secret-key"
export ADMIN_PASSWORD="your-secure-admin-password"

Technology Stack

  • Backend: Flask (Python web framework)
  • Database: SQLite (lightweight database)
  • Blockchain: Custom implementation with SHA-256 hashing
  • Frontend: Bootstrap 5, Chart.js
  • Security: Session-based authentication

File Structure

Voting system/
β”œβ”€β”€ app.py                 # Main Flask application
β”œβ”€β”€ blockchain.py          # Blockchain implementation
β”œβ”€β”€ database.db           # SQLite database (created automatically)
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ templates/           # HTML templates
β”‚   β”œβ”€β”€ index.html       # Home page
β”‚   β”œβ”€β”€ login.html       # Login page
β”‚   β”œβ”€β”€ register.html    # Registration page
β”‚   β”œβ”€β”€ vote.html        # Voting page
β”‚   └── admin_dashboard.html # Admin dashboard
└── README.md            # This file

About

Blockchain-based voting system using Flask and SQLite. Voters register/login, get one spendable voting coin, and cast anonymous ballots via tokens. A PoA blockchain records votes with multi-validator signatures and integrity checks. Admin dashboard shows real-time results and ledger. Bootstrap UI, easy setup, env-configurable secrets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors