Skip to content

Prachi5791/E-Verifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DocVerfy - Blockchain-Based Document Verification System

A comprehensive document verification platform that leverages blockchain technology, IPFS, and role-based access control to provide secure, transparent, and tamper-proof document verification and management.

Developer

Prachi Maruti Patil Student Β· Developer Β· Vidyalankar Institute of Technology, Mumbai

🎯 Project Overview

DocVerfy is a full-stack application designed to streamline document verification processes by:

  • Secure Document Storage: Documents are stored on IPFS with blockchain-backed verification
  • Role-Based Access Control: Three user roles (Uploader, Verifier, Admin) with distinct capabilities
  • Blockchain Integration: Smart contracts ensure document authenticity and immutability
  • QR Code Support: Generate and scan QR codes for easy document verification
  • IPFS Storage: Integration with decentralized storage
  • Email Notifications: Automated email alerts for verification requests and status updates

πŸ“‹ System Architecture

The project consists of three main components:

1. Client (React Frontend)

  • Modern React 19 application with React Router for navigation
  • Role-based dashboards for Uploaders, Verifiers, and Admins
  • QR code generation and scanning capabilities
  • Blockchain interaction via Ethers.js

2. Server (Node.js/Express Backend)

  • Express.js REST API with MongoDB for data persistence
  • Authentication via JWT and role-based authorization
  • IPFS integration for document storage
  • Ethereum blockchain interaction for document verification
  • Email service for notifications

3. Smart Contracts (Hardhat + Solidity)

  • DocumentVerificationV2.sol: Main contract with role-based access control
  • Uses OpenZeppelin's AccessControlEnumerable for secure role management
  • Manages document roots, versions, and verification status
  • Events for document creation, version addition, and revocation

πŸ—οΈ Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          DocVerfy System Architecture                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         HTTP/REST          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React Frontend     │◄────────────────────────────►│   Express Backend   β”‚
β”‚   (Port 3000)        β”‚      with JWT Token         β”‚   (Port 5000)        β”‚
β”‚                      β”‚                             β”‚                      β”‚
β”‚  β€’ Login Page        β”‚                             β”‚  β€’ Auth Routes       β”‚
β”‚  β€’ Dashboards        β”‚         WebSocket           β”‚  β€’ Document Routes   β”‚
β”‚  β€’ QR Generation     β”‚      (Optional)             β”‚  β€’ Verification API  β”‚
β”‚  β€’ QR Scanning       β”‚                             β”‚  β€’ Email Service     β”‚
β”‚  β€’ Document Mgmt     β”‚                             β”‚  β€’ IPFS Integration  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                                     β”‚
         β”‚ Contract ABIs &                                     β”‚ MongoDB
         β”‚ Direct Contract Calls                              β”‚ Connection
         β”‚ (Ethers.js v6)                                     β”‚
         β”‚                                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                                        β”‚   MongoDB Database      β”‚
         β”‚                                        β”‚                         β”‚
         β”‚                                        β”‚  β€’ Users               β”‚
         β”‚                                        β”‚  β€’ Documents Metadata  β”‚
         β”‚                                        β”‚  β€’ Verification Data   β”‚
         β”‚                                        β”‚  β€’ Requests            β”‚
         β”‚                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β”‚ Web3 Calls (Port 8545)
         β”‚
         └────────────────────────────────┬──────────────────────────────┐
                                          β”‚                              β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
                         β”‚   Ethereum Network (Ganache)   β”‚             β”‚
                         β”‚                                β”‚             β”‚
                         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚             β”‚
                         β”‚  β”‚ DocumentVerificationV2   β”‚  β”‚             β”‚
                         β”‚  β”‚ Smart Contract           β”‚  β”‚             β”‚
                         β”‚  β”‚                          β”‚  β”‚             β”‚
                         β”‚  β”‚ β€’ Document Roots         β”‚  β”‚             β”‚
                         β”‚  β”‚ β€’ Versions & Hashes      β”‚  β”‚             β”‚
                         β”‚  β”‚ β€’ Verification Status    β”‚  β”‚             β”‚
                         β”‚  β”‚ β€’ Role-Based Access      β”‚  β”‚             β”‚
                         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚             β”‚
                         β”‚                                β”‚             β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
                                          β”‚                             β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
        β”‚                                                        β”‚     β”‚
        β–Ό                                                        β–Ό     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  IPFS Network      β”‚                              β”‚ NFT.storage      β”‚
