Web App
Electronic Vote
Electronic voting system built with Nuxt 4, allowing election administration, candidate management, and secure vote recording with JWT authentication
Cristian Paredes
in-development
2 min read
#nuxt #nuxt-ui #typescript #postgresql #drizzle-orm #tailwindcss #jwt #docker

Electronic Vote
Electronic voting system built with Nuxt 4, Nuxt UI 4, and PostgreSQL. Allows election administration, candidate management, and secure vote recording with JWT authentication.
Tech Stack
| Component | Technology |
|---|---|
| Framework | Nuxt 4 |
| UI Library | Nuxt UI 4 |
| Database | PostgreSQL |
| ORM | Drizzle ORM |
| Auth | nuxt-auth-utils (JWT) |
| Styles | TailwindCSS 4 |
| Icons | Lucide Icons |
Features
Authentication System
- User registration and login with email and password
- JWT sessions with 1 hour expiration
- Password change with current password verification
- Rate limiting on login (5 attempts per 15 minutes)
- Global authentication middleware protecting routes
- Role-Based Access Control (RBAC)
Roles and Permissions
| Role | Description |
|---|---|
| Voter | Can view active elections and vote |
| Advisor | + Dashboard access |
| Admin | + Election and candidate management |
| Dev | Full system access |
Voting System
- Active elections list with relevant information (dates, candidates)
- Election detail with candidate visualization
- Visual candidate selection before vote confirmation
- Confirmation modal to prevent accidental votes
- Double vote prevention per user/election
- Election status verification (only active accept votes)
- Results page with bar chart and vote percentages
Election and Candidate Management
- Full CRUD for elections (create, edit, delete)
- Full CRUD for candidates
- Candidate-election association
- Bulk candidate import from CSV files
- Date validation (end date must be after start date)
- Election statuses: Draft, Active, Finished
API REST
Authentication
- - New user registration
POST /api/auth/register
- - User login
POST /api/auth/login
- - User logout
POST /api/auth/logout
- - Get current user
GET /api/auth/me
- - Change password
POST /api/auth/change-password
Elections
- - List all elections
GET /api/elections
- - Create election
POST /api/elections
- - List active elections
GET /api/elections/active
- - Get election details
GET /api/elections/:id
- - Update election
PUT /api/elections/:id
- - Delete election
DELETE /api/elections/:id
- - Get election results
GET /api/elections/:id/results
Candidates
- - List all candidates
GET /api/candidates
- - Create candidate
POST /api/candidates
- - Get candidate details
GET /api/candidates/:id
- - Update candidate
PUT /api/candidates/:id
- - Delete candidate
DELETE /api/candidates/:id
- - Import candidates from CSV
POST /api/candidates/import
Votes
- - Register a vote
POST /api/votes
- - Get user vote status
GET /api/votes/status
Security
- Passwords: Hashing with bcrypt (10 salt rounds)
- Authentication: JWT tokens in HTTP-only sessions
- Rate Limiting: Brute force attack prevention on login
- SQL Injection: Prevention via Drizzle ORM (parameterized queries)
- RBAC: Role verification on each protected endpoint
- CSRF: Integrated Nuxt protection
Quick Start
git clone https://github.com/csparedes/electronic-vote.git
cd electronic-vote
pnpm install
docker compose up -d
pnpm db:generate
pnpm db:push
pnpm dev