# nikhildsahu/e-certify architecture

> Architecture diagram of the GitHub repository nikhildsahu/e-certify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikhildsahu/e-certify
- Repository: https://github.com/nikhildsahu/e-certify

## Overview

##### Project type and purpose
- From the README and file tree, E-Certify is a blockchain-based DApp for online certificate issuance, storage, sharing and validation.
- It uses React.js for the front end, Ethereum smart contracts (via Truffle) for on-chain logic, IPFS for document storage, and Firebase for OTP-based authentication.

##### File structure
- Top-level directories:
- contracts/ (solidity source & Truffle migrations)
- e-certify/ (Truffle React “client” with compiled contract JSON artifacts)
- src/ (React application: App.js, Auth/, Institute/, Student/, CommonComponents/, Routes/, utils/)
- public/ (static HTML, manifest)
- img/ (screenshots)
- Solidity/ (version notes)
- Key patterns:
- No traditional server—front end talks directly to the blockchain and IPFS.
- Separation of UI modules by user role (Student vs. Institute).
- Utilities for Web3, IPFS, and Firebase live under src/utils, Fire.js, ipfs.js, getWeb3.js, web3.js.

##### README for additional insights
- Confirms DApp on Ethereum using MetaMask.
- Documents multi-sig wallet creation for each student/institute pair.
- Specifies Truffle for contract management and local development console.
- Emphasizes local encryption then upload to IPFS, followed by on-chain hash storage.

a. Main components
- React Single-Page App (src/)
- MetaMask / Web3 Provider
- Ethereum Network (local Ganache/Truffle or testnet via Infura)
- Smart Contracts (Migrations.sol, SimpleStorage.sol, MultiSig.sol)
- IPFS Network (document storage)
- Firebase Auth (OTP service)
b. Relationships and interactions
- User ↔ React SPA
- React SPA → MetaMask → Ethereum smart contracts (RPC calls)
- React SPA → ipfs.js → IPFS API (upload/download encrypted certs)
- React SPA ↔ Fire.js → Firebase OTP service for signup/login
- Smart contracts emit events → React SPA listens for on-chain updates
c. Architectural patterns
- MVC-like separation in the front-end (components, routes, state management via Web3 hooks)
- “Smart contract as backend” – no centralized server; on-chain logic
- Asynchronous promise-based flows for blockchain and IPFS calls
- Multi-signature wallet pattern for joint student/institute approvals
d. Relevant technologies/frameworks
- React.js, JSX, CSS (UI)
- Truffle (contract testing, migrations)
- Web3.js, getWeb3.js (Ethereum integration)
- IPFS API (via ipfs.js)
- Firebase Auth (via Fire.js)
- MetaMask extension (provider)

