The ChainVote backend is a distributed blockchain system designed for the election process in Kenya.
- Message Broker: MQTT for high latency and low bandwidth distributed systems.
- Consensus Algorithm: Custom Raft Algorithm implementation.
- Session Management: Redis for state management.
- Deployment: Docker for containerized deployment.
The system utilizes MQTT as a message broker, chosen for its properties and compatibility with low network coverage. The Raft algorithm is employed for consensus, ensuring leader election and synchronization among nodes. Key points:
- Nodes elect a leader, syncing logs and managing state changes.
- Transaction pool holds 5 transactions before processing into blocks.
- Each node maintains an independent SQLITE database for transactions.
- Blockchain files undergo verification before being added to the blockchain.
- Each node has a HTTP server on port 8080 with an administrator panel for node management and system control.
- The leader node exposes an API at port 3500 for communication with the clients.When the leader dies, the new leader exposes its API.
The Vuejs-powered administrator panel offers functionalities for:
- Creating counties, constituencies, wards, polling stations, candidates, and voters.
- Tracking registered desktop clients, distributed nodes, and transactions.
- Viewing blockchain details, including tallying results and per-county breakdowns.
Access and operations within the administrator panel are role-based, restricted to authorized users based on their roles.The default user is [email protected] and the password is 123456. To access a nodes admin panel, go to http://localhost:8080
- Blockchain explorer for public viewing at http://localhost/block-explorer
- Each node has its own block explorer,voters access the block explorer on the current leader node
- Voters can view and verify their ballots in the blockchain using their transaction IDs received via SMS
To start, clone the project and install Golang dependencies:
git clone https://github.com/your-username/ChainVoteBackend.git
cd ChainVoteBackend
# Install Golang dependencies
go mod download
Install EMQX (MQTT broker):
sudo apt-get install emqx
Update the MQTT broker URL in the mqttController.go
file:
// Update MQTT broker URL
opts := mqtt.NewClientOptions().AddBroker("tcp://YOUR_MQTT_BROKER_URL:PORT")
Instructions for Linux:
- Install EMQX and Redis as mentioned above.
- Clone the project, install Golang dependencies.
- Configure the MQTT controller with your broker URL.
- Open a terminal or command prompt.
- Navigate to the directory containing the Dockerfile:
- Run the Docker build command:
cd /path/to/your/directory
docker build -t your_image_name:tag .
Replace your_image_name:tag
with your desired image name and tag.
Build and run the Docker image using Docker Compose:
# Build and run Docker image
docker-compose up
If testing on a single PC:
Edit the docker-compose.yml
file and change the service name each time you run docker-compose up
.
The frontend client at ChainVote Dapp Client makes requests to this backend for system interactions.