Skip to content

mark-judah/golang_vue_blockchain_voting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 

Repository files navigation

ChainVote Backend

The ChainVote backend is a distributed blockchain system designed for the election process in Kenya.

Technologies Used

  • 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.

Architecture Overview

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.

Administrator Panel

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.

User Access

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

Additional Details

  • 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

Setting Up the Backend

Clone the Project and Install Dependencies

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

Install EMQX (MQTT broker):


sudo apt-get install emqx

Configure MQTT Controller

Update the MQTT broker URL in the mqttController.go file:


// Update MQTT broker URL
opts := mqtt.NewClientOptions().AddBroker("tcp://YOUR_MQTT_BROKER_URL:PORT")

Linux Deployment

Instructions for Linux:

  1. Install EMQX and Redis as mentioned above.
  2. Clone the project, install Golang dependencies.
  3. Configure the MQTT controller with your broker URL.

Docker Setup

Building and Running Docker Image

  1. Open a terminal or command prompt.
  2. Navigate to the directory containing the Dockerfile:
  3. 
      cd /path/to/your/directory
      
  4. Run the Docker build command:
  5. 
      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

Testing on a Single PC

If testing on a single PC:

Edit the docker-compose.yml file and change the service name each time you run docker-compose up.

Frontend Interaction

The frontend client at ChainVote Dapp Client makes requests to this backend for system interactions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published