Skip to content

Decentralized digital identity and voting system running on Raspberry Pi 5, powered by a custom lightweight blockchain.Open source project for secure, transparent, and accessible elections of the future.

Notifications You must be signed in to change notification settings

k0d1r/blockchain-vote-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Blockchain-Based Digital Identity & Voting System (Raspberry Pi 5)

Project Purpose

This project is a decentralized, blockchain-based digital identity and voting system designed to run on a Raspberry Pi 5. It features a self-hosted Ethereum node, smart contracts for digital identity and voting, and a modern, minimalist web interface. The system is ideal for small-scale elections, club/association voting, and digital identity management.


Table of Contents


Features

  • πŸ”’ Decentralized Digital Identity: Register and verify unique identities on-chain.
  • πŸ—³οΈ Secure Voting: One-person, one-vote, with transparent on-chain results.
  • ⚑ Runs on Raspberry Pi 5: Lightweight, energy-efficient, and portable.
  • πŸ–₯️ Modern Minimalist UI: Apple-style, responsive, and easy to use.
  • πŸ› οΈ Open Source & Customizable: All code is MIT licensed and easy to extend.
  • πŸ“Š Live Results: View real-time vote counts directly from the blockchain.

Architecture

graph TD;
  User["User<br/>(Web Browser)"] -- API Calls --> Backend["Backend<br/>(Node.js + Express)"]
  Backend -- Web3.js --> Geth["Ethereum Node<br/>(Geth, PoA)"]
  Geth -- Smart Contract Calls --> Contracts["Smart Contracts<br/>(Solidity)"]
  Backend -- REST API --> Frontend["Frontend<br/>(React)"]
Loading

Technologies

  • Blockchain: Ethereum (Geth, Proof of Authority)
  • Smart Contracts: Solidity
  • Backend: Node.js, Express, Web3.js
  • Frontend: React.js (Create React App)
  • Dev Tools: Truffle, Homebrew (for Mac), npm

Screenshots & Diagrams

1. Home Page

Home Page

2. Register Identity

Register Identity


Getting Started

1. Hardware & OS

  • Raspberry Pi 5 (or Mac/Linux PC)
  • Raspberry Pi OS Lite 64-bit (or compatible Linux/MacOS)

2. Install Dependencies

  • Node.js (>=18)
  • npm
  • Geth (Go Ethereum)
  • Truffle
  • Git

Quick Install for MacOS:

brew tap ethereum/ethereum
brew install ethereum
brew install node
npm install -g truffle

For Raspberry Pi:

sudo apt update && sudo apt upgrade -y
sudo apt install build-essential curl git npm -y
wget https://gethstore.blob.core.windows.net/builds/geth-linux-arm64-1.15.11-xxxx.tar.gz
# (Download and extract the latest ARM64 geth release)

3. Clone the Project

git clone <repo-url> blockchain-vote-pi
cd blockchain-vote-pi

Project Structure

blockchain-vote-pi/
β”‚
β”œβ”€β”€ contracts/              # Solidity smart contracts
β”‚   β”œβ”€β”€ DigitalIdentity.sol
β”‚   └── Voting.sol
β”‚
β”œβ”€β”€ migrations/             # Truffle migration scripts
β”‚   └── 1_deploy_contracts.js
β”‚
β”œβ”€β”€ backend/                # Node.js/Express backend API
β”‚   β”œβ”€β”€ package.json
β”‚   └── src/
β”‚       β”œβ”€β”€ index.js
β”‚       β”œβ”€β”€ web3.js
β”‚       └── contract.js
β”‚
β”œβ”€β”€ frontend/               # React frontend
β”‚   β”œβ”€β”€ package.json
β”‚   └── src/
β”‚       └── App.js
β”‚
β”œβ”€β”€ genesis.json            # Blockchain genesis file
β”œβ”€β”€ truffle-config.js       # Truffle config
β”œβ”€β”€ docs/                   # Documentation images/screenshots
└── README.md

Blockchain Node Setup

1. Genesis File

The genesis.json file defines a private PoA network.

2. Initialize and Start the Node

geth init genesis.json --datadir ./mychain
geth --datadir ./mychain --networkid 2025 --http --http.api personal,eth,net,web3,miner,clique --allow-insecure-unlock --mine

These commands start your own private blockchain node.


Smart Contracts

DigitalIdentity.sol

  • Users register with a name and national ID.
  • Each address can register only once.

Voting.sol

  • Deployed with a list of candidates.
  • Each address can vote only once.
  • Votes are stored transparently on-chain.

Compile & Deploy

npx truffle compile
npx truffle migrate --network development

After deployment, update contract addresses in backend/src/contract.js.


Backend (API)

  • REST API built with Express.js
  • Connects to blockchain via Web3.js
  • Main endpoints:
    • GET /health : API health check
    • POST /register : Register identity
    • POST /vote : Cast a vote
    • GET /results : Get voting results

Start the Backend

cd backend
npm install
node src/index.js

Frontend (UI)

  • Minimalist, Apple-style React interface
  • Register identity, vote, and view results
  • Communicates with backend API

Start the Frontend

cd frontend
npm install
npm start

Open your browser at http://localhost:3000


Usage

  1. Register Identity: Enter your name and national ID to register.
  2. Vote: Select a candidate and cast your vote.
  3. View Results: See live vote counts for each candidate.

All actions are recorded on the blockchain for transparency.


Development Notes

  • After deploying contracts, update their addresses and ABIs in backend/src/contract.js.
  • The Geth node and backend must run on the same machine or be accessible via HTTP API.
  • During development, frontend and backend run on separate ports; the frontend uses a proxy setting for API calls.
  • The codebase uses short, readable variable names and is designed for clarity.
  • PoA network and short block times are used for fast, low-resource operation on Raspberry Pi.

License

MIT

About

Decentralized digital identity and voting system running on Raspberry Pi 5, powered by a custom lightweight blockchain.Open source project for secure, transparent, and accessible elections of the future.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published