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.
- 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
- 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
- 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
- Frontend: https://electorportal.vercel.app
- Backend API: https://votingportal-fp5j.onrender.com
- 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
- Node.js - JavaScript runtime environment
- Express.js 5.1.0 - Web application framework
- MongoDB - NoSQL database
- Mongoose 8.17.0 - MongoDB object modeling
- JSON Web Tokens (JWT) - Secure authentication
- Bcrypt.js - Password hashing
- CORS - Cross-origin resource sharing
- Frontend: Vercel
- Backend: Render
- Database: MongoDB Atlas
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
- Node.js (v18 or higher)
- MongoDB (Atlas or local installation)
- Git
git clone https://github.com/MithanshuHedau/VotingPortal.git
cd VotingPortal
# 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
# Navigate to frontend directory (from root)
cd frontend
# Install dependencies
npm install
# Start the development server
npm run dev
Create a .env
file in the backend directory:
- Connect your GitHub repository to Vercel
- Set build command:
npm run build
- Set output directory:
dist
- Deploy automatically on push to main branch
- Connect your GitHub repository to Render
- Set build command:
npm install
- Set start command:
npm start
- Add environment variables in Render dashboard
- Deploy automatically on push to main branch
POST /user/signup # Register new user
POST /user/login # User login
GET /user/profile # Get user profile
PUT /user/profile/password # Update password
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
- Register and login to the system
- View available candidates
- Cast one vote per election
- View real-time results
- Manage profile and change password
- All voter permissions except voting
- Add, edit, and delete candidates
- Monitor vote counts and analytics
- Access comprehensive admin dashboard
- Password Security: Bcrypt hashing with salt rounds
- JWT Authentication: Secure token-based authentication
- Input Validation: Server-side validation for all inputs
- CORS Configuration: Restricted cross-origin requests
- Role-based Access: Protected admin routes
- One Vote Policy: Database-level vote tracking
- 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
- 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
- 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
- Fork the repository
- Create a 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
This project is licensed under the ISC License - see the LICENSE file for details.
- User data is encrypted and securely stored
- Voting records are anonymized
- Personal information is protected according to privacy standards
- Regular security audits and updates
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