| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Pollify is an online voting system designed to simplify the electoral process through secure, intuitive features, two-factor authentication, and real-time data visualization.
Pollify enables a smooth, structured election process, making it ideal for online voting scenarios. The system supports different types of users with distinct functionalities, ensuring an organized, secure election.
Create the Database
CREATE DATABASE pollify;
USE pollify;
Create Required Tables
Users table:
CREATE TABLE Users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(100) UNIQUE NOT NULL,
email VARCHAR(150) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'voter', 'candidate') NOT NULL,
status ENUM('pending', 'approved') DEFAULT 'pending',
voted BOOLEAN DEFAULT FALSE,
phone_number VARCHAR(20),
otp_code VARCHAR(10),
otp_expiry DATETIME,
manifesto TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);VotingPeriod table:
CREATE TABLE VotingPeriod (
id INT AUTO_INCREMENT PRIMARY KEY,
start_time DATETIME,
end_time DATETIME,
is_active BOOLEAN DEFAULT FALSE
);Votes table:
CREATE TABLE Votes (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
candidate_id INT,
voting_period_id INT,
vote_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES Users(id) ON DELETE CASCADE,
FOREIGN KEY (candidate_id) REFERENCES Users(id) ON DELETE CASCADE,
FOREIGN KEY (voting_period_id) REFERENCES VotingPeriod(id) ON DELETE CASCADE
);Results table:
CREATE TABLE Results (
id INT AUTO_INCREMENT PRIMARY KEY,
voting_period_id INT,
winner_candidate_id INT,
total_votes INT DEFAULT 0,
winner_percentage DECIMAL(5,2),
turnout_ratio DECIMAL(5,2),
start_time DATETIME,
end_time DATETIME,
declared_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (voting_period_id) REFERENCES VotingPeriod(id) ON DELETE SET NULL,
FOREIGN KEY (winner_candidate_id) REFERENCES Users(id) ON DELETE SET NULL
);CandidateApplications table:
CREATE TABLE CandidateApplications (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
voting_period_id INT,
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
submission_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES Users(id) ON DELETE CASCADE,
FOREIGN KEY (voting_period_id) REFERENCES VotingPeriod(id) ON DELETE CASCADE
);Create MySQL Events
Activate Voting Period:
CREATE EVENT activate_voting_period
ON SCHEDULE EVERY 1 MINUTE
DO
UPDATE VotingPeriod SET is_active = TRUE
WHERE start_time <= NOW() AND end_time > NOW();Deactivate Voting Period:
CREATE EVENT deactivate_voting_period
ON SCHEDULE EVERY 1 MINUTE
DO
UPDATE VotingPeriod SET is_active = FALSE
WHERE end_time <= NOW();Download Apache Tomcat 9
Download Tomcat 9 from the official website: Apache Tomcat 9 Download.
Clone the Pollify Repository
Clone the Pollify GitHub repository into the webapps folder of your Apache Tomcat directory:
git clone https://github.com/lakshitcodes/pollify.git /path/to/tomcat/webapps/pollifyCreate Database Credentials File
Inside the directory /pollify/WEB-INF/classes/com/pollify, create a file named DBCredentials.java with the following code. Replace "your_username" and "your_password" with your actual MySQL credentials:
package com.pollify;
public class DBCredentials {
private static final String DB_URL = "jdbc:mysql://localhost:3306/pollify";
private static final String DB_USER = "your_username";
private static final String DB_PASS = "your_password";
public static String getDbUrl() {
return DB_URL;
}
public static String getDbUser() {
return DB_USER;
}
public static String getDbPass() {
return DB_PASS;
}
}Download Required Libraries
Place the following JAR files in the lib folder of your Apache Tomcat directory:
Compile Java Files
If Apache Tomcat is installed in the Downloads folder of your macOS system, run the following command to compile all .java files in pollify/WEB-INF/classes/com/pollify:
javac -cp "/Users/lakshitjain/Downloads/apache-tomcat-9.0.96/lib/*:/Users/lakshitjain/Downloads/apache-tomcat-9.0.96/lib/mysql-connector-j-9.0.0.jar:/Users/lakshitjain/Downloads/apache-tomcat-9.0.96/lib/activation-1.1.1.jar" /Users/lakshitjain/Downloads/apache-tomcat-9.0.96/webapps/pollify/WEB-INF/classes/com/pollify/*.javaStart Apache Tomcat
Navigate to the bin directory of your Apache Tomcat installation and start the server to deploy the Pollify application:
cd /path/to/tomcat/bin
./startup.sh
Access Pollify
Open a web browser and go to http://localhost:8080/pollify/register.jsp to access the Pollify application.
Once the Apache Tomcat server is up and running, you can access Pollify at http://localhost:8080/pollify/register.jsp. Register as a user or log in as an admin to explore the various functionalities of the system.
| Back | FazBrowse Home | New Git URL |