Skip to content
/ Z-Vote Public

Blockchain Based E-Voting System on Django Framework

License

Notifications You must be signed in to change notification settings

akkupy/Z-Vote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlockChain Based E-Voting System

  • This project aims at implementing a voting system based on Blockchain technology.
  • It is a secure, transparent and decentralized way of voting.
  • It converts ballots into transactions and securely mines blocks out of them.
  • The advantage of a blockchain based voting system include the ability to vote from any place and prevent any tampering of votes.

Technology stack used:

  1. Python 3.11.x
  2. Django Web Framework 4.2.1
  3. Bootstrap 4
  4. DB SQLite 3
  5. HTML5

Mandatory Configs

  1. Go to API NINJA and signup to obtain the api key for passphrase generation.
  2. Create an Account on TWILIO and Buy a Phone Number to use the OTP Service.

Fill the env file with the obtained APIs.

[+] Create a env file in the root directory for the api tokens
    [-] DJANGO_SECRET_KEY=
    [-] DEBUG=
    [-] DJANGO_ALLOWED_HOSTS=
    [-] DJANGO_CSRF_TRUSTED_ORIGINS=
    [-] API_NINJA_API =
    [-] TWILIO_ACCOUNT_SID =
    [-] TWILIO_AUTH_TOKEN = 
    [-] TWILIO_PHONE_NUMBER = 

An Example Of "env" File

DJANGO_SECRET_KEY=#sdfgg4g7h%-y8b+34_^s$yo^$a63&*$Fb3^d
DEBUG=False
DJANGO_ALLOWED_HOSTS=10.1.1.50
API_NINJA_API=/ghjf53spoG657vghjygdr0qw==uRVWERV
TWILIO_ACCOUNT_SID=AA3w5fgdrfawd3459faedw4349a3b
TWILIO_AUTH_TOKEN=awd18f3ccac7329thfsf43fd4drgx1
TWILIO_PHONE_NUMBER=+134656544
DJANGO_CSRF_TRUSTED_ORIGINS=https://10.1.1.50

Z-vote Deployment On Raspberrypi Docker Container

Install Docker and Portainer if not already done.(refer here)

Folder Setup Script

  1. First thing we need to do is setup the folder structure.

Run the following script

wget -qO- https://raw.githubusercontent.com/akkupy/Homelab/main/scripts/zvote_dir.sh | sudo bash
  1. Now we need to move into that directory using the following:
cd /home/$USER/zvote
  1. Create an 'env' file
sudo nano env
  1. Fill the environment variables(see above)

  2. Pull the docker image of z-vote

docker pull akkupy/z-vote:latest
  1. Run the container
docker run -d \
  --name=z-vote \
  -e PUID=1000 \
  -e PGID=1000 \
  --env-file env \
  -p 8100:8100 \
  -v ./static:/app/static \
  --restart unless-stopped \
  akkupy/z-vote:latest
  1. Exec into the container using the command below
docker exec -it z-vote sh
  • You will see a new terminal like shown below.
/app #
  1. Run the following commands on the container terminal.
  • Enter the username and password for the superuser when prompted.
python manage.py makemigrations poll
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatic --noinput
  1. Press Ctrl+D to exit the container Terminal.

Install Nginx Proxy Manager if not already done(refer here).

Add a new volume(given below) to the nginx proxy manager container using portainer.

/home/$USER/zvote/static:/data/static

Setting up Nginx Proxy Manager for Z-vote


Go to login screen. First Login

Select Hosts > Proxy Hosts

Proxy Hosts

Select Add Proxy Hosts

Proxy Hosts

We need to enter the proxy information. In this example we are going to use the following information.

Secure External connections to the service using https.
Domain Name: homer.example.com
Scheme: https
Forward Hostname/IP address: your-ip
Port: 8100
Cache Assets: Disabled
Block Common Exploits: Enabled
Websockets Support: Disabled
Accesss List: Publicly Accessible

Most of these options should be self explanatory if you aren't sure what they do it is likely best to leave them disabled.

The most import options.

Domain Name is the public Domain name that will point at your host.
Forward Hostname/IP is the server running the resource.
Port is the port the service is running on that server(In our case its '8100').

Proxy Hosts

Hint: Generating Certificates can be complicated I will be outlining one of the simplest ways to generate one. There are other ways not outlined here.

Now we need to setup our secure https connection to the server. Select the SSL tab.

Method 1(Recommended for internet based usage):

Under SSL Certificates we are going to select Request a new SSL Certificate.

I am also going to select Force SSL this will prevent non-secure connections from being used.

I will agree to the terms after reading them you should at least review them once so you understand the terms of service.

It should have your correct email address listed if it doesn't please fix as this is where you will get alerts if there is an issue with the Certificate.

Proxy Hosts

Once you click Save it will generate a new certificate this can take a few minutes to do.

Method 2(Recommended for Local usage and usage with tailscale):

You can use a self generated SSL certificate(which can be generated here).In this case select Custom under the SSL Certificates and upload the key and certificate generated.

Post SSL Certificate Gerneration Go to Advanced Tab

  • Paste the Nginx Configuration given below(Change proxy_pass address to the one defined on details page).
location /static/{
                 root /data;
        }
    location / {
          proxy_pass http://<ip>:8100;
    }






Building Docker Container from Dockerfile (For Devs)

* Clone the repository and Build the container:

# Install Git First // (Else You Can Download And Upload to Your Local Server)
$ git clone -b production https://github.com/akkupy/Z-Vote.git
# Open Git Cloned File
$ cd Z-Vote
# Run Docker Build
$ docker build -t <name>:<tag> .

* Create env file(refer here)

* Run and Configure the container(refer here)




Contact Me

telegram

License

GNU GPLv3 Image

This is a Free Software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

--This is only a demonstration of the blockchain based voting system and it is entirely a prototype of the technology--