Online Voting system for Ethiopian fair and periodic election
# Online Voting System
A secure and anonymous voting system built with Node.js, Express, and PostgreSQL for Ethiopian political parties.
## Features
- **Secure Authentication**: Admin and voter login with bcrypt password hashing
- **Anonymous Voting**: Voters can cast votes without revealing identity
- **Admin Management**: Super admin can manage admin accounts and toggle voting periods
- **Real-time Results**: Live vote tallying and results display
- **Voter Registration**: Admin-controlled voter registration process
- **Session Management**: Secure session handling with express-session
- **Environment Configuration**: Sensitive data stored in environment variables
## Technologies Used
- **Backend**: Node.js, Express.js
- **Database**: PostgreSQL
- **Frontend**: EJS templates, HTML, CSS, JavaScript
- **Authentication**: bcryptjs for password hashing
- **Session Management**: express-session
- **Environment Variables**: dotenv
## Prerequisites
- Node.js (v14 or higher)
- PostgreSQL (v12 or higher)
- npm or yarn
## Installation
1. **Clone the repository**:
```bash
git clone
cd black-box-vote
```
2. **Install dependencies**:
```bash
npm install
```
3. **Set up the database**:
- Create a PostgreSQL database named `ethiopian_vote`
- Run the database schema:
```bash
psql -d ethiopian_vote -f database.sql
```
or simply run
node init_db.js
4. **Configure environment variables**:
- Copy `.env.example` to `.env` (if available) or create `.env` file
- Update the following variables:
```
DB_USER=your_postgres_username
DB_HOST=localhost
DB_NAME=ethiopian_vote
DB_PASSWORD=your_postgres_password
DB_PORT=5432
PORT=3000
```
5. **Initialize the database** (optional, for testing):
```bash
node init_db.js
```
## Usage
1. **Start the server**:
```bash
npm start
```
2. **Access the application**:
- Open your browser and go to `
localhost`
3. **Admin Setup**:
- Use `insert_admin.js` to create initial admin accounts
- Login as admin to manage voters an …