CoolFace
Apppublic

sharonashik005/votechain-ai

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

VoteChainAI

Civic Infrastructure for the AI Era

A production-grade, blockchain-backed voting platform with AI-assisted integrity monitoring.


๐Ÿ—๏ธ Architecture

VoteChainAI/
โ”‚
โ”œโ”€โ”€ frontend/               # React + TypeScript + Vite
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ api/            # API client
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # NavBar, etc.
โ”‚   โ”‚   โ”œโ”€โ”€ context/        # Auth context
โ”‚   โ”‚   โ”œโ”€โ”€ pages/          # Landing, Login, Register, Dashboard, Admin, Verify
โ”‚   โ”‚   โ””โ”€โ”€ App.tsx         # Router
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ backend/                # FastAPI + SQLite
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ api/            # Auth, Elections, Votes, Audit endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ models/         # SQLAlchemy models
โ”‚   โ”‚   โ”œโ”€โ”€ schemas/        # Pydantic schemas
โ”‚   โ”‚   โ”œโ”€โ”€ services/       # Blockchain, Auth services
โ”‚   โ”‚   โ””โ”€โ”€ main.py         # App entry
โ”‚   โ””โ”€โ”€ requirements.txt
โ”‚
โ””โ”€โ”€ blockchain/             # Solidity + Hardhat
    โ”œโ”€โ”€ contracts/
    โ”‚   โ””โ”€โ”€ VoteLedger.sol
    โ”œโ”€โ”€ scripts/
    โ”‚   โ””โ”€โ”€ deploy.js
    โ””โ”€โ”€ test/

๐Ÿ” Security

FeatureImplementation
Passwordsbcrypt (12 rounds)
AuthenticationJWT (HS256, 24h expiry)
Vote PrivacyOnly SHA-256 hashes stored
ImmutabilityBlockchain-backed ledger
One VoteDB constraint + smart contract
RolesAdmin, Voter, Auditor

๐Ÿš€ Quick Start

1. Backend (FastAPI + SQLite)

bash
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reload --port 8000

API Docs: http://localhost:8000/docs

2. Frontend (React + Vite)

bash
cd frontend
npm install
npm run dev

App: http://localhost:5173

3. Blockchain (Optional)

bash
cd blockchain
npm install
npx hardhat node          # Terminal 1
npm run deploy            # Terminal 2

๐Ÿ“ฑ Pages

PageRouteAuthDescription
Landing/NoHero, features, CTA
Login/loginNoJWT login
Register/registerNoCreate account
Dashboard/dashboardVoterVote in elections
Admin/adminAdminManage elections
Verify/verifyNoVerify vote hash

๐Ÿ“ก API Endpoints

Authentication

POST /api/v1/auth/register  - Register user
POST /api/v1/auth/login     - Get JWT token
GET  /api/v1/auth/me        - Get profile

Elections

POST /api/v1/elections/create      - Create (ADMIN)
GET  /api/v1/elections/active      - List active
POST /api/v1/elections/{id}/close  - Close (ADMIN)

Voting

POST /api/v1/vote/cast          - Cast vote
GET  /api/v1/vote/verify/{hash} - Verify vote

๐Ÿงช Testing Flow

  1. 1.Open http://localhost:5173
  2. 2.Register as admin role
  3. 3.Login โ†’ redirected to Admin Panel
  4. 4.Create election + activate it
  5. 5.Register another user as voter
  6. 6.Login as voter โ†’ Dashboard
  7. 7.Cast a vote โ†’ get receipt with hash
  8. 8.Go to Verify โ†’ enter hash โ†’ see confirmation

๐Ÿ“ธ Project Demo

Below is a walkthrough of the application functionality:

1. Authentication & Onboarding

[image] [image] [image] [image]

2. Face Liveness & Verification

[image] [image] [image] [image] [image]

3. Voting Process

[image] [image] [image] [image] [image]

4. Verification & Admin

[image] [image] [image] [image] [image]


๐Ÿ“ License

MIT License