β”‚  (Document Store)  β”‚                              β”‚ (Alternative)    β”‚
β”‚                    β”‚                              β”‚                  β”‚
β”‚ β€’ File Content     β”‚                              β”‚ β€’ Pinned Files   β”‚
β”‚ β€’ Content Hash     β”‚                              β”‚ β€’ Backup Storage β”‚
β”‚ β€’ Distributed      β”‚                              β”‚ β€’ NFT Metadata   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Data Flow Diagram

                    DOCUMENT UPLOAD FLOW
                    ═══════════════════

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User     β”‚  1. Select & Upload File
β”‚  (Browser) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  React Client                        β”‚
β”‚  β€’ Hash Document (SHA-256)           β”‚
β”‚  β€’ Validate File                     β”‚
β”‚  β€’ Generate QR Code                  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ 2. POST /doc/upload + File Data
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Express Server                      β”‚
β”‚  β€’ Verify JWT Token                  β”‚
β”‚  β€’ Authenticate User Role            β”‚
β”‚  β€’ Store Metadata in MongoDB         β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚                     β”‚                      β”‚
       β”‚ 3. Upload to IPFS   β”‚ 4. Store in DB       β”‚ 5. Blockchain
       β–Ό                     β–Ό                      β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ IPFS   β”‚           β”‚MongoDB β”‚          β”‚ Smart        β”‚
   β”‚ Get CIDβ”‚           β”‚ Save   β”‚          β”‚ Contract     β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚ Metadata           β”‚ uploadDoc()  β”‚
       β”‚                β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                     β”‚                      β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚  6. Confirmation    β”‚
                  β”‚  Sent to Client     β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


              DOCUMENT VERIFICATION FLOW
              ════════════════════════════

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Uploader  β”‚  1. Request Verification
β”‚            β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  React Client                        β”‚
β”‚  β€’ Request Verifier Assignment       β”‚
β”‚  β€’ Submit via Form                   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚ 2. POST /doc/request-verifier
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Express Server                      β”‚
β”‚  β€’ Create Verification Request       β”‚
β”‚  β€’ Store in MongoDB                  β”‚
β”‚  β€’ Send Email Notification           β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  3. Verifier Receives Email         β”‚
   β”‚  & Sees Request in Dashboard        β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β”‚ 4. Scan QR Code / View Document
          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  React Client (Verifier)             β”‚
   β”‚  β€’ Display Document Details          β”‚
   β”‚  β€’ Show IPFS Content                 β”‚
   β”‚  β€’ Verification Interface            β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β”‚ 5. POST /doc/verify + Approval
          β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  Express Server                      β”‚
   β”‚  β€’ Validate Verifier Role            β”‚
   β”‚  β€’ Update MongoDB                    β”‚
   β”‚  β€’ Call Smart Contract               β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚                 β”‚                  β”‚
          β”‚ Blockchain Tx   β”‚ Database Update  β”‚ Email Notification
          β–Ό                 β–Ό                  β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚Smart       β”‚    β”‚ MongoDB    β”‚    β”‚ Nodemailer     β”‚
   β”‚Contract    β”‚    β”‚ Update     β”‚    β”‚ Notify Users   β”‚
   β”‚verifyVersion       β”‚            β”‚ of Status      β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ User Workflow Diagrams

