Overview
Consensus can be deployed in several ways depending on your needs:- Local installation: Full control for development and testing
- Docker: Containerized deployment for production
- GitHub Codespaces: Zero-install browser-based environment
Prerequisites
- Local Installation
- Docker
- GitHub Codespaces
- Node.js 22 or later (download)
- Yarn package manager
- Git
Local installation
Install Node.js and Yarn
Download and install Node.js 22+ from nodejs.org.Then install Yarn globally:Verify your installation:
Install dependencies
Consensus uses several native dependencies that require compilation:
This installs packages including:
better-sqlite3(database)bcrypt(password hashing)fastify(web framework)ejs(templating)
Build the project
Compile TypeScript to JavaScript:This creates the
dist/ directory with compiled bundles.Seed the database (optional)
Populate with sample data for testing:This creates:
- 1 admin user (
admin/admin123) - 2 approved voters
- 3 active elections with candidates
Skip this step if you want to start with an empty system.
Development mode
For development with automatic reloading:Docker installation
Run Consensus in a containerized environment using the provided Dockerfile.Run the container
-d: Run in detached mode--name consensus: Container name-p 3000:3000: Map port 3000-v consensus-data:/app/data: Persist database
Docker Compose
For easier management, create adocker-compose.yml:
docker-compose.yml
GitHub Codespaces
Run Consensus entirely in your browser without any local installation.Create a Codespace
- Navigate to the GitHub repository
- Click the Code button
- Select the Codespaces tab
- Click Create codespace on master
The dev container will automatically install Node.js 22 and all dependencies. This may take a few minutes on first launch.
Wait for setup
The Codespace will automatically:
- Install Node.js and Yarn
- Run
yarn install - Configure the development environment
Start the server
Once setup completes, run:Codespaces will automatically forward port 3000 and prompt you to open the application.
Environment configuration
Customize Consensus behavior using environment variables:.env (example)
Database management
Reset database
To clear all data and start fresh:Backup database
The SQLite database is stored at:- Local:
{DATA_DIR}/consensus.db(default: OS-specific data directory) - Docker:
/app/data/consensus.db(persisted in named volume)
Troubleshooting
Native module compilation errors
Native module compilation errors
Some dependencies (bcrypt, better-sqlite3) require native compilation.On Linux/macOS:On Windows:
- Install Visual Studio Build Tools
- Or use Docker instead
Port 3000 already in use
Port 3000 already in use
Change the port via environment variable:Or modify
src/config.ts directly.Docker container exits immediately
Docker container exits immediately
Check logs for errors:Common issues:
- Missing data volume mount
- Insufficient permissions
- Port conflict
Codespace not forwarding ports
Codespace not forwarding ports
Manually configure port forwarding:
- Open the Ports panel
- Click Forward a Port
- Enter
3000 - Set visibility to Public if needed
What’s next?
Quick Start
Learn how to use Consensus from a voter’s perspective
Admin Guide
Learn how to manage elections and voters