# arka7777/crowdfunding-dapp architecture

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

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

## Overview

##### Project Type and Purpose
- This is a full-stack decentralized application (“DApp”) for crowdfunding on the Avalanche Fuji Testnet.
- Frontend: React + Vite + Tailwind CSS, deployed on Vercel; blockchain interaction via Ethers.js and MetaMask.
- Smart Contracts: Solidity contracts (Crowdfunding.sol) tested in Remix IDE and deployed on Avalanche Fuji.

##### File Structure
Top-level:
- Client/ … (React app)
- smart Contracts/ … (Solidity source and any deployment scripts)

Inside Client/:
- public/, index.html – static assets and entry point
- src/
– App.jsx, main.jsx – React entry points
– components/ – UI components (Home, CreateCampaign, Explore, MyCampaigns, Navbar, Footer, Loading)
– context/contractContext.jsx – React Context for providing contract instance and wallet state
– abi/contractABI.json – the compiled contract interface used by Ethers.js
– assets/, index.css – styling and images

Config/Deployment files:
– package.json, vite.config.js, vercel.json – build and hosting settings
– eslint.config.js – lint rules

##### README for Additional Insights
The README confirms:
- Users connect MetaMask, create and fund campaigns, data lives on-chain.
- No off-chain database—state is managed by the Solidity contract.
- Smart contract maintains campaign structs, donor addresses, funding totals.

##### Main Components & Their Responsibilities
a. Client Browser & UI (React + Vite)
– Renders pages and components under src/components
– Loads configuration (contract address + ABI) from src/abi
– Uses contractContext to inject Web3 provider

b. Wallet / Web3 Provider
– MetaMask browser extension (user’s private key management)
– Injects window.ethereum API

c. Ethers.js Layer (in contractContext)
– Wraps Web3 provider, creates Contract instances via contract ABI & address
– Exposes methods: createCampaign, fundCampaign, fetchCampaigns

d. Avalanche Fuji Testnet (Blockchain Layer)
– Public RPC endpoints (e.g., https://api.avax-test.network/ext/bc/C/rpc)
– Hosts the deployed Crowdfunding.sol contract
– Persists state (campaign data, transactions)

e. Deployment & Development Tools
– Vercel (serves the static frontend)
– Remix IDE (contract authoring & testing)

##### Relationships & Data Flow
1. User opens the React app in browser (served by Vercel).
2. React UI calls methods from contractContext → Ethers.js
3. Ethers.js sends JSON-RPC requests via MetaMask to Avalanche Fuji.
4. Blockchain executes Crowdfunding.sol logic, updates state.
5. Event receipts and updated state propagate back to UI.

##### Essential Architectural Patterns
- DApp pattern: UI ↔ Web3 provider ↔ Blockchain
- React Context for dependency injection of the contract instance
- Component-based UI layering (Home, Explore, CreateCampaign, MyCampaigns)

##### Final Checklist
– All components (Frontend, Wallet, Ethers.js layer, Blockchain, Smart Contract) labeled
– Notes for external tools (Vercel, Remix) in supporting roles

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Client Side (Frontend)" 
        direction TB
        HTML["index.html"]:::frontend
        Boot["main.jsx (Bootstrapping)"]:::frontend
        App["App.jsx (React Entry)"]:::frontend
        Subcomponents["Components"]:::frontend
        CSS["index.css (Tailwind & Global Styles)"]:::frontend
        ABI["contractABI.json"]:::frontend
        Context["contractContext.jsx\n(Ethers.js / Web3 Context)"]:::web3
    end

    %% Components breakdown
    subgraph "UI Components" 
        direction TB
        Home["Home.jsx"]:::frontend
        Explore["Explore.jsx"]:::frontend
        Create["CreateCampaign.jsx"]:::frontend
        MyC["MyCampaigns.jsx"]:::frontend
        Nav["Navbar.jsx"]:::frontend
        Foot["Footer.jsx"]:::frontend
        Load["Loading.jsx"]:::frontend
    end

    %% Blockchain Flow
    MetaMask["MetaMask\n(window.ethereum)"]:::web3
    RPC["Avalanche Fuji RPC"]:::blockchain
    Contract["Crowdfunding.sol Contract"]:::storage

    %% Dev & Hosting Tools
    subgraph "Dev / Hosting Tools"
        direction TB
        ViteConf["vite.config.js"]:::tool
        ESLint["eslint.config.js"]:::tool
        Package["package.json"]:::tool
        Vercel["Vercel"]:::tool
        Remix["Remix IDE"]:::tool
    end

    %% Relationships
    HTML -->|loads| Boot
    Boot -->|renders| App
    App -->|renders| Subcomponents
    Subcomponents --> Home
    Subcomponents --> Explore
    Subcomponents --> Create
    Subcomponents --> MyC
    Subcomponents --> Nav
    Subcomponents --> Foot
    Subcomponents --> Load

    App -->|imports| ABI
    App -->|uses| Context
    Context -->|wraps| ABI
    Context -->|calls| MetaMask
    MetaMask -->|forwards JSON-RPC| RPC
    RPC -->|executes| Contract
    Contract -->|emits events| Context
    Context -->|updates| App

    %% Tools connections
    Boot -->|configured by| ViteConf
    App -->|linted by| ESLint
    App -->|managed by| Package
    HTML -->|deployed on| Vercel
    Contract -->|developed/tested in| Remix

    %% Click Events
    click Subcomponents "https://github.com/arka7777/crowdfunding-dapp/tree/main/Client/src/components"
    click Home "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/Home.jsx"
    click Explore "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/Explore.jsx"
    click Create "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/CreateCampaign.jsx"
    click MyC "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/MyCampaigns.jsx"
    click Nav "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/Navbar.jsx"
    click Foot "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/Footer.jsx"
    click Load "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/components/Loading.jsx"
    click App "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/App.jsx"
    click Boot "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/main.jsx"
    click HTML "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/index.html"
    click Context "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/context/contractContext.jsx"
    click ABI "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/abi/contractABI.json"
    click CSS "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/src/index.css"
    click ViteConf "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/vite.config.js"
    click ESLint "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/eslint.config.js"
    click Package "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/package.json"
    click Vercel "https://github.com/arka7777/crowdfunding-dapp/blob/main/Client/vercel.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0057B7,color:#000;
    classDef web3 fill:#DFFFE0,stroke:#2E7D32,color:#000;
    classDef blockchain fill:#FFF4C1,stroke:#F9A825,color:#000;
    classDef storage fill:#FFE0E0,stroke:#C62828,color:#000;
    classDef tool fill:#EEEEEE,stroke:#9E9E9E,color:#000;
```
