Skip to content

sudiptog81/ducs-voting-system

Repository files navigation

DUCS Voting System

This repository contains the source code for the voting system used for DUCSS Elections 2023. It was built on top of the Next.js framework and uses Prisma as an ORM for the database. The databases used were PostgreSQL for deployed instances and SQLite for offline instances.

Features

  • Authentication using a list of email addresses in database
  • Voting for candidates running for various posts
  • Visualization results of the election
  • Visualization of list of students who have voted
  • Support for multiple courses and sections
  • TODO: Support for multiple elections

Notes

  • A voter can vote for only one candidate for a post
  • A voter can vote only once and cannot change their vote

Instructions

  • The list of students who can vote is stored in the User table in the database
  • The list of candidates running for various posts is stored in the Candidate table in the database
  • The list of votes casted by students is stored in the Vote table in the database

Guarded Routes

These routes are accessible only when a secret is provided as a query parameter defined in the environment variable NEXT_PUBLIC_SECRET.

  • The list of students who have voted can be viewed at /list route
  • The statistics of the election can be viewed at /stats route only when a secret is provided as a query parameter defined in the environment variable NEXT_PUBLIC_SECRET

Getting Started

Prerequisites

  • Node.js v20+
  • Yarn Package Manager
  • PostgreSQL / SQLite

Setup

  1. Clone the repository and navigate to the directory
$ git clone https://github.com/sudiptog81/ducs-voting-system
$ cd ducs-voting-system
  1. Install dependencies
$ yarn install --include=dev
  1. Create a .env file in the root directory and add the following environment variables
DATABASE_URL="postgresql://<username>:<password>@<host>:<port>/<database>?schema=public" # For PostgreSQL
DATABASE_URL="file:./dev.db" # For SQLite

NEXT_PUBLIC_SECRET="...secret used for stats and list pages..."
NEXTAUTH_SECRET="...secret used for authentication..."
  1. Run the migrations
$ yarn prisma migrate reset
$ yarn prisma db push
  1. Run the development server
$ yarn dev
  1. Start the database interface
$ yarn prisma studio

Deployment

  1. Build the application
$ yarn build
  1. Start the application
$ yarn start

Deployment on Vercel

  1. Create a new project on Vercel and link it to the GitHub repository

  2. Add the following environment variables

DATABASE_URL="postgresql://<user>:<pass>@<host>:<port>/<db>" # For PostgreSQL

NEXT_PUBLIC_SECRET="...secret used for stats and list pages..."
NEXTAUTH_SECRET="...secret used for authentication..."
  1. Redeploy the application on Vercel

Screenshots

1 2 3 4 5 6

License

Distributed under the MIT License. See LICENSE.md for more information.

Author

Sudipto Ghosh
Postgraduate Student
Department of Computer Science
Faculty of Mathematical Sciences
University of Delhi

About

Source Code for the voting system used for DUCSS Elections 2023

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published