A comprehensive, secure online voting platform with face recognition authentication, built with modern web technologies. VoteByte ensures election integrity through biometric verification, role-based access control, and real-time result tracking.
- Secure User Authentication - JWT-based authentication with role-based access control
- Election Management - Create, manage, and monitor elections with flexible scheduling
- Candidate Registration - Comprehensive candidate profiles with manifestos and symbols
- Real-time Voting - Secure voting interface with instant vote casting
- Live Results - Real-time election results with visual analytics and charts
- Voter Management - Automated voter registration and verification system
- Face Recognition Authentication - Biometric verification using face-api.js
- Face capture during user registration
- Face verification required before voting
- Prevents unauthorized voting attempts
- Multiple Authentication Types - Support for OTP, Aadhar, Face Recognition, and Student ID
- Role-Based Access Control (RBAC) - Separate interfaces for Users, Admins, and Super Admins
- Vote Integrity - One vote per user per election with face verification
- Complaint System - Users can submit complaints with resolution tracking
- Modern UI/UX - Built with React, Tailwind CSS, and Framer Motion
- Responsive Design - Works seamlessly on desktop, tablet, and mobile devices
- Real-time Feedback - Toast notifications and loading states
- Accessibility - User-friendly interface with clear navigation
- React 19 - Modern UI library
- Vite - Fast build tool and dev server
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- Zustand - State management
- Axios - HTTP client
- Recharts - Data visualization
- face-api.js - Face detection and recognition (via CDN)
- Node.js - Runtime environment
- Express.js 5 - Web framework
- Prisma - ORM for database management
- PostgreSQL - Relational database
- JWT - Authentication tokens
- bcrypt - Password hashing
- Cloudinary - Image storage and management
- Multer - File upload handling
- Nodemailer - Email service
- Node-cron - Scheduled tasks
- PostgreSQL - Primary database
- Prisma Migrations - Database schema management
VoteByte/
βββ Voting System/
β βββ backend/
β β βββ config/ # Configuration files (DB, Cloudinary, Multer)
β β βββ controllers/ # Request handlers
β β βββ middlewares/ # Auth and RBAC middlewares
β β βββ models/ # Prisma models
β β βββ routes/ # API route definitions
β β βββ services/ # Business logic
β β βββ utils/ # Helper functions
β β βββ face_storage/ # Face descriptor storage
β β βββ prisma/ # Database schema and migrations
β β βββ app.js # Express app entry point
β β
β βββ frontend/
β βββ src/
β β βββ components/ # Reusable React components
β β βββ pages/ # Page components
β β βββ routes/ # Route protection components
β β βββ services/ # API service functions
β β βββ store/ # Zustand state stores
β β βββ utils/ # Utility functions
β βββ public/ # Static assets
β βββ vite.config.js # Vite configuration
β
βββ LICENSE
βββ README.md
- Node.js (v18 or higher)
- PostgreSQL (v14 or higher)
- npm or yarn
- Cloudinary account (for image storage)
- Email service (for OTP/notifications)
-
Clone the repository
git clone <repository-url> cd VoteByte/Voting\ System
-
Backend Setup
cd backend npm install -
Frontend Setup
cd ../frontend npm install -
Database Setup
cd ../backend # Create a PostgreSQL database # Update DATABASE_URL in .env file npx prisma migrate dev npx prisma generate
-
Environment Variables
Create a
.envfile in thebackenddirectory:# Database DATABASE_URL="postgresql://user:password@localhost:5432/votebyte?schema=public" # JWT JWT_SECRET="your-super-secret-jwt-key" EXPRESS_SESSION_SECRET="your-session-secret" # Cloudinary CLOUDINARY_NAME="your-cloudinary-name" CLOUDINARY_API_KEY="your-api-key" CLOUDINARY_API_SECRET="your-api-secret" # Email (Nodemailer) EMAIL_HOST="smtp.gmail.com" EMAIL_PORT=587 EMAIL_USER="your-email@gmail.com" EMAIL_PASS="your-app-password" # Client URL CLIENT_URL="http://localhost:5173"
-
Create Face Storage Directory
# Windows PowerShell mkdir backend\face_storage # Linux/Mac mkdir backend/face_storage
-
Start Backend Server
cd backend npm run dev # Development mode with nodemon # or npm start # Production mode
Backend runs on
http://localhost:3000(or port specified in your config) -
Start Frontend Development Server
cd frontend npm run devFrontend runs on
http://localhost:5173 -
Access the Application
- Open your browser and navigate to
http://localhost:5173 - Register a new account or login with existing credentials
- Open your browser and navigate to
-
Registration
- Navigate to Sign Up page
- Fill in personal details (name, email, password, etc.)
- Capture your face using the camera (required for voting)
- Complete registration
-
Voting
- Login to your account
- Browse active elections
- Select a candidate
- Verify your face when prompted
- Cast your vote
- View confirmation
-
Viewing Results
- Navigate to Results section
- View election results with visual charts
- Check voter turnout and statistics
-
Election Management
- Create new elections with start/end times
- Set authentication type (Face Recognition, OTP, etc.)
- Manage election status
-
Candidate Management
- Approve/reject candidate registrations
- View candidate profiles and manifestos
-
Voter Management
- View registered voters
- Verify voter eligibility
- Monitor voting activity
- System Management
- Full access to all features
- Manage admins and users
- Resolve complaints
- System-wide analytics
VoteByte includes a comprehensive face recognition system for enhanced security:
-
During Registration
- User captures face photo using webcam
- System generates 128-dimensional face descriptor
- Face photo stored in Cloudinary
- Face descriptor stored locally on server
-
During Voting
- User must verify face before casting vote
- System compares live face with registered face
- Vote only allowed if face matches (threshold: 0.6)
- Prevents unauthorized voting
Face matching threshold can be adjusted in:
backend/services/faceRecognitionService.jsbackend/controllers/faceVerificationController.js
Recommended Values:
0.4- Very strict (high false rejection)0.6- Balanced (recommended)0.8- Lenient (higher false acceptance risk)
- HTTPS - Required for camera access in production
- Camera Permission - Browser must allow camera access
- Good Lighting - Ensures accurate face detection
For detailed face recognition documentation, see:
FACE_RECOGNITION_README.mdQUICK_START.md
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user
GET /api/elections- List all electionsGET /api/elections/:id- Get election detailsPOST /api/elections- Create election (Admin)PUT /api/elections/:id- Update election (Admin)DELETE /api/elections/:id- Delete election (Admin)
GET /api/candidates- List candidatesGET /api/candidates/:id- Get candidate detailsPOST /api/candidates- Register as candidatePUT /api/candidates/:id- Update candidate (Admin)POST /api/candidates/:id/approve- Approve candidate (Admin)
POST /api/votes/verify-face- Verify face for votingPOST /api/votes/face-verify/:electionId- Verify and mark as verifiedPOST /api/votes/cast- Cast voteGET /api/votes/voter-status/:electionId- Get voter status
GET /api/results- List all resultsGET /api/results/:electionId- Get election resultsPOST /api/results/generate/:electionId- Generate results (Admin)
GET /api/voters- List votersGET /api/voters/:electionId- Get voters for electionPOST /api/voters/register/:electionId- Register as voter
- User - User accounts with profile information
- Election - Election details and scheduling
- Candidate - Candidate profiles and registration
- Voter - Voter registration and verification status
- Vote - Individual vote records
- ElectionResult - Calculated election results
- Admin - Admin user management
- SuperAdmin - Super admin accounts
- Complaint - User complaints and resolutions
See backend/prisma/schema.prisma for complete schema definition.
- JWT Authentication - Secure token-based authentication
- Password Hashing - bcrypt with salt rounds
- Face Recognition - Biometric verification for voting
- Role-Based Access Control - Granular permissions
- HTTPS Support - Secure data transmission
- Input Validation - Server-side validation
- SQL Injection Prevention - Prisma ORM protection
- CORS Configuration - Controlled cross-origin access
- User registration with face capture
- User login and authentication
- Election creation (Admin)
- Candidate registration
- Face verification during voting
- Vote casting
- Results generation and viewing
- Complaint submission
- Admin panel access
Face Recognition Not Working
- Ensure camera permissions are granted
- Check HTTPS is enabled (required for camera)
- Verify face-api.js models are loading (check browser console)
- Ensure good lighting conditions
Database Connection Errors
- Verify DATABASE_URL in .env
- Check PostgreSQL is running
- Run
npx prisma migrate devto apply migrations
Cloudinary Upload Failures
- Verify Cloudinary credentials in .env
- Check API key permissions
- Ensure internet connectivity
CORS Errors
- Update CLIENT_URL in backend .env
- Check allowedOrigins in app.js
- Controllers - Handle HTTP requests/responses
- Services - Business logic and data processing
- Models - Database models (Prisma)
- Routes - API endpoint definitions
- Middlewares - Authentication and authorization
- Utils - Helper functions and utilities
- Update Prisma schema if database changes needed
- Run migrations:
npx prisma migrate dev - Create/update services for business logic
- Create/update controllers for API endpoints
- Add routes in appropriate route file
- Update frontend components/pages as needed
This project is licensed under the ISC License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
For support, email [your-email] or open an issue in the repository.
- face-api.js - Face detection and recognition library
- Prisma - Modern database toolkit
- React Team - Amazing UI library
- Express.js - Robust web framework
- All open-source contributors
Built with β€οΈ by Team VoteByte for secure and transparent elections