Skip to content

Latest commit

ย 

History

History
508 lines (405 loc) ยท 15.2 KB

File metadata and controls

508 lines (405 loc) ยท 15.2 KB

BlockProof โ€“ Google Certificate Verification System Using Blockchain & AI

BlockProof Banner License Blockchain AI

๐ŸŽฏ Project-Overview

BlockProof is a revolutionary, hackathon-ready certificate verification system that combines blockchain technology with artificial intelligence to ensure certificate authenticity and detect tampering in real-time.

The Problem ๐Ÿ”ด

  • Fake certificates are flooding the market - employers can't verify authenticity
  • Manual verification is time-consuming and unreliable
  • No permanent audit trail - once a certificate is issued, there's no immutable record
  • Tampering is easy - PDFs and images can be edited without detection
  • Trust issues - no way to verify issuer legitimacy

The Solution ๐ŸŸข

BlockProof uses a two-layer verification system:

  1. Blockchain Layer ๐Ÿ”—

    • SHA-256 hash of certificate data stored on Polygon Mumbai testnet
    • Immutable proof of issuance
    • Permanent audit trail
    • Smart contract manages issuance, verification, and revocation
  2. AI Layer ๐Ÿค–

    • Google Gemini API analyzes certificate for tampering
    • Detects: altered text, fake logos, formatting mismatches, image quality issues
    • Confidence scoring (0-100)
    • Instant analysis without manual review

Result: A certificate is VERIFIED only when:

  • โœ… Hash matches blockchain record (no tampering)
  • โœ… AI confidence is high (authentic appearance)
  • โœ… Certificate is not revoked
  • โœ… Issuer is authorized

๐Ÿš€ Quick Start (2 Minutes)

For DEMO MODE (No blockchain or API keys needed!)

# 1. Clone and setup
git clone <your-repo>
cd BlockProof-GoogleCertificateVerificationSystem

# 2. Install dependencies
cd backend && npm install
cd ../frontend && npm install && cd ..

# 3. Start both servers (from root or in separate terminals)
# Terminal 1 - Backend
cd backend && npm run dev

# Terminal 2 - Frontend
cd frontend && npm run dev

# 4. Open browser
# Frontend: http://localhost:5173
# API: http://localhost:5000/api/health

That's it! Everything works in simulation mode - perfect for demos and presentations.

For PRODUCTION (With real blockchain & AI)

See DEPLOYMENT.md for complete setup guide.


๐Ÿ“‹ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      BlockProof System                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   FRONTEND (React)  โ”‚                 โ”‚  BACKEND (Node.js)  โ”‚
โ”‚                     โ”‚                 โ”‚                     โ”‚
โ”‚  โ€ข Home             โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  โ€ข Express Server   โ”‚
โ”‚  โ€ข Issue Cert       โ”‚  HTTP Request   โ”‚  โ€ข Certificate API  โ”‚
โ”‚  โ€ข Verify Cert      โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚  โ€ข File Upload      โ”‚
โ”‚  โ€ข View Results     โ”‚   JSON Response โ”‚  โ€ข Hash Generation  โ”‚
โ”‚  โ€ข About            โ”‚                 โ”‚                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                 โ”‚
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚                  โ”‚                  โ”‚
                              โ–ผ                  โ–ผ                  โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  BLOCKCHAIN      โ”‚ โ”‚   AI/GEMINI      โ”‚ โ”‚    STORAGE     โ”‚
                    โ”‚  (Polygon/Eth)   โ”‚ โ”‚   (Google)       โ”‚ โ”‚  (Blockchain)  โ”‚
                    โ”‚                  โ”‚ โ”‚                  โ”‚ โ”‚                โ”‚
                    โ”‚  โ€ข Hash Store    โ”‚ โ”‚  โ€ข Image Analysisโ”‚ โ”‚ โ€ข Immutable    โ”‚
                    โ”‚  โ€ข Verification  โ”‚ โ”‚  โ€ข Tampering     โ”‚ โ”‚ โ€ข Audit Trail  โ”‚
                    โ”‚  โ€ข Revocation    โ”‚ โ”‚  โ€ข Confidence    โ”‚ โ”‚ โ€ข Permanent    โ”‚
                    โ”‚  โ€ข Smart Contractโ”‚ โ”‚  โ€ข Scoring       โ”‚ โ”‚                โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Layer Technology Purpose
Frontend React 18 + Vite User interface
Styling Tailwind CSS Google-like UI design
Backend Node.js + Express REST API server
Blockchain Solidity + Hardhat Smart contracts
Blockchain RPC Polygon Mumbai Testnet (free, fast)
Blockchain Lib Ethers.js v6 Contract interaction
AI Google Gemini API Certificate analysis
Hashing SHA-256 (Node crypto) Certificate fingerprinting
File Upload Multer Image/PDF handling

