This is a simple full-stack Voting Application built using the MERN stack. It includes user authentication, admin-controlled candidate management and creation, and secure voting functionality for registered users.
- Frontend: Next.js
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens)
- Sign up & Log in
- Update password
- View profile
- Vote for a favorite candidate (can vote only once)
- Log in using a secure
JWT_SECRET - Add, edit, and delete candidates
- Cannot vote
| Method | Endpoint | Description |
|---|---|---|
| POST | /signup | Register a new user |
| POST | /login | User login and token retrieval |
| GET | /profile | Get current user profile |
| PUT | /profile/password | Update user password |
| Method | Endpoint | Description |
|---|---|---|
| GET | /candidates | Get list of all candidates |
| POST | /vote/:candidateId | Vote for a candidate |
| GET | /vote/count | Get current vote counts |
| Method | Endpoint | Description |
|---|---|---|
| POST | /candidates | Add a new candidate |
| PUT | /candidate/:candidateId | Update candidate details |
| DELETE | /candidate/:candidateId | Delete a candidate |
The app has two main folders: /frontend → Next.js frontend /Backend → Node.js + Express backend
Make sure you have Node.js and MongoDB installed.
- Clone the repository:
git clone https://github.com/yourusername/voting-app-mern.git
cd voting-app-mern- Open two terminals, one for each folder.
cd frontend
npm install
npm run devcd Backend
npm install
npm run devPORT
MONGODB_LOCAL
JWT_SECRET
# Mongo Db Credentials
USERNAME
PASSWORD
MONGODB_URLApp is deployed on Vercel
- Each user can vote only once.
- Only Admin can Add, Update and Delete candidates.
- Admin cannot vote.
This project is open-source and available under the MIT License.
