Skip to content
/ VoteX Public

A comprehensive, secure, and real-time digital voting platform built with modern web technologies. This system enables organizations to conduct transparent and efficient elections with real-time results, comprehensive reporting, and robust security features.

Notifications You must be signed in to change notification settings

bipulhf/VoteX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—³οΈ Digital Voting System

A comprehensive, secure, and real-time digital voting platform built with modern web technologies. This system enables organizations to conduct transparent and efficient elections with real-time results, comprehensive reporting, and robust security features.

Home Page

🌟 Features

πŸ” Core Security Features

  • JWT-based Authentication: Secure token-based authentication system
  • Role-based Access Control: Admin, Election Commissioner, and Voter roles
  • Email Verification: Mandatory email verification for account activation
  • Secure Voting: One-vote-per-election validation with voter verification

πŸ›οΈ Election Management

  • Multiple Election Types: Support for various election formats
  • Candidate Management: Complete candidate registration with image uploads
  • Eligible Voter Management: Controlled voter registration and verification
  • Real-time Results: Live election results and vote counting
  • Election Scheduling: Automated election start/end times

πŸ’¬ Real-time Communication

  • Live Chat System: Real-time messaging during elections
  • Socket.io Integration: Instant updates and notifications
  • Election Monitoring: Live election status updates

πŸ“Š Reporting & Analytics

  • Comprehensive Reports: Detailed election reports and analytics
  • Export Functionality: Export voter lists and results
  • Audit Trail: Complete voting history and system logs

πŸ—οΈ System Architecture

System Diagram

Technology Stack

Backend

  • Runtime: Node.js with TypeScript
  • Framework: Express.js
  • Database: PostgreSQL with Prisma ORM
  • Authentication: JWT (JSON Web Tokens)
  • Real-time: Socket.io
  • Email: Nodemailer
  • Validation: Joi/Zod validators

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: Shadcn/ui
  • State Management: React Server Components + Actions
  • File Upload: UploadThing
  • Real-time: Socket.io client

πŸ“‹ Use Cases

Use Case Diagram

User Roles

πŸ”‘ System Administrator

  • Manage user accounts and roles
  • Configure system settings
  • Monitor system performance
  • Generate system-wide reports

πŸ‘¨β€πŸ’Ό Election Commissioner

  • Create and manage elections
  • Add/remove candidates
  • Manage eligible voters
  • Monitor election progress
  • Generate election reports

πŸ—³οΈ Voter

  • Register and verify account
  • Participate in eligible elections
  • View election results
  • Report issues or concerns

πŸ”„ System Flow

Flow Diagram

Election Lifecycle

  1. Election Creation: Commissioner creates election with candidates
  2. Voter Registration: Eligible voters are added to the election
  3. Voting Period: Voters cast their ballots securely
  4. Result Compilation: Real-time vote counting and result generation
  5. Report Generation: Comprehensive election reports

πŸ“Š Database Schema

Schema Diagram

Entity Relationship Diagram

Prisma ERD

Key Entities

  • Users: System users with roles and authentication
  • Elections: Election details, timing, and configuration
  • Candidates: Election candidates with associated data
  • Votes: Secure vote records with anonymization
  • Reports: Election reports and analytics
  • Chat Messages: Real-time communication logs

πŸš€ Getting Started

Prerequisites

  • Node.js (v20 or higher)
  • PostgreSQL (v16 or higher)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd voting_system
  2. Backend Setup

    cd backend
    npm install
    
    # Configure environment variables
    cp .env.example .env
    # Edit .env with your database and email configuration
    
    # Run database migrations
    npx prisma migrate dev
    
    # Seed the database
    npx prisma db seed
    
    # Start the backend server
    npm run dev
  3. Frontend Setup

    cd frontend
    npm install
    
    # Configure environment variables
    cp .env.local.example .env.local
    # Edit .env.local with your backend URL and API keys
    
    # Start the frontend application
    npm run dev
  4. Access the Application

Environment Variables

Backend (.env)

DATABASE_URL="postgresql://username:password@localhost:5432/voting_db"
JWT_SECRET="your-jwt-secret-key"
JWT_EXPIRES_IN="7d"
EMAIL_HOST="smtp.gmail.com"
EMAIL_PORT=587
EMAIL_USER="your-email@gmail.com"
EMAIL_PASS="your-app-password"
PORT=5000

Frontend (.env.local)

NEXT_PUBLIC_API_URL="http://localhost:5000"
NEXT_PUBLIC_SOCKET_URL="http://localhost:5000"
UPLOADTHING_SECRET="your-uploadthing-secret"
UPLOADTHING_APP_ID="your-uploadthing-app-id"

πŸ“± Application Screenshots

Dashboard Overview

The main dashboard provides a comprehensive overview of all elections, user management, and system statistics.

Election Management

Create, edit, and monitor elections with an intuitive interface for managing candidates and voters.

Real-time Voting

Secure voting interface with real-time updates and immediate result compilation.

Reports & Analytics

Detailed reporting system with export capabilities and comprehensive analytics.

πŸ”§ Development

Project Structure

voting_system/
β”œβ”€β”€ backend/          # Node.js/Express backend
β”œβ”€β”€ frontend/         # Next.js frontend
β”œβ”€β”€ resources/        # Documentation assets
└── README.md        # This file

For detailed file structure, see FILE_STRUCTURE.md

Available Scripts

Backend

npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run test         # Run tests
npm run db:migrate   # Run database migrations
npm run db:seed      # Seed database

Frontend

npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # Run TypeScript type checking

πŸ§ͺ Testing

Backend Testing

cd backend
npm run test
npm run test:watch
npm run test:coverage

Frontend Testing

cd frontend
npm run test
npm run test:e2e

πŸš€ Deployment

Production Deployment

  1. Backend Deployment

    cd backend
    npm run build
    npm run start
  2. Frontend Deployment

    cd frontend
    npm run build
    npm run start

πŸ›‘οΈ Security Features

  • SQL Injection Prevention: Parameterized queries and ORM protection
  • Rate Limiting: API rate limiting to prevent abuse
  • Input Validation: Comprehensive input sanitization and validation

πŸ“ˆ Performance

  • Optimized Database Queries: Efficient database operations with indexing
  • Caching Strategy: Redis caching for improved performance
  • CDN Integration: Static asset delivery optimization
  • Real-time Updates: Efficient WebSocket connections
  • Lazy Loading: Frontend component optimization

Built with ❀️ using modern web technologies for secure, transparent, and efficient digital voting.

About

A comprehensive, secure, and real-time digital voting platform built with modern web technologies. This system enables organizations to conduct transparent and efficient elections with real-time results, comprehensive reporting, and robust security features.

Resources

Stars

Watchers

Forks

Languages