# mrakhilmalvi/chainwallet-web architecture

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

- Interactive diagram: https://gitdiagram.com/mrakhilmalvi/chainwallet-web
- Repository: https://github.com/mrakhilmalvi/chainwallet-web

## Overview

##### Project Type and Purpose
- This is a full-stack decentralized application (DApp) built with Next.js (React) for the frontend, WAGMI/Ethers for blockchain connectivity, and Solidity contracts under the contracts folder. Its purpose is to let users stake ERC-20 tokens, participate in an ICO, and earn rewards on any blockchain network (configured via RPC URLs).

##### File-Structure Highlights
- “pages/”: Next.js routing – pages/_app.js (app shell), pages/index.js (home), pages/admin.js (admin dashboard), pages/activities.js (user activity logs).
- “Components/”: UI atoms, molecules and templates – global Header/Footer/HeroSection/Loader, feature folders for Admin & Investor functionality, and shared components (Buttons, Inputs, Modals).
- “Context/”: JSON ABIs and constants + React Context provider wiring up WAGMI hooks, reading NEXT_PUBLIC_* env variables for chain IDs, contract addresses, currency, explorer URLs.
- “contracts/”: Solidity source files defining the staking and ICO contracts.
- “public/”: Static assets (CSS, images, vanilla JS).
- Configuration files: next.config.js, .env.local (runtime env), package.json (scripts & deps).

##### Key README Insights
- Technical stack: Next.js, React 18, WAGMI for wallet/connect, Ethers for contract calls, HeadlessUI + Heroicons + NextUI for styling, React-Hot-Toast for notifications, Formspree for contact form.
- Environment variables drive smart-contract addresses, network config (Holesky testnet).
- Deployment: Remix for contract compilation/deployment, any EVM RPC provider (e.g., Ankr).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        AppShell["_app.js"]:::ui
        HomePage["index.js"]:::ui
        AdminDashboard["admin.js"]:::ui
        ActivityLogs["activities.js"]:::ui

        subgraph "UI Components"
            direction TB
            Header["Header.jsx"]:::ui
            Footer["Footer.jsx"]:::ui
            HeroSection["HeroSection.jsx"]:::ui
            Loader["Loader.jsx"]:::ui
            Notification["Notification.jsx"]:::ui
            ICOSale["ICOSale.jsx"]:::ui
            PoolsOverview["Pools.jsx"]:::ui
            PoolsModel["PoolsModel.jsx"]:::ui
            TokenInteraction["Token.jsx"]:::ui
            WithdrawFlow["Withdraw.jsx"]:::ui
            WithdrawModal["WithdrawModal.jsx"]:::ui
            ContactForm["Contact.jsx"]:::ui
            AskFAQ["Ask.jsx"]:::ui
            Statistics["Statistics.jsx"]:::ui
            subgraph "Admin Features"
                direction TB
                AdminShell["Admin.jsx"]:::ui
                AdminNav["AdminNav.jsx"]:::ui
                AdminHead["AdminHead.jsx"]:::ui
                AdminAuth["Auth.jsx"]:::ui
                PoolManagement["Pool.jsx"]:::ui
                Investing["Investing.jsx"]:::ui
                ICOTokenAdmin["ICOToken.jsx"]:::ui
                TokenAdmin["Token.jsx"]:::ui
                StakingAdmin["Staking.jsx"]:::ui
                TransferAdmin["Transfer.jsx"]:::ui
                AdminNotification["Notification.jsx"]:::ui
                UpdateAPY["UpdateAPYModel.jsx"]:::ui
            end
        end
    end

    %% Logic Layer
    subgraph "Logic Layer"
        direction TB
        ContextProvider["index.js"]:::logic
        Constants["constants.js"]:::logic
        ERC20ABI["ERC20.json"]:::logic
        StakingDappABI["StakingDapp.json"]:::logic
        TokenICOABI["TokenICO.json"]:::logic
    end

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        direction TB
        SmartContracts["contracts/"]:::contract
    end

    %% Node
    RPCNode["RPC Endpoint"]:::node

    %% External Services
    subgraph "External Services"
        direction TB
        Formspree["Formspree API"]:::external
        Explorer["Block Explorer"]:::external
    end

    %% Data Flow
    AppShell -->|interact| ContextProvider
    HomePage -->|interact| ContextProvider
    AdminDashboard -->|interact| ContextProvider
    ActivityLogs -->|interact| ContextProvider

    ContextProvider -->|uses| ERC20ABI
    ContextProvider -->|uses| StakingDappABI
    ContextProvider -->|uses| TokenICOABI
    ContextProvider -->|reads| Constants

    ContextProvider -->|"JSON-RPC call"| RPCNode
    RPCNode -->|"forwards tx"| SmartContracts
    SmartContracts -->|"events/logs"| RPCNode
    RPCNode -->|"response"| ContextProvider
    ContextProvider -->|"update UI"| AppShell

    ContactForm -->|"HTTP POST"| Formspree

    %% Click Events
    click AppShell "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/pages/_app.js"
    click HomePage "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/pages/index.js"
    click AdminDashboard "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/pages/admin.js"
    click ActivityLogs "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/pages/activities.js"
    click Header "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Header.jsx"
    click Footer "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Footer.jsx"
    click HeroSection "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/HeroSection.jsx"
    click Loader "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Loader.jsx"
    click Notification "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Notification.jsx"
    click ICOSale "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/ICOSale.jsx"
    click PoolsOverview "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Pools.jsx"
    click PoolsModel "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/PoolsModel.jsx"
    click TokenInteraction "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Token.jsx"
    click WithdrawFlow "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Withdraw.jsx"
    click WithdrawModal "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/WithdrawModal.jsx"
    click ContactForm "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Contact.jsx"
    click AskFAQ "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Ask.jsx"
    click Statistics "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Statistics.jsx"
    click AdminShell "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Admin.jsx"
    click AdminNav "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/AdminNav.jsx"
    click AdminHead "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/AdminHead.jsx"
    click AdminAuth "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Auth.jsx"
    click PoolManagement "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Pool.jsx"
    click Investing "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Investing.jsx"
    click ICOTokenAdmin "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/ICOToken.jsx"
    click TokenAdmin "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Token.jsx"
    click StakingAdmin "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Staking.jsx"
    click TransferAdmin "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Transfer.jsx"
    click AdminNotification "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/Notification.jsx"
    click UpdateAPY "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Components/Admin/UpdateAPYModel.jsx"
    click ContextProvider "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Context/index.js"
    click Constants "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Context/constants.js"
    click ERC20ABI "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Context/ERC20.json"
    click StakingDappABI "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Context/StakingDapp.json"
    click TokenICOABI "https://github.com/mrakhilmalvi/chainwallet-web/blob/main/Context/TokenICO.json"
    click SmartContracts "https://github.com/mrakhilmalvi/chainwallet-web/tree/main/contracts/"

    %% Styles
    classDef ui fill:#CCE5FF,stroke:#3399FF,color:#000;
    classDef logic fill:#D5F5E3,stroke:#27AE60,color:#000;
    classDef contract fill:#FAD7A0,stroke:#E67E22,color:#000;
    classDef node fill:#E5E7E9,stroke:#95A5A6,color:#000;
    classDef external fill:#E8DAEF,stroke:#8E44AD,color:#000;
```
