How syarifulmujaddiq/certificate-gen-ver works
Project Type and Purpose
• This is a full-stackBlockchain-enabled certificate management and verification system.
• Purpose: Allow an admin to generate PDF certificates, hash them (SHA-256), store on IPFS via Pinata, record the CID/hash on a smart contract, and allow both admin and the public to verify certificates (via file upload or QR code).
File Structure
• Top-level directories:
• backend/ – Express.js REST API (controllers, routes, middleware, ABI)
• frontend/ – React + Tailwind CSS single-page app (components, public assets)
• smart-contract/ – Hardhat project (Solidity contracts, deployment/test scripts)
• Patterns:
• MVC-ish separation in backend (controllers ↔ routes ↔ middleware)
• Componentized React UI
• Separate concerns for on-chain logic (smart-contract) vs off-chain services
• Config & deployment artifacts:
• .env for secrets and RPC URL
• Hardhat config and deploy scripts
• Pinata API integration in backend via HTTP
README for Additional Insights
• Tech stack: React, Tailwind, Express, JWT auth, Hardhat/Ethers, IPFS/Pinata, SHA-256
• Workflow:
1. Deploy smart contract on local Hardhat node
2. Copy ABI + contract address to backend
3. Start backend Express
4. Start React frontend
• Features: Admin login, certificate generation + PDF + IPFS + blockchain, verification by upload or QR
a. Main Components (group into logical layers):
1. Presentation Layer
– Admin & Public React UI (Run in browser)
2. API Layer
– Express.js backend
• AuthController (JWT)
• CertificateController (PDF gen, hashing, IPFS upload)
• Routes (authRoutes, certificateRoutes)
3. Blockchain Layer
– Ethereum test network (Hardhat node)
– CertificateRegistry smart contract (ABI in backend/abi)
4. External Services
– IPFS via Pinata (CID storage)
5. Data Stores / Temporary Storage
– Temporary uploads/ folder (PDF staging)
– cert-metadata.json (runtime metadata)
b. Relationships & Data Flow:
1. User (Admin) → React form → HTTP POST /api/auth → JWT issued
2. Admin → fills generate form → HTTP POST /api/certificate/generate → backend:
• Generates PDF → Computes SHA-256 hash → Uploads PDF to Pinata →
• Calls smart contract method via Ethers RPC → Stores hash & CID on-chain → Responds with tx/hash
3. Public User → Scans QR (hash) → React triggers GET /api/certificate/verify/:hash →
• Backend optionally queries smart contract → Verifies against stored hash/CID → Returns status
4. Backend ↔ Hardhat Node (via RPC URL)
5. Backend ↔ Pinata API (via API_KEY/SECRET)
c. Architectural Patterns & Design Principles:
• Separation of concerns: UI vs API vs blockchain vs IPFS
• MVC-style organization in backend
• Stateless JWT authentication
• Eventual consistency: on-chain writes are asynchronous
• Component-based UI for reusability
d. Key Technologies:
• React + Tailwind CSS (frontend)
• Express.js + JWT + axios (backend)
• Hardhat + Ethers.js + Solidity (smart-contract)
• IPFS (Pinata) for off-chain storage
• SHA-256 for integrity
Elements
• Labels:
• “Admin UI”, “Public UI”, “Express API”, “Smart Contract”, “IPFS Pinata”
• Request/response flows (HTTP, RPC, REST)
• Annotations:
• Environment variables (.env) feeding into backend
• ABI artifact feeding into the API
• Call out the use of SHA-256 hash function