<<<<<<< HEAD
This is a robust and scalable online voting system built with the MERN (MongoDB, Express.js, React.js, Node.js) stack. It provides a secure platform for users to register, log in, and cast their votes for candidates, with an administrative panel for managing users and candidates. The system ensures data integrity, secure authentication, and real-time updates for vote counts.
- Secure User Authentication: Implemented JWT (JSON Web Token) based authentication for secure user registration, login, and session management, with password hashing using
bcrypt. - Role-Based Access Control: Differentiated user roles (
voterandadmin), ensuring only administrators can add or manage candidates. - Candidate Management: Admin users can add new candidates, including their details, party, and image (uploaded to Cloudinary).
- Voting Mechanism: Registered voters can cast their vote for a chosen candidate once, with logic to prevent multiple votes from the same user.
- Real-time Vote Tracking: Dynamically updates vote counts for candidates.
- User Profile Management: Users can view and update their profile details, including password changes.
- RESTful API Design: Comprehensive and well-structured RESTful APIs for all backend operations.
- Cloud Image Storage: Integrates Cloudinary for secure and efficient storage of candidate images.
- Responsive UI: (Assumed, given MERN stack) A user-friendly and responsive frontend built with React.js.
- React.js
- React Router (Likely for navigation)
- Axios (For API requests)
- Node.js
- Express.js (Web framework)
- MongoDB (NoSQL database)
- Mongoose (ODM for MongoDB)
- jsonwebtoken (For JWT authentication)
- bcrypt (For password hashing)
- dotenv (For environment variable management)
- cors (For Cross-Origin Resource Sharing)
- body-parser (For parsing incoming request bodies)
- express-fileupload (For handling file uploads)
- cloudinary (For cloud image storage)
- nodemon (For automatic server restarts during development)
Before running this project, ensure you have the following installed:
- Node.js (LTS version recommended)
- npm or yarn
- MongoDB (Community Server or a MongoDB Atlas account)
Follow these steps to get the project up and running on your local machine.
git clone https://github.com/uvraviz007/OneVote.git
cd OneVoteNavigate to the backend directory (or wherever your server.js and package.json are located).
cd backend # or the relevant directoryInstall Dependencies
npm install # or yarn installConfigure Environment Variables
Create a .env file in the backend directory and add the following variables:
PORT=5000
MONGO_URI='mongodb+srv://<username>:<password>@cluster.r6mhes6.mongodb.net/<database-name>?retryWrites=true&w=majority'
JWT_SECRET='your_jwt_secret_key'
CLOUD_NAME='your_cloudinary_cloud_name'
CLOUD_API_KEY='your_cloudinary_api_key'
CLOUD_API_SECRET_KEY='your_cloudinary_api_secret_key'Replace <username>, <password>, and <database-name> with your MongoDB Atlas credentials. Generate a strong secret key for JWT_SECRET. Obtain your Cloudinary credentials from your Cloudinary Dashboard.
Run the Backend Server
npm start # or yarn startNavigate to your frontend directory.
cd ../frontend # Adjust path if your frontend is in a different directoryInstall Dependencies
npm install # or yarn installConfigure Environment Variables
Create a .env file in the frontend root and add:
REACT_APP_API_BASE_URL=http://localhost:5000Run the Frontend Application
npm start # or yarn startOpen your browser and go to http://localhost:3000.
- Register as a new user (default role is voter).
- Login using your credentials.
- Admin access: manually update a user's role to
adminin MongoDB or create a special route. - Admin can add candidates with image uploads.
- Voters can vote once per candidate.
- Results show updated vote counts in real-time.
POST /user/signup: Register a new user.POST /user/login: Log in and receive a JWT.GET /user/profile: Get profile (JWT required).PUT /user/profile/password: Change password (JWT required).
POST /candidate: Add a new candidate (admin only).POST /candidate/vote/:candidateId: Cast a vote (voter only).GET /candidate: List of candidates (basic info).GET /candidate/allcandidates: Full candidate details.
Contributions are welcome!
- Fork the repo
- Create a branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m "Add new feature" - Push:
git push origin feature/your-feature - Open a pull request
This project is licensed under the ISC License.
=======
One Vote is a robust and scalable online voting system built using the MERN stack (MongoDB, Express.js, React.js, Node.js). It provides a secure platform for voters to register, log in, and cast votes for candidates. The system also features a powerful admin panel to manage candidate details. The platform ensures data integrity, secure authentication, and real-time vote tracking.
- π Secure User Authentication: JWT-based authentication with bcrypt password hashing.
- π Role-Based Access Control: Separate roles for voters and admins.
- π§βπΌ Candidate Management: Admins can add, edit, or delete candidates with profile images and manifesto links.
- π³οΈ Voting Mechanism: Users can vote only once; vote updates are tracked in real-time.
- π Live Vote Count: Displays live vote statistics dynamically.
- π€ User Profile Management: Update personal details and password.
- π RESTful API Design: Organized and scalable backend APIs.
- βοΈ Cloud Image Storage: Candidate profile images are uploaded using Cloudinary.
- π± Responsive UI: Fully responsive React frontend for all devices.
- React.js
- React Router
- Axios
- Node.js
- Express.js
- MongoDB with Mongoose
- JWT (
jsonwebtoken) - Bcrypt
- Dotenv
- CORS
- Body-parser
- Express-fileupload
- Cloudinary
- Nodemon
π‘ Make sure these images are inside a folder named
screenshots/at the root of your project.
- Node.js (LTS recommended)
- npm or yarn
- MongoDB (local or Atlas)
- Cloudinary account
git clone https://github.com/uvraviz007/OneVote.git
cd OneVote
>>>>>>> db3441aa4d78733ae807129cbd963ca807defd0c


