Frontend: React (Vite) + React Router
Backend: Express + MongoDB (via Mongoose)
- Users can create a poll with a custom number of options.
- A shareable one-time-use voting link is generated for each voter.
- Each voting link is valid only once.
- Poll results are always accessible from a standard results link.
- (Future) Poll creator can end/delete poll after creating an account.
npm init
npm install express mongoose cors dotenv uuidStructure:
backend/
├── models/
├── routes/
├── controllers/
├── middleware/
└── server.js
npm create vite@latest frontend -- --template react
cd frontend
npm install
npm install react-router-dom{
title: String,
pollId: String,
question: String,
options: [
{ text: String, votes: Number }
],
createdAt: Date,
expired: Boolean,
creatorId: String | null
}{
token: String,
pollId: String,
used: Boolean,
createdAt: Date
}| Method | Route | Description |
|---|---|---|
| POST | /api/polls | Create a new poll |
| GET | /api/polls/:pollId | Get poll data |
| POST | /api/polls/:pollId/generate-links | Generate one-time voting links |
| POST | /api/vote/:token | Submit a vote using a token |
| GET | /api/polls/:pollId/results | View poll results |
- When a poll is created, a set number of unique voting links are generated.
- Each link contains a token and is stored in the DB as unused.
- When a user votes via the link:
- Token is validated.
- Vote is counted.
- Token is marked as used.
| Route | Component | Description |
|---|---|---|
/ |
Home | Create a poll |
/poll-created/:id |
CreatedSuccess | View and share vote links |
/vote/:token |
VoteView | Vote using one-time link |
/poll/:pollId/results |
ResultsView | View poll results |
- Form: question + options
- POST
/api/polls - Redirect to
/poll-created/:id
- Call
/api/polls/:id/generate-links(e.g., 10 links) - Display or allow download/share of links
- Route:
/vote/:token - Fetch poll using token
- Submit vote
- Redirect to
/poll/:pollId/results
- Show real-time or refreshed results
- Generate
pollId - Save question and options
- Generate N tokens linked to pollId
- Save each with
used: false
- Validate token
- If unused, register vote and mark as used
- Return poll + vote counts
- Auth (JWT + bcrypt)
- Creator ID stored with poll
- Dashboard to:
- End poll
- Delete poll
- Set expiration
- Track votes
- Analytics dashboard