Skip to content

πŸ—³οΈ Voting Portal - Digital Democracy Made Simple A secure, modern online voting platform built with the MERN stack that enables citizens to participate in elections digitally. Features Aadhar-based authentication, one-time voting per user, real-time result tracking, and comprehensive admin controls for candidate management.

Notifications You must be signed in to change notification settings

MithanshuHedau/VotingPortal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

πŸ—³οΈ Voting Portal

A modern, secure, and user-friendly online voting platform built with the MERN stack. This application provides a complete digital voting experience with separate interfaces for voters and administrators.

Voting Portal React Node.js MongoDB

🌟 Features

For Voters

  • Secure Registration: Register with Aadhar card verification
  • One-Time Voting: Each user can vote only once per election
  • Real-time Results: View live voting results and statistics
  • Profile Management: Update personal information and change passwords
  • Responsive Design: Works seamlessly on desktop and mobile devices

For Administrators

  • Candidate Management: Add, edit, and delete candidates
  • Vote Monitoring: Real-time vote tracking and analytics
  • User Management: Monitor registered users and voting status
  • Results Dashboard: Comprehensive voting results with visual representations

Security Features

  • JWT Authentication: Secure token-based authentication
  • Password Encryption: Bcrypt hashing for password security
  • CORS Protection: Configured cross-origin resource sharing
  • Input Validation: Comprehensive form validation on both client and server
  • Role-based Access: Separate permissions for voters and administrators

πŸš€ Live Demo

πŸ› οΈ Tech Stack

Frontend

  • React 19.1.0 - Modern UI library with latest features
  • React Router DOM 7.7.1 - Client-side routing
  • React Icons 5.5.0 - Beautiful icons
  • Vite 7.0.4 - Fast build tool and development server
  • CSS3 - Custom styling with responsive design

Backend

  • Node.js - JavaScript runtime environment
  • Express.js 5.1.0 - Web application framework
  • MongoDB - NoSQL database
  • Mongoose 8.17.0 - MongoDB object modeling

Security & Authentication

  • JSON Web Tokens (JWT) - Secure authentication
  • Bcrypt.js - Password hashing
  • CORS - Cross-origin resource sharing

Deployment

  • Frontend: Vercel
  • Backend: Render
  • Database: MongoDB Atlas

πŸ“ Project Structure

VotingPortal/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx              # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx             # User login
β”‚   β”‚   β”‚   β”œβ”€β”€ Signup.jsx            # User registration
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx         # Voter dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminPanel.jsx        # Admin management panel
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.jsx           # User profile management
β”‚   β”‚   β”‚   β”œβ”€β”€ About.jsx             # About page
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx            # Navigation component
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.jsx            # Footer component
β”‚   β”‚   β”‚   └── ProtectedRoute.jsx    # Route protection
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx       # Authentication context
β”‚   β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   β”‚   β”œβ”€β”€ global.css            # Global styles
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.css              # Authentication styles
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.css         # Dashboard styles
β”‚   β”‚   β”‚   β”œβ”€β”€ admin.css             # Admin panel styles
β”‚   β”‚   β”‚   └── navbar.css            # Navigation styles
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── api.js                # API utility functions
β”‚   β”‚   β”œβ”€β”€ App.jsx                   # Main app component
β”‚   β”‚   └── main.jsx                  # App entry point
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ user.js                   # User schema
β”‚   β”‚   └── candidate.js              # Candidate schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ userRoutes.js             # User-related routes
β”‚   β”‚   └── candidateRoutes.js        # Candidate-related routes
β”‚   β”œβ”€β”€ connection/
β”‚   β”‚   └── db.js                     # Database connection
β”‚   β”œβ”€β”€ jwt.js                        # JWT utilities
β”‚   β”œβ”€β”€ server.js                     # Express server
β”‚   └── package.json
└── README.md

πŸ”§ Installation & Setup

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (Atlas or local installation)
  • Git

1. Clone the Repository

git clone https://github.com/MithanshuHedau/VotingPortal.git
cd VotingPortal

2. Backend Setup

# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Create .env file and add your environment variables
echo "MONGODB_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=3000" > .env

# Start the backend server
npm start

3. Frontend Setup

# Navigate to frontend directory (from root)
cd frontend

# Install dependencies
npm install

# Start the development server
npm run dev

4. Environment Variables

Create a .env file in the backend directory:

πŸš€ Deployment

Frontend (Vercel)

  1. Connect your GitHub repository to Vercel
  2. Set build command: npm run build
  3. Set output directory: dist
  4. Deploy automatically on push to main branch

Backend (Render)

  1. Connect your GitHub repository to Render
  2. Set build command: npm install
  3. Set start command: npm start
  4. Add environment variables in Render dashboard
  5. Deploy automatically on push to main branch

πŸ“– API Documentation

Authentication Endpoints

POST /user/signup          # Register new user
POST /user/login           # User login
GET  /user/profile         # Get user profile
PUT  /user/profile/password # Update password

Candidate Endpoints

GET    /user/candidates              # Get all candidates (voter)
POST   /candidate                    # Add candidate (admin only)
PUT    /candidate/:id               # Update candidate (admin only)
DELETE /candidate/:id               # Delete candidate (admin only)
POST   /candidate/vote/:id          # Vote for candidate
GET    /candidate/vote/count        # Get vote counts

πŸ‘₯ User Roles

Voter

  • Register and login to the system
  • View available candidates
  • Cast one vote per election
  • View real-time results
  • Manage profile and change password

Administrator

  • All voter permissions except voting
  • Add, edit, and delete candidates
  • Monitor vote counts and analytics
  • Access comprehensive admin dashboard

πŸ” Security Measures

  1. Password Security: Bcrypt hashing with salt rounds
  2. JWT Authentication: Secure token-based authentication
  3. Input Validation: Server-side validation for all inputs
  4. CORS Configuration: Restricted cross-origin requests
  5. Role-based Access: Protected admin routes
  6. One Vote Policy: Database-level vote tracking

🎨 UI/UX Features

  • Modern Design: Clean and intuitive interface
  • Responsive Layout: Mobile-friendly design
  • Real-time Updates: Live vote counting and results
  • Loading States: User-friendly loading indicators
  • Error Handling: Comprehensive error messages
  • Success Feedback: Clear confirmation messages

πŸ§ͺ Testing

Manual Testing Checklist

  • User registration with validation
  • User login and authentication
  • Protected route access
  • Candidate voting process
  • Admin candidate management
  • Real-time vote counting
  • Profile management
  • Password updates
  • Responsive design on mobile

πŸ”„ Version History

  • v1.0.0 - Initial release with core voting functionality
  • v1.1.0 - Added admin panel and candidate management
  • v1.2.0 - Improved UI/UX and mobile responsiveness
  • v1.3.0 - Enhanced security and error handling

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.

πŸ›‘οΈ Data Privacy

  • User data is encrypted and securely stored
  • Voting records are anonymized
  • Personal information is protected according to privacy standards
  • Regular security audits and updates

πŸ“ž Support & Contact

For any questions, issues, or suggestions, please feel free to reach out:

Email: hedaumithanshu@gmail.com


Built with ❀️ by Mithanshu Hedau

Making democracy accessible through technology

About

πŸ—³οΈ Voting Portal - Digital Democracy Made Simple A secure, modern online voting platform built with the MERN stack that enables citizens to participate in elections digitally. Features Aadhar-based authentication, one-time voting per user, real-time result tracking, and comprehensive admin controls for candidate management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published