This Distributed Voting System is a real-time application built using Svelte for the frontend and Node.js, Express.js, Socket.IO, and NeDB on the backend. It allows users to vote on various polls, with the results updated in real-time via web sockets.
Ensure you have Node.js installed on your machine to run the server. Node.js can be downloaded from Node.js official website.
Clone the repository:
git clone https://github.com/MrJesseh/distributed-voting-system.git
Make sure you are in the root folder /distributed-voting-system/
Run the start script.
./start.sh
Then navigate to http://localhost:3000
.
GET /api/polls
: Retrieves all available polls.
POST /api/polls
: Submits a vote to a specific poll.
For the post request, the body should be as follows:
{
"id": 1,
"option": 1
}
Where id
(number) is the id of the poll you are posting a vote to, and option
(number) is the index of the option the person chose.