How riya-joshi-401/ethereum-blockchain-based-electronic-voting-system works
Project Type and Purpose
• This is a full‐stack decentralized application (DApp) for electronic voting.
• Purpose: Allow users to authenticate via Aadhaar, view candidates, cast a vote through a web portal, and record that vote immutably on a blockchain (Ethereum via Ganache).
Main Architectural Components
a. Frontend (React.js SPA)
• ui/src/components (App.js, Auth.js, Voting.js, Loading.js)
• Redux state management (ui/src/redux.js)
• Service worker (ui/src/serviceWorkerRegistration.js, service-worker.js)
• Asset pipeline (ui/src/assets, public folder)
b. Web3 Layer
• Web3.js integration to communicate with smart contracts
• MetaMask as the injected provider for transaction signing
c. Smart Contracts & Blockchain
• Solidity contracts in contracts/ (Voting.sol, Migrations.sol implied)
• Truffle migrations (migrations/1_initial_migration.js, 2_deploy_voting.js)
• Local blockchain (Ganache) configured via truffle-config.js
d. External Services
• Aadhaar authentication API (out-of-band, not in code but called from Auth.js)
• MetaMask wallet extension
e. Development & Testing
• Truffle CLI for compile/migrate/test
• JavaScript tests in test/
• init.sh for environment setup
Relationships & Data Flow
1. User opens browser → React App served from ui/public/index.html
2. React App dispatches login action → calls Aadhaar API for OTP and Aadhar validation
3. On success, App requests MetaMask to connect accounts (Web3 provider)
4. User selects candidate → App invokes web3.eth.sendTransaction to Voting smart contract
5. MetaMask prompts user to sign and broadcast transaction to Ganache network
6. Ganache (Ethereum VM) executes contract, state (vote count) updates
7. Frontend polls or listens to contract events to display updated vote counts
Architectural Patterns & Principles
• Separation of concerns: UI components vs. blockchain integration vs. smart contracts
• Single-page App with Redux for predictable state
• Smart contract as the sole source of truth for votes (immutability)
• Infrastructure as code: truffle-config.js and migration scripts to automate deployment
Summary
1. User Interaction Layer (Browser + MetaMask)
2. Frontend Application (React SPA, Redux, Service Worker)
3. Blockchain Interaction Layer (Web3.js, MetaMask Provider)
4. Smart Contract Layer (Voting.sol, Migrations.sol) + Migration Scripts
5. Local Ethereum Network (Ganache)
6. External Identity Service (Aadhaar API)