# ganesh0324/blackchain architecture

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

- Interactive diagram: https://gitdiagram.com/ganesh0324/blackchain
- Repository: https://github.com/ganesh0324/blackchain

## Overview

##### Project type and purpose
- From the README (“BlackChain: A Blockchain X Social Media Initiative”) and the file tree, this is a Web3 social-media DApp:
- A Next.js/React frontend under `frontend/`
- On-chain Move smart contract(s) under `contracts/black_contract` deployed to the Sui blockchain (see `sui.config.ts`)
- Deployment & initialization scripts in `scripts/`
- No traditional backend server—UI talks directly to Sui via RPC and a wallet provider

##### File structure
- Top-level:
- `contracts/black_contract`: Move source, tests, Toml lock, and deployment artifacts
- `frontend/`: React/Next.js app (pages, components, hooks, lib, config)
- `scripts/`: TypeScript scripts (`faucet.ts`, `initialize.ts`, plus a shell publish script)
- `sui.config.ts`: Sui chain configuration
- Patterns:
- Frontend follows Next.js 13 App Router (`app/`) with React components, hooks, and CSS + Tailwind configs
- Smart-contract project using Move language and Sui-native tooling (Move.toml, Move.lock)
- Dev/deploy files:
- `scripts/*` for on-chain contract deployment & testnet faucet funding
- `sui.config.ts` for RPC endpoints, network names, and default package path

##### README
- Minimal README, but name and file tree strongly imply Web3 social feed on Sui

##### Elements
- “User Browser & Wallet Extension”
- “Wallet Provider Adapter”
- “Sui RPC Node” (external service)
- “Move Smart Contract (black_contract)”
- “Deployment Scripts / CI”
- UI → Wallet Provider → RPC Node → Smart Contract → RPC Node → UI
- Deployment Scripts → RPC Node → Smart Contract
- Blue for frontend components
- Green for blockchain on-chain elements
- Orange for external services (RPC nodes, ZK login service)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["User Browser & Wallet Extension"]:::external
        subgraph "Next.js Frontend"
            Components["UI Components"]:::frontend
            subgraph "Hooks"
                RecentStatuses["useRecentStatuses"]:::frontend
                ToastHook["use-toast"]:::frontend
            end
            subgraph "Lib"
                API["sui-api (RPC calls)"]:::frontend
                NetworkCfg["networkConfig"]:::frontend
                ZKLogin["zklogin (ZK Login Integration)"]:::frontend
            end
        end
    end

    %% Wallet Integration
    subgraph "Wallet Integration"
        WalletAdapter["Wallet Provider Adapter"]:::frontend
    end

    %% Blockchain & External Services
    subgraph "Blockchain API & Services"
        RPCNode["Sui RPC Node"]:::external
    end

    %% On-chain Layer
    subgraph "On-chain Layer"
        SmartContract["Move Smart Contract (black_contract)"]:::blockchain
    end

    %% Deployment Scripts / CI
    subgraph "Deployment Scripts / CI"
        Faucet["Faucet Funding Script"]:::scripts
        InitScript["Contract Initialization Script"]:::scripts
        Publish["Publish/Deployment Shell Script"]:::scripts
        SuiConfig["Sui Config (sui.config.ts)"]:::scripts
    end

    %% Connections
    Browser -->|"interacts"| Components
    Components --> RecentStatuses
    Components --> ToastHook
    RecentStatuses --> API
    ToastHook --> API
    API --> WalletAdapter
    NetworkCfg --> API
    ZKLogin --> API
    API --> RPCNode
    WalletAdapter -->|"sign Tx"| RPCNode
    RPCNode -->|"submit Tx"| SmartContract
    SmartContract -->|"return state"| RPCNode
    RPCNode -->|"query state"| API
    SuiConfig --> RPCNode

    Faucet --> RPCNode
    InitScript --> RPCNode
    Publish --> RPCNode
    Publish --> SmartContract

    %% Click Events
    click Components "https://github.com/ganesh0324/blackchain/tree/main/frontend/components/"
    click RecentStatuses "https://github.com/ganesh0324/blackchain/blob/main/frontend/hooks/useRecentStatuses.tsx"
    click ToastHook "https://github.com/ganesh0324/blackchain/blob/main/frontend/hooks/use-toast.tsx"
    click API "https://github.com/ganesh0324/blackchain/blob/main/frontend/lib/sui-api.ts"
    click NetworkCfg "https://github.com/ganesh0324/blackchain/blob/main/frontend/lib/networkConfig.ts"
    click ZKLogin "https://github.com/ganesh0324/blackchain/blob/main/frontend/lib/zklogin.ts"
    click WalletAdapter "https://github.com/ganesh0324/blackchain/blob/main/frontend/components/WallerProviderWrapper.tsx"
    click SmartContract "https://github.com/ganesh0324/blackchain/tree/main/contracts/black_contract/"
    click Faucet "https://github.com/ganesh0324/blackchain/blob/main/scripts/faucet.ts"
    click InitScript "https://github.com/ganesh0324/blackchain/blob/main/scripts/initialize.ts"
    click Publish "https://github.com/ganesh0324/blackchain/blob/main/scripts/publish.sh"
    click SuiConfig "https://github.com/ganesh0324/blackchain/blob/main/sui.config.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef blockchain fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFD580,stroke:#333,stroke-width:1px
    classDef scripts fill:#FDEBD0,stroke:#333,stroke-width:1px
```
