# availproject/bridge-ui architecture

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

- Interactive diagram: https://gitdiagram.com/availproject/bridge-ui
- Repository: https://github.com/availproject/bridge-ui

## Overview

##### Component Relationships

- User Interface → Hooks → Stores (State Management)
- Hooks → Services → Blockchain Networks
- API Routes → External Services
- MetaMask Integration ↔ Blockchain Networks

##### Specific Component Details

Frontend Components:
**┌─ UI Layer ─────────────────┐**
- Bridge Section          │
- Transaction Section     │
- Wallet Components       │
- Common UI Components    │
- ┘

State Management:
**┌─ Stores ──────────────────┐**
- Wallet Store           │
- Transaction Store      │
- Common Store           │
- Block Info Store       │
- ┘

Integration Layer:
**┌─ Services ────────────────┐**
- API Service            │
- Transaction Service    │
- Vector Pallet Service  │
- ┘

##### Additional Elements

- Version/environment indicators (test, staging, prod)
- Deployment flow as mentioned in README:
- Test → Preview Domains
- Staging → turing.bridge.avail.so
- Prod → bridge.availproject.org

##### Technical Stack Indicators

Badges/labels for:
- Next.js
- TypeScript
- Tailwind CSS
- MetaMask
- Ethereum
- Avail Network

Remember to include notes about the different deployment environments and their corresponding domains, as this is crucial for understanding the complete system architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[UI Components]
        Pages[Pages/Routes]
        Hooks[Hooks Layer]
        Stores[State Management]
    end

    subgraph Integration
        API[API Services]
        Services[Core Services]
        MetaMask[MetaMask Integration]
        Datadog[Datadog Monitoring]
    end

    subgraph Blockchain
        Ethereum[Ethereum Network]
        Avail[Avail Network]
        Contracts[Smart Contracts]
    end

    %% Frontend Details
    subgraph UI_Components
        Bridge["Bridge Section"]:::ui
        Transaction["Transaction Section"]:::ui
        Wallet["Wallet Components"]:::ui
        CommonUI["Common UI Elements"]:::ui
    end

    subgraph State_Management
        TransStore["Transaction Store"]:::store
        WalletStore["Wallet Store"]:::store
        CommonStore["Common Store"]:::store
        BlockStore["Block Info Store"]:::store
    end

    %% Integration Details
    subgraph Services_Layer
        APIService["API Service"]:::service
        TxService["Transaction Service"]:::service
        VectorService["Vector Pallet Service"]:::service
        TokenAPI["Token Price API"]:::service
    end

    %% Relationships
    UI --> Hooks
    Hooks --> Stores
    Hooks --> Services
    Services --> Blockchain
    API --> Services
    MetaMask <--> Blockchain
    Services --> Datadog

    %% Click Events
    click Bridge "https://github.com/availproject/bridge-ui/blob/main/components/sections/bridgesection.tsx"
    click Transaction "https://github.com/availproject/bridge-ui/blob/main/components/sections/transactionsection/index.tsx"
    click Wallet "https://github.com/availproject/bridge-ui/tree/main/components/wallets"
    click CommonUI "https://github.com/availproject/bridge-ui/tree/main/components/ui"
    click Pages "https://github.com/availproject/bridge-ui/blob/main/app/page.tsx"
    click TransStore "https://github.com/availproject/bridge-ui/blob/main/stores/transactionsStore.ts"
    click WalletStore "https://github.com/availproject/bridge-ui/blob/main/stores/availWalletHook.ts"
    click CommonStore "https://github.com/availproject/bridge-ui/blob/main/stores/common.ts"
    click BlockStore "https://github.com/availproject/bridge-ui/blob/main/stores/lastestBlockInfo.ts"
    click APIService "https://github.com/availproject/bridge-ui/blob/main/services/api.ts"
    click TxService "https://github.com/availproject/bridge-ui/blob/main/services/transactions.ts"
    click VectorService "https://github.com/availproject/bridge-ui/blob/main/services/vectorpallet.ts"
    click TokenAPI "https://github.com/availproject/bridge-ui/blob/main/app/api/getTokenPrice/route.ts"
    click MetaMask "https://github.com/availproject/bridge-ui/tree/main/hooks/Metamask"
    click Contracts "https://github.com/availproject/bridge-ui/tree/main/constants/abis"
    click Datadog "https://github.com/availproject/bridge-ui/blob/main/app/datadog-init.tsx"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef store fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#e74c3c,stroke:#c0392b,color:white
    classDef blockchain fill:#f1c40f,stroke:#f39c12,color:black
    classDef monitoring fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Store_L["State Management"]:::store
        Service_L["Services"]:::service
        Blockchain_L["Blockchain"]:::blockchain
        Monitoring_L["Monitoring"]:::monitoring
    end
```