##### Details
- Truffle migration process as part of the development pipeline.
- Multi-sig approval flow between student/institute wallets.
- Do not omit the Firebase OTP handshake step in the authentication flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (React SPA)"
        direction TB
        App["App.js"]:::client
        Index["index.js"]:::client
        SW["serviceWorker.js"]:::client
        subgraph "UI Components"
            direction TB
            CommonComp["CommonComponents/"]:::client
            Routes["Routes/"]:::client
            subgraph "Auth Modules"
                direction TB
                SignUpG["SignUpG.jsx"]:::client
                SignUpI["SignUpI.jsx"]:::client
                Login["Login.jsx"]:::client
                OtpS["OtpS.jsx"]:::client
                OtpI["OtpI.jsx"]:::client
            end
            subgraph "Dashboards"
                direction TB
                Student["Student/"]:::client
                Institute["Institute/"]:::client
            end
        end
        subgraph "Utilities"
            direction TB
            Fire["Fire.js"]:::auth
            IPFSUtil["ipfs.js"]:::client
            GetWeb3["getWeb3.js"]:::client
            Web3Util["web3.js"]:::client
        end
        PublicHTML["index.html"]:::client
        Manifest["manifest.json"]:::client
    end

    %% External Integrations
    MetaMask["MetaMask Provider"]:::external
    Firebase["Firebase OTP Service"]:::auth
    Ethereum["Ethereum Network"]:::decentralized
    IPFSNet["IPFS Network"]:::decentralized

    %% Smart Contracts
    subgraph "Smart Contracts"
        direction TB
        ContractsSrc["contracts/"]:::decentralized
        ArtifactsFE["e-certify/src/contracts/"]:::decentralized
        ArtifactsLocal["src/contracts/"]:::decentralized
    end

    %% Flows
    App -->|"renders UI"| CommonComp
    App -->|"configures routes"| Routes
    App -->|"registers SW"| SW
    App -->|"imports utils"| Fire
    App -->|"imports utils"| IPFSUtil
    App -->|"imports utils"| GetWeb3
    App -->|"imports utils"| Web3Util

    SignUpG --> AuthFlow[("Auth Flow")]:::auth
    SignUpI --> AuthFlow
    Login --> AuthFlow
    OtpS --> AuthFlow
    OtpI --> AuthFlow
    AuthFlow -->|HTTPS/REST| Firebase

    App -->|"Web3 RPC"| MetaMask
    MetaMask -->|"calls"| Ethereum
    GetWeb3 --> MetaMask
    Web3Util --> MetaMask

    IPFSUtil -->|"HTTP API"| IPFSNet

    App -->|"loads contracts artifacts"| ArtifactsFE
    App -->|"loads local artifacts"| ArtifactsLocal
    Ethereum --> ContractsSrc

    %% Legends (invisible nodes for layout)
    Env1([ ]) --> App
    Env1 --> MetaMask

    %% Click Events
    click App "https://github.com/nikhildsahu/e-certify/blob/master/src/App.js"
    click Index "https://github.com/nikhildsahu/e-certify/blob/master/src/index.js"
    click SW "https://github.com/nikhildsahu/e-certify/blob/master/src/serviceWorker.js"
    click CommonComp "https://github.com/nikhildsahu/e-certify/tree/master/src/CommonComponents/"
    click Routes "https://github.com/nikhildsahu/e-certify/tree/master/src/Routes/"
    click SignUpG "https://github.com/nikhildsahu/e-certify/blob/master/src/Auth/SignUpG.jsx"
    click SignUpI "https://github.com/nikhildsahu/e-certify/blob/master/src/Auth/SignUpI.jsx"
    click Login "https://github.com/nikhildsahu/e-certify/blob/master/src/Login/Login.jsx"
    click OtpS "https://github.com/nikhildsahu/e-certify/blob/master/src/Login/OtpS.jsx"
    click OtpI "https://github.com/nikhildsahu/e-certify/blob/master/src/Login/OtpI.jsx"
    click Student "https://github.com/nikhildsahu/e-certify/tree/master/src/Student/"
    click Institute "https://github.com/nikhildsahu/e-certify/tree/master/src/Institute/"
    click Fire "https://github.com/nikhildsahu/e-certify/blob/master/src/Fire.js"
    click IPFSUtil "https://github.com/nikhildsahu/e-certify/blob/master/src/ipfs.js"
    click GetWeb3 "https://github.com/nikhildsahu/e-certify/blob/master/src/utils/getWeb3.js"
    click Web3Util "https://github.com/nikhildsahu/e-certify/blob/master/src/web3.js"
    click PublicHTML "https://github.com/nikhildsahu/e-certify/blob/master/public/index.html"
    click Manifest "https://github.com/nikhildsahu/e-certify/blob/master/public/manifest.json"
    click ContractsSrc "https://github.com/nikhildsahu/e-certify/tree/master/contracts/"
    click ArtifactsFE "https://github.com/nikhildsahu/e-certify/tree/master/e-certify/src/contracts/"
    click ArtifactsLocal "https://github.com/nikhildsahu/e-certify/tree/master/src/contracts/"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0277BD,color:#000
    classDef decentralized fill:#E0F8E0,stroke:#2E7D32,color:#000
    classDef auth fill:#F3E5F5,stroke:#6A1B9A,color:#000
    classDef external fill:#FFF3E0,stroke:#F57C00,color:#000
```
