# rohitroy-github/vite-project-evault architecture

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

- Interactive diagram: https://gitdiagram.com/rohitroy-github/vite-project-evault
- Repository: https://github.com/rohitroy-github/vite-project-evault

## Overview

##### Project Type & Purpose
- The project is a blockchain-based eVault solution focused on the Indian Judiciary. It leverages Ethereum Virtual Machine (EVM) compatible networks (Local Hardhat, Sepolia, Polygon, and Morph testnets) along with IPFS for decentralized document storage.
- The frontend is built with ViteJS and Tailwind CSS, while the backend utilizes Hardhat for smart contract development & testing, NodeJS scripts, and integration with blockchain services using Ethers JS, Metamask, and a service like Pinata for IPFS.
- Primary Use Cases: seamless registration for clients, lawyers & judges; case registration & tracking; document uploads via IPFS; and integration with blockchain for authorization and data immutability.

##### Analyzing the File Structure
- Two main top-level components:
- “blockchain-hardhat” folder: Contains smart contracts, deployment scripts, tests, configuration files (e.g. hardhat.config.js), and environment templates.
- “frontend-vite” folder: Contains the web client built using ViteJS, React components, pages, and blockchain API calls to interact with the deployed smart contracts.
- Additional folders such as “project-assets” provide images and snapshots for the documentation.
- The presence of directories like “contracts”, “scripts”, “tasks”, and “test” in the blockchain folder indicates a clear separation for managing smart contracts, deployment automation, and testing.
- The frontend folder includes separation of API calls (the “blockchain-api” subfolder), UI components, pages, and configuration files (e.g., tailwind.config.js).

##### Key Components
a. Blockchain / Backend Components:
- Smart Contracts: Located in “blockchain-hardhat/contracts”, these are the core of the E-Vault functionality.
- Hardhat Environment: Manages local blockchain emulation, testing, and deployment scripts (e.g., deploy_fetchCaseDetailsByAClient.js in “blockchain-hardhat/scripts”).
- Tasks & Testing: Automated tasks (see “blockchain-hardhat/tasks”) and tests (in “blockchain-hardhat/test”) ensure contract correctness.
- Environment Configuration: An .env file (based on .env.example) for setting up network endpoints (Alchemy, etc.) and environment variables.
b. Frontend Components:
- ViteJS-Based Client: “frontend-vite” directory contains the entire client application built with React, Tailwind CSS, and various libraries.
- Blockchain API Integration: Under “frontend-vite/src/blockchain-api”, individual components handle interactions with smart contract functions (login, fetching details, registering cases, etc.).
- UI Components & Pages: Organized under “components” and “pages” directories to separate visual elements, including admin dashboards, case details, login, registration, etc.
- Backend Configuration: “src/backend-config.json” gets updated post-deployment to point to the correct contract addresses based on the network.
c. External Services and Networks:
- Integration with IPFS (using Pinata) for uploading and storing case documents.
- Metamask Wallet for authentication and blockchain interactions.
- Multiple blockchain endpoints – Local Hardhat, Sepolia, and Polygon test networks.

##### Architectural Relationships & Data Flow
- User Interface (Client) Layer: Represented by the ViteJS based frontend.
- Blockchain Interaction Layer:
- A blockchain API module representing asynchronous communication with deployed smart contracts (via ethers.js, Metamask).
- Blockchain & Smart Contract Layer: The core smart contracts (deployed using Hardhat) handling registration, case details, automatic judge allocation, and progress updates.
- Off-Chain Storage: Show the connection from smart contracts or backend scripts to IPFS for storing documents.
- Deployment & Configuration: Including environment files and the update of “backend-config.json” that bridges the frontend with current blockchain addresses.
- Directional relationships: User actions → Frontend API calls → Blockchain smart contract functions → Document storage (IPFS).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users
    User["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        vFrontend["ViteJS Frontend (React & Tailwind)"]:::frontend
        uiComponents["UI Components"]:::frontend
        pages["Pages"]:::frontend
        blockchainApi["Blockchain API Integration"]:::api
        frontendConfig["Frontend Backend Config"]:::config
    end

    %% Blockchain Backend Layer
    subgraph "Blockchain Backend Layer"
        smartContracts["Smart Contracts (EVM)"]:::blockchain
        hardhatEnv["Hardhat Environment\n(Deployment & Testing)"]:::blockchain
        blockchainEnv["Blockchain Env Config\n(.env)"]:::config
    end

    %% External Services
    subgraph "External Services"
        ipfs["IPFS (Pinata)"]:::external
        metamask["Metamask Wallet"]:::external
        evmNetworks["EVM Networks\n(Local Hardhat, Sepolia, Polygon)"]:::external
    end

    %% Data Flow
    User -->|"access"| vFrontend
    vFrontend -->|"renders"| uiComponents
    vFrontend -->|"renders"| pages
    vFrontend -->|"APIcalls"| blockchainApi
    blockchainApi -->|"contractCalls"| smartContracts
    hardhatEnv -->|"deploys/tests"| smartContracts
    blockchainEnv -->|"configures"| hardhatEnv
    smartContracts -->|"storesDocs"| ipfs
    smartContracts -->|"networkTx"| evmNetworks
    vFrontend -->|"authVia"| metamask
    frontendConfig -->|"updatesAddr"| vFrontend

    %% Click Events - Component Mapping
    click smartContracts "https://github.com/rohitroy-github/vite-project-evault/tree/main/blockchain-hardhat/contracts"
    click hardhatEnv "https://github.com/rohitroy-github/vite-project-evault/blob/main/blockchain-hardhat/hardhat.config.js"
    click blockchainEnv "https://github.com/rohitroy-github/vite-project-evault/blob/main/blockchain-hardhat/.env.example"
    click vFrontend "https://github.com/rohitroy-github/vite-project-evault/tree/main/frontend-vite"
    click blockchainApi "https://github.com/rohitroy-github/vite-project-evault/tree/main/frontend-vite/src/blockchain-api"
    click uiComponents "https://github.com/rohitroy-github/vite-project-evault/tree/main/frontend-vite/src/components"
    click pages "https://github.com/rohitroy-github/vite-project-evault/tree/main/frontend-vite/src/pages"
    click frontendConfig "https://github.com/rohitroy-github/vite-project-evault/blob/main/frontend-vite/src/backend-config.json"

    %% Styles
    classDef user fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef api fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef blockchain fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
