Prerequisites
Before you begin, ensure you have:- Node.js 22 or later installed (download here)
- Yarn package manager (
npm i yarn -g) - Basic familiarity with the command line
Installation and setup
Seed the database
Populate the database with sample elections, voters, and admin accounts:
This creates sample data including:
- 1 admin account (username:
admin, password:admin123) - 2 voter accounts (emails:
[email protected],[email protected], password:password123) - 3 active elections with candidates
Casting your first vote
Now that Consensus is running, let’s walk through the voter experience.Register or log in as a voter
Navigate to
http://localhost:3000 in your browser.You can either:- Register a new account: Click “Register” and fill out the form
- Use a seeded account: Click “Login” and use:
- Email:
[email protected] - Password:
password123
- Email:
New registrations require admin approval by default. Use seeded accounts for immediate access, or enable auto-approval in admin settings.
View available elections
After logging in, you’ll be redirected to the voter dashboard at
/dashboard.The dashboard shows:- Your voter registration status
- Elections available for voting
- Your recent voting history
Cast your vote
The voting interface adapts to the election type:For FPTP elections (First Past The Post):
- Select one candidate by clicking their radio button
- Click “Cast Vote”
- Drag and drop candidates to rank them in order of preference
- Your first choice goes at the top
- Click “Cast Vote” when your ranking is complete
Exploring admin features
To explore election management and administration:Log in as admin
Log out if you’re logged in as a voter, then navigate to
/admin.Use the seeded admin credentials:- Username:
admin - Password:
admin123
On first login, you’ll be prompted to change the default password.
Access the admin dashboard
The admin dashboard at
/admin/dashboard provides:- Overview of all elections and their statuses
- Voter registration management
- System statistics (total voters, active elections, votes cast)
- Quick actions for election management
Create a new election
Click “Create Election” and fill out:
- Name: e.g., “Department Representative Election”
- Type: Choose FPTP, STV, or AV
- Start/End Dates: Set the voting period
- Description: Election details for voters
- Name
- Party/affiliation
- Biography
Manage voters
In the Voters section, you can:
- Approve or reject pending registrations
- View all registered voters
- Manually create voter accounts
- Remove voters if needed
View election results
Once an election ends or is closed manually:
- Navigate to the election details page
- Click “Calculate Results”
- View winner(s) and detailed vote breakdowns
- FPTP: Simple majority
- STV: Quota-based proportional representation
- AV: Instant runoff with preference transfers
Development mode
For development with hot-reloading:Running tests
What’s next?
Installation Guide
Learn about Docker deployment and production setup
Architecture Overview
Understand the system design and patterns
Troubleshooting
Server won't start - port already in use
Server won't start - port already in use
Change the port in
src/config.ts or set the PORT environment variable:Database errors after updates
Database errors after updates
Reset and reseed the database:
Cannot vote - registration pending
Cannot vote - registration pending
Either:
- Wait for an admin to approve your registration
- Ask an admin to enable auto-approval in system settings
- Use a pre-seeded voter account from
yarn db:seed