Skip to content

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—ณ๏ธ Web-Based Voting & Polling System

Python Django React JWT License

A secure full-stack online voting application that allows authenticated users to participate in polls while ensuring one vote per user using JWT-based authentication.

โš ๏ธ This project is available as source code and can be run locally by following the setup instructions below.


๐Ÿ“‘ Table of Contents


๐ŸŒ Project Status

Status Details
โœ… Source Code Available
โœ… Functionality Fully Functional (Local Development)
โณ Live Deployment Not Available

๐Ÿ“ธ Screenshots

๐Ÿ  Home / Login Page

Home Page

๐Ÿ“ Registration

Register Page

๐Ÿง‘โ€๐Ÿ’ผ User Dashboard

User Dashboard

๐Ÿ›ก๏ธ Admin Dashboard

Admin Dashboard

๐Ÿ“‹ Poll List

Poll List

๐Ÿ—ณ๏ธ Vote Page

Vote Page

๐Ÿ“Š Results Page

Results Page

โž• Create Poll (Admin)

Create Poll


โœจ Features

๐Ÿ” Authentication

  • JWT Login
  • User Registration
  • Protected APIs (token-required routes)
  • Role-based access (Admin vs User)

๐Ÿ“‹ Poll Management

  • Create Poll
  • Edit Poll & Choices
  • Delete Poll
  • View All Polls

๐Ÿ—ณ๏ธ Voting

  • One vote per user (enforced at DB level)
  • Already-voted detection (upfront check)
  • Empty poll guard (Vote button disabled if no choices)
  • Live vote results

๐Ÿ›ก๏ธ Admin

  • Manage polls and choices
  • Add / update / delete options
  • View all poll results

๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend React, HTML, CSS, JavaScript
Backend Python, Django, Django REST Framework
Database MySQL
Authentication JWT (SimpleJWT)

๐Ÿ—๏ธ Architecture

React (Frontend)
      โ†“
REST API (Axios)
      โ†“
Django REST Framework
      โ†“
MySQL Database

๐Ÿš€ Getting Started

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • MySQL

1. Clone the Repository

git clone https://github.com/dineshkumarg5/Web-Based-Voting-System.git
cd Web-Based-Voting-System

2. Backend Setup

# Create and activate virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
source venv/bin/activate     # Mac/Linux

# Install dependencies
pip install django djangorestframework djangorestframework-simplejwt django-cors-headers mysqlclient

# Configure database
# Edit backend/backend/settings.py โ†’ DATABASES section with your MySQL credentials

# Run migrations
cd backend
python manage.py migrate

# Create admin superuser
python manage.py createsuperuser

# Start backend server
python manage.py runserver

Backend runs at: http://localhost:8000

3. Frontend Setup

cd frontend
npm install
npm start

Frontend runs at: http://localhost:3000


๐Ÿ“ Project Structure

Web-Based-Voting-System/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ backend/          # Django project settings
โ”‚   โ”‚   โ”œโ”€โ”€ settings.py
โ”‚   โ”‚   โ””โ”€โ”€ urls.py
โ”‚   โ”œโ”€โ”€ polls/            # Main app
โ”‚   โ”‚   โ”œโ”€โ”€ models.py     # Poll, Choice, Vote models
โ”‚   โ”‚   โ”œโ”€โ”€ views.py      # API views
โ”‚   โ”‚   โ”œโ”€โ”€ serializers.py
โ”‚   โ”‚   โ””โ”€โ”€ urls.py       # API routes
โ”‚   โ””โ”€โ”€ manage.py
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/
โ”‚       โ”‚   โ””โ”€โ”€ Navbar.js
โ”‚       โ”œโ”€โ”€ pages/
โ”‚       โ”‚   โ”œโ”€โ”€ Login.js
โ”‚       โ”‚   โ”œโ”€โ”€ Register.js
โ”‚       โ”‚   โ”œโ”€โ”€ AdminDashboard.js
โ”‚       โ”‚   โ”œโ”€โ”€ UserDashboard.js
โ”‚       โ”‚   โ”œโ”€โ”€ Polls.js
โ”‚       โ”‚   โ”œโ”€โ”€ Vote.js
โ”‚       โ”‚   โ”œโ”€โ”€ Results.js
โ”‚       โ”‚   โ”œโ”€โ”€ CreatePoll.js
โ”‚       โ”‚   โ”œโ”€โ”€ AddOptions.js
โ”‚       โ”‚   โ””โ”€โ”€ EditPoll.js
โ”‚       โ”œโ”€โ”€ services/
โ”‚       โ”‚   โ””โ”€โ”€ api.js    # Axios instance
โ”‚       โ””โ”€โ”€ App.js
โ”‚
โ”œโ”€โ”€ screenshots/
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md

๐Ÿ”Œ API Endpoints

Method Endpoint Description Access
POST /api/register/ Register new user Public
POST /api/login/ Login (returns JWT) Public
GET /api/polls/ List all polls Authenticated
POST /api/polls/create/ Create a poll Admin
PUT /api/polls/update/<id>/ Update poll Admin
DELETE /api/polls/delete/<id>/ Delete poll Admin
POST /api/polls/add-choice/ Add choice to poll Admin
PUT /api/choices/update/<id>/ Update a choice Admin
DELETE /api/choices/delete/<id>/ Delete a choice Admin
POST /api/polls/vote/ Cast a vote Authenticated
GET /api/polls/<id>/has-voted/ Check if voted Authenticated
GET /api/polls/results/<id>/ Get poll results Authenticated

๐Ÿ‘จโ€๐Ÿ’ป My Contribution

Designed and developed the complete full-stack application including frontend, backend, authentication, REST APIs, database design, and poll management system using React and Django REST Framework.


๐Ÿ”ฎ Future Enhancements

  • Email Verification on Registration
  • Election Scheduling (set open/close dates)
  • Real-Time Vote Count (WebSocket)
  • Charts & Analytics (bar/pie charts for results)
  • Candidate Images support
  • Poll Categories / Tags

๐Ÿ‘จโ€๐Ÿ’ป Developer

Dinesh Kumar G

GitHubย ย ย LinkedInย ย ย Email


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


If this project helped you, consider giving it a โญ on GitHub!

About

Online Voting System

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages