# harshau007/crowdfundx architecture

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

- Interactive diagram: https://gitdiagram.com/harshau007/crowdfundx
- Repository: https://github.com/harshau007/crowdfundx

## Overview

##### Main Components Identification
- Smart Contracts & Blockchain: Represent the contracts in the “contracts” directory. Include the Hardhat configuration (hardhat.config.ts), ignition modules (e.g., Lock.ts in ignition/modules), deployment scripts (scripts/deploy.ts and scripts/fastForwardTime.ts), and tests (in the test folder).
- Frontend Application: Represent the frontend folder which is structured as a Next.js application. Highlight directories such as:
- /src/app – This contains pages (e.g., campaign pages, contributions) plus API routes (e.g., API endpoint for “uploadToPinata”).
- /src/components – Modular UI components like CampaignCard, CampaignDetails, and other UI elements.
- /lib – Utility libraries for interacting with the smart contracts (e.g., contract.ts, utils.ts).
- External Services: Based on the API endpoint named “uploadToPinata” (found under frontend/src/app/api/uploadToPinata), note integration with external services such as Pinata for IPFS uploads or similar decentralized storage interactions.
- Build and Test Infrastructure: Capture the scripts used for deployment and time manipulation (scripts folder), the test configurations and scripts, and any build scripts dictated by the package.json at the root level or within the frontend.

##### Relationships and Interactions
- That the frontend interacts with the smart contracts via the utility functions (in frontend/src/lib/contract.ts) and possibly via blockchain APIs.
- API Layer in the Next.js app (under frontend/src/app/api) that handles operations like uploading to Pinata and may serve as wrappers for contract interactions.
- Flow of data from the UI components through the API routes to the blockchain and back (e.g., when creating or fetching campaign data).
- Testing and deployment paths: tests interact with the smart contracts directly, and deployment scripts (using Hardhat and Ignition modules) deploy the contracts to a local or test network.

##### Architectural Patterns and Technologies
- The project follows a layered architecture separating concerns between the smart contract backend and the Next.js frontend.
- It employs Infrastructure as Code principles via Hardhat, and testing is integral as seen with the test cases.
- Use of framework-specific configurations (e.g., tailwind.config, tsconfig.json, eslint configurations) emphasizes an organized approach to maintaining consistency in the frontend.
- Interaction with external IPFS/Pinata services suggests that the frontend might upload campaign images or metadata, linking blockchain data with decentralized storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Smart Contract Layer
    subgraph "Smart Contract Layer"
        SC1["Contracts"]:::smart
        SC2["Hardhat Config"]:::smart
        SC3["Ignition Modules"]:::smart
        SC4["Tests"]:::smart
        subgraph "Deployment & Testing"
            DS1["Deploy Script (deploy.ts)"]:::scripts
            DS2["Time Manipulation (fastForwardTime.ts)"]:::scripts
        end
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE1["Pages & Layouts"]:::frontend
        FE2["API Routes"]:::frontend
        FE3["UI Components"]:::frontend
        FE4["Utility Libraries"]:::frontend
    end

    %% External Services
    EX1["Pinata Service"]:::external

    %% Relationships in Frontend
    FE3 -->|"renders"| FE1
    FE1 -->|"calls"| FE2
    FE2 -->|"uses"| FE4

    %% Relationships between Frontend and Smart Contract Layer
    FE4 -->|"interacts with"| SC1

    %% External service interaction
    FE2 -->|"uploads to"| EX1

    %% Deployment and Testing relationships
    DS1 -->|"deploys to"| SC1
    DS2 -->|"manipulates time for"| SC1
    SC4 -->|"verifies"| SC1

    %% Styles
    classDef smart fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef scripts fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef frontend fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px;

    %% Click Events for Smart Contract Layer
    click SC1 "https://github.com/harshau007/crowdfundx/tree/main/contracts"
    click SC2 "https://github.com/harshau007/crowdfundx/blob/main/hardhat.config.ts"
    click SC3 "https://github.com/harshau007/crowdfundx/blob/main/ignition/modules/Lock.ts"
    click SC4 "https://github.com/harshau007/crowdfundx/tree/main/test"
    click DS1 "https://github.com/harshau007/crowdfundx/blob/main/scripts/deploy.ts"
    click DS2 "https://github.com/harshau007/crowdfundx/blob/main/scripts/fastForwardTime.ts"

    %% Click Events for Frontend Layer
    click FE1 "https://github.com/harshau007/crowdfundx/tree/main/frontend/src/app"
    click FE2 "https://github.com/harshau007/crowdfundx/blob/main/frontend/src/app/api/uploadToPinata/route.ts"
    click FE3 "https://github.com/harshau007/crowdfundx/tree/main/frontend/src/components"
    click FE4 "https://github.com/harshau007/crowdfundx/tree/main/frontend/src/lib"

    %% Click Event for External Service
    click EX1 "https://github.com/harshau007/crowdfundx/blob/main/frontend/src/app/api/uploadToPinata/route.ts"
```
