How swayam-2003/blockchain-certificate-system works
Project Type and Purpose
• This is a full-stack decentralized web application (“Blockchain Certificate System”) that enables educational institutions to issue, store, and verify tamper-proof certificates on Ethereum, with metadata stored on IPFS, authentication via Firebase, and a responsive static frontend.
File Structure
• Top-level folders:
• contracts/ & migrations/: Truffle smart contract (CertificateRegistry.sol) + deploy scripts
• public/: Static web UI (HTML pages, CSS, client-side JS)
• src/: Node.js/Express backend
– config/: env & Firebase setup
– controllers/: HTTP request handlers
– middleware/: Express auth guard (Firebase-based)
– routes/: REST API endpoints (/api/certificates/…)
– services/: business logic for IPFS, Pinata, Web3 interactions
– index.js & app.js: server bootstrap and router wiring
• templates/: HTML template(s) for server-rendered views
• truffle-config.js: blockchain network config
README for Insights
• Core components:
• Frontend: static HTML/CSS/JS + Bootstrap + MetaMask integration
• Backend: Node/Express REST API
• Blockchain: Ethereum contracts via Web3.js & Truffle (deployed on Ganache in dev)
• Storage: IPFS (Pinata) for certificate metadata
• Auth & DB: Firebase Authentication + Firestore for user roles and metadata indexing
Main Components
a. Frontend (browser):
• Static assets (public/pages/*.html, auth.js)
• MetaMask plugin for signing blockchain transactions
• Consumes Express REST API & directly interacts with smart contract via Web3.js (optional)
b. Express Backend (Node.js):
• Routes → Controllers → Services
• Middleware for Firebase authentication & role checks
• Services:
• web3Service: calls smart contract methods on Ethereum
• ipfsService / pinataService: uploads certificate metadata to IPFS/Pinata
• (Optional) Firestore client for quick lookup of certificate events
c. Ethereum Blockchain:
• CertificateRegistry.sol contract
• Ganache (development) or public test/mainnet
d. IPFS Network:
• Pinata gateway for persistently pinning JSON metadata
e. Firebase:
• Firebase Auth: user login & issuer role enforcement
• Firestore: stores user-certificate indexing, maybe USN uniqueness
f. External Tools:
• MetaMask (user wallet)
• Ganache Desktop (local Ethereum node)
Relationships and Data Flow
• User → Frontend → (1) REST API calls to Express backend or (2) direct Web3 calls via MetaMask
• Backend:
• Verifies Firebase JWT via auth middleware
• Calls IPFS/Pinata to store certificate JSON; receives CID
• Calls smart contract (web3Service) to mint/store certificate on Ethereum, passing CID + USN + metadata
• Optionally logs metadata in Firestore for search/recent endpoints
• Frontend:
• Displays certificate issuance/validation UI
• Fetches certificate details via REST (which may read contract via web3Service or Firestore)
• Smart Contract:
• Emits events (CertificateIssued, Revoked)
• Provides view functions for validation
Architectural Patterns & Principles
• Layered Architecture: Presentation (static UI), API Layer (Express), Service Layer (business logic), Data Layer (Ethereum + IPFS + Firestore)
• Separation of Concerns:
• Auth (Firebase middleware)
• Storage (IPFS vs Firestore vs blockchain)
• Contract interaction (web3Service)
• Event-Driven: Smart contract emits events that backend (or another service) could consume for indexing