Giter Site home page Giter Site logo

anirudhachal / secure-ranked-choice-e-voting Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 5.39 MB

Software Engineering Lab Project

Home Page: https://securerankedchoice.herokuapp.com/

Python 33.37% HTML 1.26% JavaScript 64.29% CSS 0.98% Shell 0.10%
software-engineering full-stack-web-development react django-rest-framework postgresql

secure-ranked-choice-e-voting's Introduction

Secure-Ranked-Choice-E-Voting

Secure Ranked Choice E-Voting is a web application that provides an easy-to-use method of collecting encrypted ballots that is secure against malicious actors, and capable of authenticating voters properly. Additionally, the web interface allows the tabulation of election results and the public posting of those results. The elections will follow ranked choice voting which has become more popular than single choice voting.

The goal of this project is to build and deploy a robust, secure, reliable and user-friendly online voting application. This is achieved with cryptography methods. Real life use cases for this software application include Student Council elections, official college-related elections and any other type of election.

alt text

Note: All screenshots can be found in the screenshots directory.

Tech Stack

  • Frontend: React
  • Backend: Django Rest Framework
  • Database: PostgreSQL

Project Structure

.
├── Final Report.pdf
├── README.md
├── backend
│   ├── backend
│   │   ├── authentication
│   │   │   ├── __init__.py
│   │   │   ├── admin.py
│   │   │   ├── apps.py
│   │   │   ├── migrations
│   │   │   ├── models.py
│   │   │   ├── serializers.py
│   │   │   ├── tests.py
│   │   │   ├── urls.py
│   │   │   ├── utils.py
│   │   │   └── views.py
│   │   ├── backend
│   │   │   ├── __init__.py
│   │   │   ├── asgi.py
│   │   │   ├── settings.py
│   │   │   ├── urls.py
│   │   │   └── wsgi.py
│   │   ├── election
│   │   │   ├── __init__.py
│   │   │   ├── admin.py
│   │   │   ├── apps.py
│   │   │   ├── migrations
│   │   │   ├── models.py
│   │   │   ├── serializers.py
│   │   │   ├── tests.py
│   │   │   ├── urls.py
│   │   │   ├── utils.py
│   │   │   └── views.py
│   │   └── manage.py
│   └── requirements.txt
├── frontend
│   ├── README.md
│   ├── package-lock.json
│   ├── package.json
│   ├── public
│   │   ├── favicon.ico
│   │   ├── index.html
│   │   ├── logo192.png
│   │   ├── logo512.png
│   │   ├── manifest.json
│   │   └── robots.txt
│   └── src
│       ├── App.js
│       ├── axios.js
│       ├── components
│       │   ├── Admin
│       │   │   ├── AdminCompletedElectionContainerView.jsx
│       │   │   ├── AdminCompletedElectionView.jsx
│       │   │   ├── AdminDashboardContainerView.jsx
│       │   │   ├── AdminDashboardView.jsx
│       │   │   ├── AdminElectionContainerView.jsx
│       │   │   ├── AdminElectionView.jsx
│       │   │   ├── AdminNavbarContainerView.jsx
│       │   │   ├── AdminNavbarView.jsx
│       │   │   ├── AdminOngoingElectionContainerView.jsx
│       │   │   ├── AdminOngoingElectionView.jsx
│       │   │   ├── AdminUpcomingElectionContainerView.jsx
│       │   │   ├── AdminUpcomingElectionView.jsx
│       │   │   ├── CreateElectionContainerView.jsx
│       │   │   └── CreateElectionView.jsx
│       │   ├── Dashboard
│       │   │   ├── DashboardContainerView.jsx
│       │   │   ├── DashboardView.jsx
│       │   │   ├── NavbarContainerView.jsx
│       │   │   ├── NavbarView.jsx
│       │   │   ├── PageNotFoundContainerView.jsx
│       │   │   ├── PageNotFoundView.jsx
│       │   │   ├── ProfileContainerView.jsx
│       │   │   └── ProfileView.jsx
│       │   ├── Election
│       │   │   ├── BallotContainerView.jsx
│       │   │   ├── BallotView.jsx
│       │   │   ├── CompletedElectionContainerView.jsx
│       │   │   ├── CompletedElectionView.jsx
│       │   │   ├── ElectionContainerView.jsx
│       │   │   ├── ElectionView.jsx
│       │   │   ├── OngoingElectionContainerView.jsx
│       │   │   ├── OngoingElectionView.jsx
│       │   │   ├── ResultContainerView.jsx
│       │   │   ├── ResultStaticView.jsx
│       │   │   ├── ResultView.jsx
│       │   │   ├── UpcomingElectionContainerView.jsx
│       │   │   └── UpcomingElectionView.jsx
│       │   ├── User
│       │   │   ├── LoginContainerView.jsx
│       │   │   ├── LoginView.jsx
│       │   │   ├── MyProfileContainerView.jsx
│       │   │   ├── MyProfileView.jsx
│       │   │   ├── PasswordResetContainerView.jsx
│       │   │   ├── PasswordResetEmailContainerView.jsx
│       │   │   ├── PasswordResetEmailView.jsx
│       │   │   ├── PasswordResetView.jsx
│       │   │   ├── RegisterContainerView.jsx
│       │   │   ├── RegisterView.jsx
│       │   │   ├── VerifyEmailContainerView.jsx
│       │   │   └── VerifyEmailView.jsx
│       │   ├── styles
│       │   │   ├── CreateElectionView.css
│       │   │   ├── LoginView.css
│       │   │   ├── MyProfileView.css
│       │   │   ├── PageNotFound.css
│       │   │   ├── PasswordResetEmailView.css
│       │   │   ├── PasswordResetView.css
│       │   │   ├── RegisterView.css
│       │   │   ├── ResultView.css
│       │   │   └── VerifyEmailView.css
│       │   └── utils
│       │       ├── authentication.js
│       │       ├── response.js
│       │       └── user.js
│       ├── images
│       │   ├── completed.png
│       │   ├── lighthouse.jpg
│       │   ├── ongoing.jpg
│       │   └── upcoming.jpg
│       └── index.js
└── screenshots

