# suxutao/noteevidence architecture

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

- Interactive diagram: https://gitdiagram.com/suxutao/noteevidence
- Repository: https://github.com/suxutao/noteevidence

## Overview

##### Project type and purpose
- This is a decentralized application (DApp) for “Note Verification on Ethereum.”
- It consists of on-chain components (Solidity smart contracts deployed via Hardhat) and an off-chain React frontend interacting through MetaMask/ethers.js.

##### File structure
- Top-level folders:
- contracts/      → Solidity sources (NoteVerifier.sol, Counter.sol)
- frontend/       → React app (JSX components, contractABI.js, CSS, HTML)
- scripts/        → deployment & operational scripts (deploy.js, send-op-tx.ts)
- test/           → Mocha/Chai + Hardhat tests for contracts
- hardhat.config.ts & tsconfig.json → build/deploy configuration
- Key patterns:
- DApp layered architecture (UI ↔ Web3 provider ↔ Blockchain network)
- Hardhat development network vs. public testnet (Sepolia)
- LocalStorage for offline note content

##### README for additional insights
- Core features: note-hash storage, retrieval, verification, listing
- Workflows:
- LocalHardhat node ⟷ deploy scripts ⟷ smart contracts
- React UI ⟷ MetaMask/ethers.js ⟷ Ethereum network
- Security: only hashes on-chain; note texts in browser localStorage

1) User Browser Environment
– React SPA (NoteEditor, NoteList, VerifyNote)
– LocalStorage for raw notes
– MetaMask Web3 provider
2) Blockchain Layer
– Ethereum Network (Hardhat local node / Sepolia RPC)
– Smart Contracts (NoteVerifier, Counter)
3) Development & Deployment
– Hardhat CLI & config
– scripts/deploy.js, scripts/send-op-tx.ts
– Mocha/Chai tests under test/
– User → React UI: create/edit note
– UI → Hashing module → compute SHA256
– UI → MetaMask/ethers.js → sendTransaction(hash) → Ethereum node
– Ethereum node → Smart Contract storage → block data
– UI ← ethers.js.call → contract view functions (getNotes, verifyHash)
– UI ↔ localStorage for raw note persistence
– Developer → Hardhat CLI → deploy/test scripts → local/testnet
c. Architectural patterns & design principles
– Separation of concerns:
- Presentation (React)
- Blockchain logic (Solidity contracts)
- Infrastructure/config (Hardhat, scripts)
– Stateless frontend with on-chain state
– Secure by design: only hashes on-chain
d. Key technologies & libraries
– Hardhat 3 Beta (Ethereum dev framework)
– Solidity (smart contracts)
– ethers.js (Web3 SDK)
– React (frontend)
– Mocha & Chai (tests)
– MetaMask (user’s Web3 wallet)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        direction TB
        User("User"):::external
        React("React SPA"):::frontend
        NoteEditor("NoteEditor.jsx"):::frontend
        NoteList("NoteList.jsx"):::frontend
        VerifyNote("VerifyNote.jsx"):::frontend
        Main("main.jsx"):::frontend
        HTML("index.html"):::frontend
        CSS("style.css"):::frontend
        ABI("contractABI.js"):::frontend
        CounterJS("counter.js"):::frontend
        MMTest("MetaMaskConnectionTest.html"):::frontend
        GetChain("getChainId.js"):::frontend
        LocalStorage("localStorage"):::frontend

        User -->|"interact"| React
        React --> NoteEditor
        React --> NoteList
        React --> VerifyNote
        React --> ABI
        React --> CounterJS
        React --> MMTest
        React --> CSS
        React --> HTML
        React --> Main
        React --> GetChain
        React --> LocalStorage
    end

    subgraph "Blockchain Layer"
        direction TB
        Provider("MetaMask/ethers.js"):::backend
        Ethereum("Ethereum Network"):::backend
        Contracts("Smart Contracts"):::backend
        NV("NoteVerifier.sol"):::backend
        Counter("Counter.sol"):::backend

        React -.->|"sendTransaction(hash)"| Provider
        React -.->|"call(view functions)"| Provider
        Provider --> Ethereum
        Ethereum --> Contracts
        Contracts --> NV
        Contracts --> Counter
    end

    subgraph "DevOps & Testing"
        direction TB
        Dev("Developer"):::dev
        Hardhat("Hardhat CLI"):::dev
        Config("hardhat.config.ts"):::dev
        TSConf("tsconfig.json"):::dev
        Deploy("deploy.js"):::dev
        OpTx("send-op-tx.ts"):::dev
        Test1("Counter.ts"):::dev
        Test2("NoteVerifier.ts"):::dev

        Dev --> Hardhat
        Hardhat --> Config
        Hardhat --> TSConf
        Hardhat --> Deploy
        Hardhat --> OpTx
        Hardhat --> Test1
        Hardhat --> Test2
        Deploy -.->|"deploy contracts"| Ethereum
        OpTx -.->|"send operations"| Ethereum
        Test1 -.->|"run tests"| Hardhat
        Test2 -.->|"run tests"| Hardhat
    end

    classDef frontend fill:#1E90FF,stroke:#333,stroke-width:1px,color:#fff;
    classDef backend fill:#32CD32,stroke:#333,stroke-width:1px,color:#fff;
    classDef dev fill:#D3D3D3,stroke:#333,stroke-width:1px,color:#000;
    classDef external fill:#87CEEB,stroke:#333,stroke-width:1px,color:#000;

    click React "https://github.com/suxutao/noteevidence/tree/main/frontend/"
    click NoteEditor "https://github.com/suxutao/noteevidence/blob/main/frontend/src/NoteEditor.jsx"
    click NoteList "https://github.com/suxutao/noteevidence/blob/main/frontend/src/NoteList.jsx"
    click VerifyNote "https://github.com/suxutao/noteevidence/blob/main/frontend/src/VerifyNote.jsx"
    click Main "https://github.com/suxutao/noteevidence/blob/main/frontend/src/main.jsx"
    click HTML "https://github.com/suxutao/noteevidence/blob/main/frontend/index.html"
    click CSS "https://github.com/suxutao/noteevidence/blob/main/frontend/src/style.css"
    click ABI "https://github.com/suxutao/noteevidence/blob/main/frontend/src/contractABI.js"
    click CounterJS "https://github.com/suxutao/noteevidence/blob/main/frontend/src/counter.js"
    click MMTest "https://github.com/suxutao/noteevidence/blob/main/frontend/src/MetaMaskConnectionTest.html"
    click GetChain "https://github.com/suxutao/noteevidence/blob/main/getChainId.js"
    click NV "https://github.com/suxutao/noteevidence/blob/main/contracts/NoteVerifier.sol"
    click Counter "https://github.com/suxutao/noteevidence/blob/main/contracts/Counter.sol"
    click Config "https://github.com/suxutao/noteevidence/blob/main/hardhat.config.ts"
    click TSConf "https://github.com/suxutao/noteevidence/blob/main/tsconfig.json"
    click Deploy "https://github.com/suxutao/noteevidence/blob/main/scripts/deploy.js"
    click OpTx "https://github.com/suxutao/noteevidence/blob/main/scripts/send-op-tx.ts"
    click Test1 "https://github.com/suxutao/noteevidence/blob/main/test/Counter.ts"
    click Test2 "https://github.com/suxutao/noteevidence/blob/main/test/NoteVerifier.ts"
```
