This is a smart election system built with React and Ballerina, designed to manage online elections with two distinct interfaces:
-
Admin Dashboard - Admins can create elections by adding voters and candidates, and set the election's time period. Voters and candidates can be added until the election begins. Once the election starts, no further additions are allowed, and results remain hidden.
Admins add voters using their Gmail and NIC number. When a voter participates in the election, they need to log in using the Gmail address added by the admin and provide their NIC number to cast their vote.
Additionally, admins can bulk add voters and candidates by uploading a CSV file. A sample template for the CSV format is provided in the samplefolder of this project.
Admin management: Admins can also add additional admins to the system to help manage the election process
After the election ends (based on the pre-defined time period), admins can view detailed results, including:
- 📊 A pie chart showing the percentage of total votes.
- 📋 The percentage and number of votes received by each candidate.
(Currently, the system supports Gmail login only, but future upgrades will allow other email services.)
-
Voter Interface - Registered voters can log in and participate in the elections during the election time window by using their NIC number and Gmail address.
-
Clone the repository to your desired directory.
-
Install necessary dependencies for each part of the system:
cd backend -> bal build cd admin -> npm install cd frontend -> npm install
-
Create a
Config.toml
file in thebackend
directory and add the following data:defalt_admin = "<Your default admin email>" password = "<Your admin password>" frontUrl = "<Your frontend URL e.g. 'http://localhost:5174'>" adminUrl = "<Your admin URL e.g. 'http://localhost:5173'>"
-
Set up Google OAuth for the frontend by creating a
.env
file and adding your Google OAuth Client ID.For detailed instructions on how to obtain a Google OAuth Client ID, refer to this article:
Obtaining a Google OAuth Client ID. (Here we have already added google auth client id, if you need your id see this document)
To run the project, execute the following commands from the root directory:
1. npm install
2. npm run start-all