Uploader Workflow

                         UPLOADER JOURNEY
                    ════════════════════════

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚   START     β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                          β”‚ Login/Sign  β”‚
                          β”‚ Up          β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚                         β”‚
                     β–Ό                         β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Upload          β”‚      β”‚ View My Uploads  β”‚
            β”‚ Document        β”‚      β”‚ & Status         β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Generate QR     β”‚
            β”‚ Code            β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Request Verifier        β”‚
            β”‚ (Pending Verification)  β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Scan QR to Verify         β”‚
            β”‚ Document Status           β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                β”Œβ”€β”€β”€β”€β–΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                    β”‚
                β–Ό                    β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ VERIFIED βœ“      β”‚  β”‚ NOT VERIFIED    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                            β”‚ Wait or Request   β”‚
                            β”‚ Another Verifier  β”‚
                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Verifier Workflow

                         VERIFIER JOURNEY
                    ════════════════════════

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚   START     β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                          β”‚ Login       β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚                         β”‚
                     β–Ό                         β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ View Pending    β”‚      β”‚ Scan Documents   β”‚
            β”‚ Verification    β”‚      β”‚ (QR Code)        β”‚
            β”‚ Requests        β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Click on Request      β”‚
            β”‚ View Document Details β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚ Review Document from      β”‚
            β”‚ IPFS                      β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                β”Œβ”€β”€β”€β”€β–΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                    β”‚
                β–Ό                    β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Approve      β”‚     β”‚ Reject       β”‚
        β”‚ Document     β”‚     β”‚ Document     β”‚
        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚                    β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Transaction to β”‚
                β”‚ Blockchain     β”‚
                β”‚ (Immutable)    β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Email Notification β”‚
                β”‚ Sent to Uploader   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Admin Workflow

                          ADMIN JOURNEY
                    ════════════════════════

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚   START     β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                          β”‚ Admin Login β”‚
                          β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚               β”‚                  β”‚
                 β–Ό               β–Ό                  β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Manage All   β”‚ β”‚ Revoke Docs  β”‚ β”‚ View Reports β”‚
        β”‚ Documents    β”‚ β”‚              β”‚ β”‚ & Analytics  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ Select Doc      β”‚
                        β”‚ to Revoke       β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ Provide Reason      β”‚
                        β”‚ for Revocation      β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ Submit Revocation   β”‚
                        β”‚ (Blockchain)       β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚ Email Notifications β”‚
                        β”‚ to All Parties      β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Frontend

  • React 19: UI framework
  • React Router v7: Client-side routing
  • Ethers.js v6: Blockchain interaction
  • Axios: HTTP client
  • QR Code: qrcode.react and react-qr-reader for QR functionality
  • JWT: jwt-decode for token management

Backend

  • Express.js v5: Web framework
  • MongoDB: Database (via Mongoose)
  • Ethers.js v6: Blockchain interaction
  • IPFS Client: ipfs-http-client for decentralized storage
  • NFT.storage: Alternative IPFS storage
  • Nodemailer: Email notifications
  • JWT: Authentication
  • bcryptjs: Password hashing

Smart Contracts

  • Solidity ^0.8.28: Smart contract language
  • Hardhat: Development framework
  • OpenZeppelin: Secure contract libraries
  • Chai: Testing framework

πŸ“ Project Structure

doc-verfy/
β”œβ”€β”€ client/                 # React frontend application
β”‚   β”œβ”€β”€ public/            # Static files
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components (dashboards, login)
β”‚   β”‚   β”œβ”€β”€ context/       # React Context (AuthContext)
β”‚   β”‚   β”œβ”€β”€ utils/         # Utility functions and routing
β”‚   β”‚   β”œβ”€β”€ contracts/     # ABI files for smart contracts
β”‚   β”‚   └── App.js         # Main application component
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                # Node.js backend
β”‚   β”œβ”€β”€ routes/           # API endpoint definitions
β”‚   β”œβ”€β”€ middleware/       # Authentication and request processing
β”‚   β”œβ”€β”€ model/            # MongoDB schemas
β”‚   β”œβ”€β”€ utils/            # Helper functions (IPFS, Ethereum, Email)
β”‚   β”œβ”€β”€ index.js          # Application entry point
β”‚   └── package.json
β”‚
└── hardhat/              # Smart contract development
    β”œβ”€β”€ contracts/        # Solidity smart contracts
    β”œβ”€β”€ scripts/          # Deployment scripts
    β”œβ”€β”€ test/             # Contract tests
    β”œβ”€β”€ artifacts/        # Compiled contract artifacts
    β”œβ”€β”€ hardhat.config.cjs # Hardhat configuration
    └── package.json

πŸš€ Getting Started

Prerequisites

  • Node.js v16 or higher
  • npm or yarn
  • MongoDB instance (local or cloud - MongoDB Atlas)
  • Ganache or similar Ethereum local network (optional, for local blockchain testing)
  • IPFS node or IPFS API key (for document storage)

Installation

1. Clone and Navigate to Project

cd doc-verfy

2. Setup Smart Contracts (Hardhat)

cd hardhat

# Install dependencies
npm install

# Create .env file with:
# PRIVATE_KEY=your-wallet-private-key
# GANACHE_RPC_URL=http://localhost:8545
# ETHERSCAN_API_KEY=your-etherscan-key

# Compile contracts
npx hardhat compile

# Deploy to local Ganache network
npx hardhat run scripts/deploy.js --network ganache

# Run tests
npx hardhat test

3. Setup Backend (Server)

cd server

# Install dependencies
npm install