๐ŸŽฎ User Workflows

1. Issue a Certificate (Admin)

Admin Portal
    โ†“
Enter: Recipient Name, Issuer, Course, Date
    โ†“
System generates unique Certificate ID
    โ†“
Create SHA-256 hash of certificate data
    โ†“
Store hash on Polygon blockchain
    โ†“
Return: Certificate ID (for verification)
    โ†“
Success! Certificate is now on blockchain

Endpoint: POST /api/certificates/issue

2. Verify a Certificate (User/Employer)

User enters Certificate ID
    โ†“
Check if exists on blockchain
    โ†“
If yes โ†’ Query blockchain for hash
    โ†“
Check if certificate is revoked
    โ†“
(Optional) Verify data matches blockchain hash
    โ†“
(Optional) Upload certificate image for AI analysis
    โ†“
Gemini API analyzes for tampering
    โ†“
Returns confidence score & findings
    โ†“
System determines: VERIFIED / SUSPICIOUS / FAKE
    โ†“
Display results with evidence

Endpoint: POST /api/certificates/verify

3. Analyze Certificate Image (Optional)

User uploads certificate PDF/image
    โ†“
System sends to Gemini AI
    โ†“
AI analyzes:
  โ€ข Logo authenticity
  โ€ข Text quality & consistency
  โ€ข Formatting & layout
  โ€ข Image manipulation signs
    โ†“
Returns: Tampering probability & detailed findings
    โ†“
User sees visual report

Endpoint: POST /api/certificates/analyze-image


๐Ÿ“ Project Structure

BlockProof/
โ”œโ”€โ”€ backend/                          # Node.js + Express server
โ”‚   โ”œโ”€โ”€ contracts/
โ”‚   โ”‚   โ””โ”€โ”€ CertificateRegistry.sol  # Smart contract (Solidity)
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ””โ”€โ”€ certificateController.js # Business logic
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ””โ”€โ”€ certificate.js           # API endpoints
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ blockchain.js            # Blockchain interactions
โ”‚   โ”‚   โ”œโ”€โ”€ gemini.js                # AI verification
โ”‚   โ”‚   โ””โ”€โ”€ hash.js                  # SHA-256 hashing
โ”‚   โ”œโ”€โ”€ uploads/                     # Uploaded files
โ”‚   โ”œโ”€โ”€ server.js                    # Express app
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ .env.example                 # Environment template
โ”‚
โ”œโ”€โ”€ frontend/                         # React + Vite
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Header.jsx
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ Footer.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Home.jsx             # Landing page
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Admin.jsx            # Issue certificates
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Verify.jsx           # Verify certificates
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Result.jsx           # Verification results
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ About.jsx            # About page
โ”‚   โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.js               # API client
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”‚   โ”œโ”€โ”€ main.jsx
โ”‚   โ”‚   โ””โ”€โ”€ index.css
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ”œโ”€โ”€ README.md                         # This file
โ”œโ”€โ”€ QUICKSTART.md                     # Quick setup guide
โ”œโ”€โ”€ DEPLOYMENT.md                     # Production deployment
โ””โ”€โ”€ LICENSE

๐Ÿ”‘ API Endpoints

Certificate Management

Issue Certificate

POST /api/certificates/issue
Content-Type: application/json

{
  "recipientName": "John Doe",
  "issuerName": "Google",
  "course": "Cloud Architecture Essentials",
  "issueDate": "2024-01-15",
  "additionalInfo": "With distinction"
}

Response (201 Created):
{
  "success": true,
  "message": "Certificate issued successfully",
  "certificate": {
    "certificateId": "CERT-1704067200000-ABC123D4",
    "recipientName": "John Doe",
    "issuerName": "Google",
    "hash": "3a7f8c2d9e1b4a6f..."
  },
  "blockchain": {
    "success": true,
    "transactionHash": "0x..."
  }
}

Verify Certificate

POST /api/certificates/verify
Content-Type: application/json

{
  "certificateId": "CERT-1704067200000-ABC123D4",
  "certificateData": {
    "recipientName": "John Doe",
    "issuerName": "Google",
    "course": "Cloud Architecture Essentials"
  }
}

Response (200 OK):
{
  "success": true,
  "verified": true,
  "verdict": "VERIFIED",
  "confidence": 95
}

Get Certificate

GET /api/certificates/{certificateId}

Response (200 OK):
{
  "success": true,
  "certificateId": "CERT-1704067200000-ABC123D4",
  "hash": "3a7f8c2d9e1b4a6f...",
  "issuer": "Google",
  "recipient": "John Doe",
  "revoked": false
}

Why BlockProof ?

  1. Solves Real Problem

    • Certificate fraud is a $100M+ market problem
    • Employers need instant verification
    • No existing solution combines blockchain + AI
  2. Complete Solution

    • Not just theory - fully functional end-to-end
    • Works in demo mode (no keys needed!)
    • Professional UI ready for investor demo
  3. Impressive Tech Stack

    • Blockchain: Polygon, Solidity, Smart Contracts
    • AI: Google Gemini API for real analysis
    • Full-stack: React, Node.js, Express
    • Shows versatility across 4+ domains
  4. Scalable Architecture

    • Can handle millions of certificates
    • Decentralized storage (blockchain)
    • AI analysis runs instantly
    • Low cost (free testnet, cheap gas)
  5. Beginner-Friendly

    • Works with just npm install && npm run dev
    • Simulation mode for demos (no setup needed)
    • Clear comments in every file
    • Comprehensive documentation
  6. Production Ready

    • Can go live immediately
    • All security best practices
    • Error handling throughout
    • Professional code quality

๐Ÿ”’ Security Features

  • โœ… SHA-256 hashing (cryptographically secure)
  • โœ… Blockchain immutability
  • โœ… Smart contract access controls
  • โœ… API input validation
  • โœ… CORS protection
  • โœ… Rate limiting ready
  • โœ… Secure key management (.env)

๐Ÿ“š Additional Documentation


๐Ÿš€ Deployment Guide

Option 1: Railway (Recommended for Backend)

  1. Create account at railway.app
  2. Install Railway CLI: npm install -g @railway/cli
  3. Deploy:
    cd backend
    railway login
    railway init
    railway up
  4. Set environment variables in Railway dashboard

Option 2: Vercel (Recommended for Frontend)

  1. Install Vercel CLI: npm install -g vercel
  2. Deploy:
    cd frontend
    vercel
  3. Set VITE_API_URL to your backend URL

Option 3: Manual Deployment

See detailed instructions in your hosting provider's documentation.


๐Ÿ› Troubleshooting

Common Issues

Q: "Contract not initialized" error?
A: Normal for demo mode. Set CONTRACT_ADDRESS in .env to deploy on blockchain.

Q: "GEMINI_API_KEY not set" warning?
A: Normal - AI runs in simulation mode. Get free API key at https://ai.google.dev/

Q: Frontend can't connect to backend?
A:

  1. Check backend is running on port 5000: curl http://localhost:5000/api/health
  2. Verify CORS settings in backend/server.js
  3. Check VITE_API_URL in frontend .env

Q: Port already in use?
A: Change PORT in backend/.env or kill the process using the port

Q: Dependencies not installing?
A:

  1. Delete node_modules and package-lock.json
  2. Run npm install again
  3. Make sure you're using Node.js 16+

Q: Blockchain transaction failing?
A:

  1. Check you have testnet MATIC in your wallet
  2. Verify RPC URL is correct
  3. Ensure private key is valid (no 0x prefix)

Q: File upload not working?
A:

  1. Check file size is under 5MB
  2. Verify file type is JPG, PNG, GIF, or PDF
  3. Check uploads/ directory exists and is writable

Key Talking Points

  • โœ… Real Problem: $100M+ certificate fraud market
  • โœ… Complete Solution: Not just a prototype
  • โœ… Advanced Tech: Blockchain + AI combination
  • โœ… Production Ready: Can deploy today
  • โœ… Scalable: Handles millions of certificates
  • โœ… Cost Effective: Free testnets, low gas fees

๐Ÿ—บ๏ธ Roadmap

Phase 1: Current (v1.0.0) โœ…

  • Smart contract for certificate management
  • Two-layer verification (blockchain + AI)
  • React frontend with Tailwind
  • Express backend API
  • Demo mode for presentations
  • Complete documentation

Phase 2: Enhancements (v1.1.0)

  • QR code generation for certificates
  • Email verification and notifications
  • Analytics dashboard
  • Batch certificate issuance

Phase 3: Mobile & Multi-Chain (v1.2.0)

  • React Native mobile app
  • Multi-chain support (Ethereum, Arbitrum, Optimism)
  • IPFS integration for decentralized storage
  • Advanced dashboard

Phase 4: Enterprise (v2.0.0)

  • OAuth/SSO integration
  • Webhooks for events
  • API key management
  • White-label solution

๐Ÿ“Š Project Statistics

  • Smart Contract: 314 lines (Solidity)
  • Backend: 1,400+ lines (Node.js)
  • Frontend: 600+ lines (React)
  • API Endpoints: 6
  • Functions: 53
  • Documentation: 540+ comments

๐Ÿ“„ License

MIT License - See LICENSE for details.


๐Ÿ™ Acknowledgments

  • Polygon for free testnet
  • Google for Gemini API
  • Ethereum for smart contract standards
  • Open source community for amazing tools

Made with for hackathons and certificate verification ๐Ÿš€