19 directories, 138 files

Backend Setup

1. Create a new virtual environment

cd backend
python -m venv env

2. Activate the virtual enviromnent

On Windows

env\Scripts\activate

On Linux

source env/bin/activate

3. Install python packages

On Linux

sudo apt install libpq-dev python3-dev
pip install wheel
pip install -r requirements.txt

On Windows

pip install -r requirements.txt

4. Setup environment variables

  • Create a .env file at the root directoy of the backend (at the same level as manage.py)
  • Add secret keys using the .env.example file as reference

5. Setup Django Database

cd backend
python manage.py migrate

6. Start Django Restful API

python manage.py runserver

Frontend Setup

cd frontend
npm ci
npm start

Local Database Setup

  • Create a new local PostgreSQL database using PgAdmin
  • Add all required environment variables in the .env file using the .env.example file as reference

Resources

secure-ranked-choice-e-voting's People

Contributors

53nterprise avatar anirudhachal avatar ayushman1 avatar deltacube23 avatar dragonado avatar muditsinghal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

secure-ranked-choice-e-voting's Issues

Build Error while insalling psycopg2

In your local system do this first : sudo apt-get install libpq-dev.
Before installing requirements.txt in venv do the following command pip install wheel.

Improve getRandomColor() function

The current getRandomColor() function in ResultView.jsx is not very good.
Consecutive calling of that function returns similar colors.
This leads to consecutive candidates having similar colors making it difficult to distinguish.
Someone fix it pls.

Ranked Choice Vote Calculation Code

# ballots is a 2 - d array of votes
# listed in preference order of candidates of each voter

def count_votes():
	ballots = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 3, 2],
			  [2, 1, 3], [3, 2, 1]]

	round = 0
	winner = 0
	candidates = len(ballots[0])
	voters = len(ballots)
	majority = voters/2
	track = [0] * voters
	skip = [0] * candidates
        result_history = []

	while round < candidates:
		arr = [0] * candidates
		# count votes
		for i in range(0, voters):
			arr[ballots[i][track[i]] - 1] += 1

		print(arr)
                result_history.append(arr)
		# check for majority
		lowest = arr.index(max(arr))
		for i in range(0, candidates):
			if skip[i] == 1:
				continue
			if arr[i] > majority:
				winner = i+1
			if arr[lowest] > arr[i]:
				lowest = i

		if winner != 0:
			break 
		print(lowest)
		# eliminate loser
		skip[lowest] = 1
		for i in range(0, voters):
			while skip[ballots[i][track[i]] - 1] == 1:
				track[i] += 1
		round += 1

	print(winner, round)	
		
count_votes()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.