# Create .env file with the following variables:
# MONGODB_URI
# PORT=5000
# JWT_SECRET=your-secret-key
# ETH_PROVIDER=http://localhost:8545
# CONTRACT_ADDRESS=0x...
# IPFS_API_KEY=your-ipfs-key
# EMAIL_USER=your-email@gmail.com
# EMAIL_PASS=your-app-password
# NFT_STORAGE_KEY=your-nft-storage-key

npm start
# For development with auto-reload:
npm run dev

The server will run on http://localhost:5000

4. Setup Frontend (Client)

cd client

# Install dependencies with legacy peer deps flag
npm install -legacy-peer-deps

# Create .env file with:
# REACT_APP_API_URL=http://localhost:5000
# REACT_APP_CONTRACT_ADDRESS=0x...
# REACT_APP_RPC_URL=http://localhost:8545

npm start

The client will run on http://localhost:3000

πŸ‘₯ User Roles

1. Uploader

  • Upload documents to the system
  • Generate QR codes for documents
  • Scan QR codes to verify documents
  • View personal uploads and their verification status
  • Request verifiers for their documents

2. Verifier

  • View pending verification requests
  • Scan and verify documents
  • Approve or reject documents
  • Track verification history

3. Admin

  • Manage all documents in the system
  • Revoke documents if needed
  • Manage user roles and permissions
  • View system reports and analytics
  • Handle disputes and system administration

πŸ”‘ Key Features

Document Verification

  • Immutable Records: Documents stored on blockchain and IPFS
  • Version Control: Track multiple versions of documents
  • QR Code Integration: Easy document identification and sharing
  • Expiry Management: Set document expiration dates

Security

  • Role-Based Access Control: Three-tier permission system
  • Password Hashing: Bcrypt for secure password storage
  • JWT Authentication: Stateless authentication tokens
  • Blockchain Verification: Cryptographic proof of authenticity

Storage

  • IPFS Integration: Decentralized file storage
  • NFT.storage: Alternative IPFS provider support
  • MongoDB: User data and metadata storage
  • Ethereum: Document hash and status on-chain

πŸ“‘ API Endpoints

Authentication

  • POST /auth/signup - User registration
  • POST /auth/login - User login
  • POST /auth/logout - User logout

Documents

  • POST /doc/upload - Upload a document
  • GET /doc/:docId - Get document details
  • GET /doc/ - List documents
  • POST /doc/verify - Verify a document
  • DELETE /doc/:docId - Revoke a document

Verification Requests

  • POST /doc/request-verifier - Create verification request
  • GET /doc/requests - Get verification requests
  • PUT /doc/request/:id - Update verification request

πŸ”— Smart Contract Functions

Key Functions in DocumentVerificationV2.sol

  • uploadDocument() - Upload a new document root
  • addVersion() - Add a new version to a document
  • verifyVersion() - Mark a version as verified
  • revokeRoot() - Revoke a document (admin only)
  • getRootInfo() - Get document root information
  • getVersionInfo() - Get version information

πŸ§ͺ Testing

Run Smart Contract Tests

cd hardhat
npx hardhat test

Run Frontend Tests

cd client
npm test

πŸ“¦ Deployment

Deploy Smart Contracts to Testnet

cd hardhat
npx hardhat run scripts/deploy.js --network sepolia

Build Frontend for Production

cd client
npm run build

The optimized build will be in the client/build/ directory.

πŸ”’ Environment Variables

Server (.env)

MONGODB_URI=
PORT=
JWT_SECRET=
ETH_PROVIDER=
CONTRACT_ADDRESS=
IPFS_API_KEY=
EMAIL_USER=
EMAIL_PASS=
NFT_STORAGE_KEY=

Client (.env)

REACT_APP_API_URL=
REACT_APP_CONTRACT_ADDRESS=
REACT_APP_RPC_URL=

Hardhat (.env)

PRIVATE_KEY=
GANACHE_RPC_URL=
ETHERSCAN_API_KEY=

πŸ› Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running locally or check connection string
  • Verify network access if using MongoDB Atlas

Contract Deployment Failures

  • Check that Ganache/local network is running
  • Verify account has sufficient funds
  • Check contract address is correctly set in client

IPFS Upload Failures

  • Verify IPFS API key or local IPFS node is accessible
  • Check file size limits
  • Test connectivity to IPFS node

About

A comprehensive document verification platform that leverages blockchain technology, IPFS, and role-based access control to provide secure, transparent, and tamper-proof document verification and management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors