# laitazidan/blockchain-certficate-verification architecture

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

- Interactive diagram: https://gitdiagram.com/laitazidan/blockchain-certficate-verification
- Repository: https://github.com/laitazidan/blockchain-certficate-verification

## Overview

##### Project type and purpose
- This is a full-stack blockchain-enabled certificate issuance and verification system.
- The “frontend” is a React/Tailwind/Vite web app for users to generate and validate certificates.
- The “backend” is a Python service (likely using Flask or FastAPI) that exposes REST endpoints, handles certificate cryptography, persists data in MongoDB, and mediates with the blockchain.
- The “blockchain” folder contains a Truffle project defining and deploying a smart contract (CertificateVerification) on an Ethereum-compatible network.

##### File structure
- Top-level:
- backend/ – Python API, crypto utilities, routes, Mongo driver, static assets.
- blockchain/ – smart contract code, build artifacts, migrations, tests, truffle config.
- frontend/ – React components, pages, styling, build config (Vite, Tailwind, Flowbite).
- test/ – end-to-end tests for the API and smart contract.
- backend/crypto and backend/database signal separation of concerns (cryptography vs. storage).
- backend/routes maps to logical API endpoints: activity, blockchain interactions, certificate issuance, verification, and a route to serve the frontend.
- blockchain/ using Truffle indicates an Ethereum development flow: compile, migrate, test.

##### (empty) README
- No high-level architecture section provided—so we’ll rely on the structure and file names for guidance.

##### Detail
- Call out environment config (.env) feeding credentials/keys into the backend.
- Public/private key files under “Crypto module” as assets used for signing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        FE1["Home Page"]:::frontend
        FE2["Generate Page"]:::frontend
        FE3["Validation Page"]:::frontend
        COMP["Components & Layout"]:::frontend
        STYLE["Styling & Config"]:::frontend
        FE1 --> COMP
        FE2 --> COMP
        FE3 --> COMP
        COMP --> STYLE
        STYLE --> API
    end

    click FE1 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/frontend/src/pages/Home.jsx"
    click FE2 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/frontend/src/pages/Generate.jsx"
    click FE3 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/frontend/src/pages/Validation.jsx"
    click COMP "https://github.com/laitazidan/blockchain-certficate-verification/tree/main/frontend/src/components/"
    click STYLE "https://github.com/laitazidan/blockchain-certficate-verification/tree/main/frontend/"

    %% Backend API Layer
    subgraph "Backend API Layer"
        direction TB
        API["Python Backend API"]:::backend
        ENV["Config & .env"]:::module
        API --> ENV

        subgraph "Routes Layer"
            direction TB
            R1["activity.py"]:::backend
            R2["blockchain.py"]:::backend
            R3["certificate.py"]:::backend
            R4["verification.py"]:::backend
            R5["frontend.py"]:::backend
        end
        API --> Routes

        subgraph "Crypto Module"
            direction TB
            AES["aes_utils.py"]:::module
            RSA["rsa_utils.py"]:::module
            HASH["hash_utils.py"]:::module
            KEYS["Key Storage"]:::module
        end
        API --> AES
        API --> RSA
        API --> HASH
        API --> KEYS

        subgraph "Database Module"
            direction TB
            DBMOD["mongo.py"]:::module
            DB["MongoDB (logs.db)"]:::database
        end
        API --> DBMOD
        DBMOD --> DB

        STATIC["Static Assets"]:::module
        API --> STATIC
    end

    click ENV "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/config.py"
    click ENV "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/.env"
    click R1 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/routes/activity.py"
    click R2 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/routes/blockchain.py"
    click R3 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/routes/certificate.py"
    click R4 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/routes/verification.py"
    click R5 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/routes/frontend.py"
    click AES "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/crypto/aes_utils.py"
    click RSA "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/crypto/rsa_utils.py"
    click HASH "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/crypto/hash_utils.py"
    click KEYS "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/keys/private_key.pem"
    click DBMOD "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/database/mongo.py"
    click DB "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/backend/logs.db"
    click STATIC "https://github.com/laitazidan/blockchain-certficate-verification/tree/main/backend/static/"

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        direction TB
        TRUFFLECFG["truffle-config.js"]:::blockchain
        MIG["2_deploy_contracts.js"]:::blockchain
        CONTRACTSRC["contracts/CertificateVerification.sol"]:::blockchain
        ABI["CertificateVerification.json"]:::blockchain
        NODE["Ethereum Node (Ganache/Testnet)"]:::external
        TRUFFLECFG --> MIG
        MIG --> CONTRACTSRC
        CONTRACTSRC --> ABI
        API -->|"Web3RPC Calls"| NODE
        API --> ABI
        CONTRACTSRC --> NODE
    end

    click TRUFFLECFG "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/blockchain/truffle-config.js"
    click MIG "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/blockchain/migrations/2_deploy_contracts.js"
    click CONTRACTSRC "https://github.com/laitazidan/blockchain-certficate-verification/tree/main/blockchain/contracts/"
    click ABI "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/blockchain/build/contracts/CertificateVerification.json"

    %% Tests
    subgraph "Testing"
        direction TB
        T1["test_api.py"]:::external
        T2["test_smart_contract.js"]:::external
        T1 --> API
        T2 --> CONTRACTSRC
    end

    click T1 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/test/test_api.py"
    click T2 "https://github.com/laitazidan/blockchain-certficate-verification/blob/main/test/test_smart_contract.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#3399FF,color:#000
    classDef backend fill:#DFFFD0,stroke:#33CC33,color:#000
    classDef module fill:#FFF5CC,stroke:#FFCC00,color:#000
    classDef database fill:#FFE0B2,stroke:#FF9800,color:#000
    classDef blockchain fill:#FFE0E0,stroke:#FF3333,color:#000
    classDef external fill:#E0E0E0,stroke:#999,color:#000
```
