# dappuniversity/fun-pump architecture

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

- Interactive diagram: https://gitdiagram.com/dappuniversity/fun-pump
- Repository: https://github.com/dappuniversity/fun-pump

## Overview

##### Main Components
a. Frontend (Next.js App)
- Located under app/: React/Next.js pages (layout.js, page.js) and components (Header.js, List.js, Token.js, Trade.js).
- Static/config assets: globals.css, config.json, images.json, public/.
- ABI artifacts under app/abis/ (Factory.json).
b. Smart Contracts
- Solidity sources in contracts/
- Compiled ABIs used by frontend.
c. Blockchain Node & Deployment
- Hardhat local node (npx hardhat node).
- Deployment scripts via Hardhat-Ignition in ignition/modules/Factory.js.
d. Tests
- Test suite under test/ (Factory.js) using Hardhat & Ethers.js.
e. Tooling & Config
- Hardhat config: hardhat.config.js
- Next.js config: next.config.mjs, jsconfig.json
- package.json / package-lock.json

##### Relationships & Data Flow
- User → Browser → Next.js UI (React components)
- UI uses Ethers.js to load Factory.json ABI and connect to a JSON-RPC endpoint.
- JSON-RPC endpoint is the Hardhat node (local blockchain emulator).
- Hardhat node processes transactions, invokes the Factory.sol contract on the EVM.
- Deployment script (Ignition) runs on the dev machine, calls Hardhat network to deploy Factory.sol, writes the deployed address into app/abis/Factory.json or config.json.
- Tests also connect via Ethers.js to Hardhat node, exercise Factory.sol.

##### Architectural Patterns & Key Technologies
- Pattern: Single-Page Application (Next.js) + Backendless blockchain layer
- Components: Presentation (React), Data Access (Ethers.js & ABIs), Smart Contract Business Logic (Solidity)
- Deployment: Infrastructure-as-Code via Hardhat-Ignition
- Testing: Automated unit/integration tests under Hardhat framework
- Config & Assets: Centralized under app/config.json, images.json, public/

##### Essential Elements
- Clear, concise labels (e.g., “Next.js UI”, “Hardhat JSON-RPC”).
- Blue = Client/UI layer
- Green = Blockchain/EVM layer
- Orange = Tooling (deployment & testing)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Client/UI Layer"
        direction TB
        UI["User Browser\n(Next.js UI)"]:::frontend
        Layout["layout.js"]:::frontend
        Page["page.js"]:::frontend
        Header["Header.js"]:::frontend
        List["List.js"]:::frontend
        Token["Token.js"]:::frontend
        Trade["Trade.js"]:::frontend
        Globals["globals.css"]:::frontend
        Config["config.json"]:::frontend
        Images["images.json"]:::frontend
        Public["public/"]:::frontend
        ABI["Factory.json"]:::frontend
    end

    %% Blockchain Layer
    subgraph "Blockchain Layer"
        direction TB
        Node["Hardhat Node\n(JSON-RPC)"]:::blockchain
        Contract["Factory.sol\n(Smart Contract)"]:::blockchain
    end

    %% Tooling & Config
    subgraph "Tooling & Config"
        direction TB
        HardhatConfig["hardhat.config.js"]:::tool
        NextConfig["next.config.mjs\njsconfig.json"]:::tool
        Packages["package.json\npackage-lock.json"]:::tool
        RepoMeta["README.md\n.gitignore"]:::tool
        Deploy["Factory Deployment\n(ignition/modules/Factory.js)"]:::tool
        Tests["Factory Tests\n(test/Factory.js)"]:::tool
    end

    %% Connections
    UI -->|"uses React/UI" | Layout
    UI --> Page
    Layout --> Header
    Layout --> List
    Layout --> Token
    Layout --> Trade
    UI --> Globals
    UI --> Config
    UI --> Images
    UI --> Public
    UI --> ABI
    UI -->|"Ethers.js RPC calls"| Node
    Node -->|"deploy & call"| Contract
    Deploy -->|"deploys via RPC"| Node
    Tests -->|"tests via RPC"| Node

    %% Click Events
    click Layout "https://github.com/dappuniversity/fun-pump/blob/main/app/layout.js"
    click Page "https://github.com/dappuniversity/fun-pump/blob/main/app/page.js"
    click Header "https://github.com/dappuniversity/fun-pump/blob/main/app/components/Header.js"
    click List "https://github.com/dappuniversity/fun-pump/blob/main/app/components/List.js"
    click Token "https://github.com/dappuniversity/fun-pump/blob/main/app/components/Token.js"
    click Trade "https://github.com/dappuniversity/fun-pump/blob/main/app/components/Trade.js"
    click Globals "https://github.com/dappuniversity/fun-pump/blob/main/app/globals.css"
    click Config "https://github.com/dappuniversity/fun-pump/blob/main/app/config.json"
    click Images "https://github.com/dappuniversity/fun-pump/blob/main/app/images.json"
    click Public "https://github.com/dappuniversity/fun-pump/tree/main/public/"
    click ABI "https://github.com/dappuniversity/fun-pump/blob/main/app/abis/Factory.json"
    click Contract "https://github.com/dappuniversity/fun-pump/tree/main/contracts/"
    click HardhatConfig "https://github.com/dappuniversity/fun-pump/blob/main/hardhat.config.js"
    click Deploy "https://github.com/dappuniversity/fun-pump/blob/main/ignition/modules/Factory.js"
    click Tests "https://github.com/dappuniversity/fun-pump/blob/main/test/Factory.js"
    click NextConfig "https://github.com/dappuniversity/fun-pump/blob/main/next.config.mjs"
    click Packages "https://github.com/dappuniversity/fun-pump/blob/main/package.json"
    click RepoMeta "https://github.com/dappuniversity/fun-pump/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0066CC,color:#000000
    classDef blockchain fill:#DFFFD0,stroke:#33AA00,color:#000000
    classDef tool fill:#FFE8B0,stroke:#CC6600,color:#000000
```
