# iamabhishekgawali/crowdfunding architecture

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

- Interactive diagram: https://gitdiagram.com/iamabhishekgawali/crowdfunding
- Repository: https://github.com/iamabhishekgawali/crowdfunding

## Overview

##### Project type and purpose
- Fundchain is a full-stack decentralized application (dApp) for crowdfunding on Ethereum.
- The React front-end ("client/fundchain") interacts directly with smart contracts deployed via Hardhat on an Ethereum network.

##### File structure
- Top-level directories:
- client/fundchain: React app (UI components, styles, context, utils)
- contracts: Solidity smart contract sources (Campaign.sol, CampaignFactory.sol)
- scripts: Hardhat deploy script (scripts/deploy.js)
- test: Smart contract tests (test/Lock.js)
- Key config files: hardhat.config.js, package.json (both root and client).
- No traditional centralized “backend”—the blockchain replaces it.

##### README
- Describes a user flow: connect MetaMask, view campaigns, contribute, see confetti, handle withdrawal requests.
- No server-side API—front-end talks to Ethereum via MetaMask/Ethers.js.

##### Detailed breakdown of components
- React UI Layer:
- Components folder (pages & widgets)
- Context layer (WalletContext)
- Utils folder (ABI JSON, constants)
- Blockchain Layer:
- CampaignFactory contract
- Campaign contract
- Infrastructure/Tooling Layer:
- Hardhat node & config
- Deploy script (scripts/deploy.js)
- Tests (test/Lock.js)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actor
    MetaMask["MetaMask Wallet"]:::external

    subgraph "React UI Layer"
        direction TB
        UI["React UI<br/>(client/fundchain/src)"]:::frontend
        App["App.js"]:::frontend
        Components["Components<br/>(client/fundchain/src/Components)"]:::frontend
        ConnectWallet["ConnectWallet.jsx"]:::frontend
        WalletContext["WalletContext.jsx"]:::frontend
        Constants["constant.js"]:::frontend
        ABI1["Campaign.json"]:::frontend
        ABI2["CampaignFactory.json"]:::frontend
    end

    subgraph "Blockchain Layer"
        direction TB
        Network["Ethereum Network"]:::onchain
        FactoryContract["CampaignFactory.sol"]:::onchain
        CampaignContract["Campaign.sol"]:::onchain
    end

    subgraph "Tooling Layer"
        direction TB
        HardhatConfig["hardhat.config.js"]:::tooling
        DeployScript["deploy.js"]:::tooling
        Tests["Lock.js (Test)"]:::tooling
        RootPkg["package.json (root)"]:::tooling
        ClientPkg["package.json (client)"]:::tooling
    end

    %% Flows
    UI -->|"connect() / requestTx"| MetaMask
    MetaMask -->|"provider"| UI
    UI -->|"uses Ethers.js"| Constants
    UI -->|"load ABI"| ABI1
    UI -->|"load ABI"| ABI2
    UI -->|"createCampaign(), contribute()"| Network
    Network -->|"processTx"| FactoryContract
    Network -->|"processTx"| CampaignContract
    FactoryContract -->|"emit CampaignCreated"| UI
    CampaignContract -->|"emit ContributionReceived"| UI

    %% Tooling flows
    DeployScript -.->|"deploy()"| Network
    Tests -.->|"simulateTx"| Network
    HardhatConfig -.-> Network

    %% Click Events
    click UI "https://github.com/iamabhishekgawali/crowdfunding/tree/master/client/fundchain/src"
    click App "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/App.js"
    click Components "https://github.com/iamabhishekgawali/crowdfunding/tree/master/client/fundchain/src/Components"
    click ConnectWallet "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/Components/ConnectWallet.jsx"
    click WalletContext "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/Context/WalletContext.jsx"
    click Constants "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/utils/constant.js"
    click ABI1 "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/utils/Campaign.json"
    click ABI2 "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/src/utils/CampaignFactory.json"
    click FactoryContract "https://github.com/iamabhishekgawali/crowdfunding/blob/master/contracts/CampaignFactory.sol"
    click CampaignContract "https://github.com/iamabhishekgawali/crowdfunding/blob/master/contracts/Campaign.sol"
    click HardhatConfig "https://github.com/iamabhishekgawali/crowdfunding/blob/master/hardhat.config.js"
    click DeployScript "https://github.com/iamabhishekgawali/crowdfunding/blob/master/scripts/deploy.js"
    click Tests "https://github.com/iamabhishekgawali/crowdfunding/blob/master/test/Lock.js"
    click RootPkg "https://github.com/iamabhishekgawali/crowdfunding/blob/master/package.json"
    click ClientPkg "https://github.com/iamabhishekgawali/crowdfunding/blob/master/client/fundchain/package.json"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#333,stroke-width:1px
    classDef onchain fill:#90ee90,stroke:#333,stroke-width:1px
    classDef tooling fill:#ffd580,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
```
