# eclipse-laboratories-inc/eclipse-bridge-ux architecture

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

- Interactive diagram: https://gitdiagram.com/eclipse-laboratories-inc/eclipse-bridge-ux
- Repository: https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux

## Overview

##### Project type and purpose
- This is a Next.js 13 “App Router” full-stack React application.
- It provides a UI for bridging tokens (Ethereum, Solana, tETH mint-redeem flows, gas-station, third-party bridges) and exposes a small backend via Next.js API routes under `app/api/*`.
- It integrates with blockchain RPCs (Ethereum, Solana), smart-contracts (via ABIs in `mint-teth/abis` and `app/components/constants/abi.json`), third-party bridge endpoints, and instrumentation/telemetry services.

##### File structure
- Top-level:
- `app/` – Next.js App Router directories: pages (`page.tsx`), layouts (`layout.tsx`), API routes (`app/api/.../route.ts`), error handling (`global-error.tsx`).
- `app/contexts` & `app/context.tsx` – React contexts for network, sidebar, wallets.
- `app/hooks` – Domain hooks (wallet management, gas-station modal, transactions).
- `app/providers` – Providers for Wagmi (Ethereum), RelayKit, Gas Providers, Dynamic configuration.
- `app/bridge`, `app/gas-station`, `app/mint-teth` – Feature modules with pages, components, constants, hooks, utils.
- `lib/` – Shared utility libraries (network, price, relay, solana, withdraw, wallet client).
- `public/` – Static assets (fonts, thirdparty-bridges JSON).
- Config: `next.config.js`, `tsconfig.json`, `.env.example`, Tailwind, ESLint, GitHub workflows.
- Architectural patterns:
- React component hierarchy with a global layout.
- Context + Provider pattern for dependency injection.
- Feature-based module folders (`bridge`, `gas-station`, `mint-teth`).
- Next.js API routes for server-side data fetching/relay.

##### Key insights from README
- Standard Next.js setup; uses `next/font` to optimize custom fonts.
- Deployed typically on Vercel; no external DB—state is on-chain or in‐memory on the client.

##### Detailed coverage
- Break the Next.js Server block into sub-blocks:
- App Router (Pages + Layouts)
- API Routes (`/api/ethereum-data`, `/api/get-transactions`)
- Middleware & Error boundary (`global-error.tsx`)
- Under the Client block, illustrate the Context/Provider stack:
- WagmiProvider → RelayKitProvider → GasProviders → DynamicProvider → NetworkContext
- Under Feature modules, group each user flow:
- Deposit/Withdraw
- Gas Station
- Mint & Redeem tETH

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client (Browser)"
        Browser["Browser"]:::external
        subgraph "UI Layer"
            ReactUI["React UI Layer"]:::frontend
            PageUI["app/page.tsx"]:::internal
            BridgeUI["app/bridge/page.tsx"]:::internal
            GasUI["app/gas-station/page.tsx"]:::internal
            MintUI["app/mint-teth/page.tsx"]:::internal
            ErrorUI["app/global-error.tsx"]:::internal
            ClientLayout["app/client-layout.tsx"]:::internal
        end
        subgraph "Components"
            Deposit["Deposit & Withdraw"]:::component
            GasStationComp["GasStation"]:::component
            ThirdpartyModal["ThirdpartyBridgeModal"]:::component
            Header["Header"]:::component
            Sidebar["Sidebar"]:::component
            TxPool["TransactionPool"]:::component
            ABIConst["ABI Constants"]:::component
        end
        subgraph "Context & Providers"
            NetworkCtx["NetworkContext"]:::context
            SidebarCtx["SidebarContext"]:::context
            AppContext["app/context.tsx"]:::context
            WagmiProv["wagmiProvider.tsx"]:::provider
            RelayProv["RelayKitProvider.tsx"]:::provider
            GasProv["GasProviders.tsx"]:::provider
            DynProv["DynamicProvider.tsx"]:::provider
            AllProv["providers.tsx"]:::provider
        end
        Hooks["Domain Hooks"]:::hook
    end

    %% Server Side
    subgraph "Server (Next.js)"
        subgraph "App Router"
            Layout["app/layout.tsx"]:::internal
            GlobalError["app/global-error.tsx"]:::internal
            BridgePageServer["app/bridge/page.tsx"]:::internal
            GasPageServer["app/gas-station/page.tsx"]:::internal
            GasLayout["app/gas-station/layout.tsx"]:::internal
            MintPageServer["app/mint-teth/page.tsx"]:::internal
        end
        subgraph "API Routes"
            EthData["/api/ethereum-data"]:::api
            GetTx["/api/get-transactions"]:::api
        end
    end

    %% Shared Utilities
    subgraph "Shared Utilities (lib)"
        NetUtil["lib/networkUtils.ts"]:::util
        PriceUtil["lib/priceUtils.ts"]:::util
        RelayUtil["lib/relay.ts"]:::util
        SolUtil["lib/solanaUtils.ts"]:::util
        EthUtil["lib/ethUtils.ts"]:::util
        WithdrawUtil["lib/withdrawUtils.ts"]:::util
        WalletClient["lib/walletClient.ts"]:::util
    end

    %% External Services
    EthereumRPC[(Ethereum JSON-RPC)]:::db
    SolanaRPC[(Solana RPC)]:::db
    SmartContracts[(Smart Contract ABIs)]:::db
    ThirdPartyBridges[[Third-Party Bridge APIs]]:::cloud
    Telemetry[[Telemetry Service]]:::cloud
    StaticAssets{{Static Assets CDN}}:::hex

    %% Relationships
    Browser -->|"loads UI"| ReactUI
    Browser -->|"requests page"| Layout
    Browser -->|"fetches static"| StaticAssets
    Browser -->|"calls API"| EthData
    Browser -->|"calls API"| GetTx

    ReactUI -->|"renders"| PageUI
    ReactUI -->|"renders"| BridgeUI
    ReactUI -->|"renders"| GasUI
    ReactUI -->|"renders"| MintUI
    ReactUI -->|"uses"| Components
    Components -->|"calls"| Hooks
    Hooks -->|"invokes"| WagmiProv
    Hooks -->|"invokes"| RelayProv
    Hooks -->|"invokes"| GasProv
    Hooks -->|"invokes"| DynProv
    Hooks -->|"invokes"| AllProv
    Hooks -->|"uses"| NetUtil
    Hooks -->|"uses"| PriceUtil
    Hooks -->|"uses"| RelayUtil
    Hooks -->|"uses"| SolUtil
    Hooks -->|"uses"| EthUtil
    Hooks -->|"uses"| WithdrawUtil
    Hooks -->|"uses"| WalletClient

    WagmiProv -->|"RPC calls"| EthereumRPC
    RelayProv -->|"relay tx"| EthereumRPC
    GasProv -->|"RPC calls"| EthereumRPC
    DynProv -->|"RPC calls"| SolanaRPC
    DynProv -->|"reads ABIs"| SmartContracts

    EthData -->|"JSON-RPC"| EthereumRPC
    EthData -->|"HTTP"| ThirdPartyBridges
    GetTx -->|"JSON-RPC"| EthereumRPC

    Layout -->|"SSR"| ReactUI
    BridgePageServer -->|"SSR"| BridgeUI
    GasPageServer -->|"SSR"| GasUI
    MintPageServer -->|"SSR"| MintUI

    %% Telemetry
    ReactUI -->|"events"| Telemetry
    EthData -->|"logs"| Telemetry
    GetTx -->|"logs"| Telemetry
    Layout -->|"errors"| Telemetry

    %% Click Events
    click PageUI "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/page.tsx"
    click BridgeUI "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/bridge/page.tsx"
    click GasUI "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/gas-station/page.tsx"
    click MintUI "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/mint-teth/page.tsx"
    click ErrorUI "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/global-error.tsx"
    click ClientLayout "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/client-layout.tsx"
    click Layout "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/layout.tsx"
    click BridgePageServer "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/bridge/page.tsx"
    click GasPageServer "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/gas-station/page.tsx"
    click GasLayout "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/gas-station/layout.tsx"
    click MintPageServer "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/mint-teth/page.tsx"
    click EthData "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/api/ethereum-data/route.ts"
    click GetTx "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/api/get-transactions/route.ts"
    click Deposit "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/Deposit"
    click GasStationComp "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/GasStation"
    click ThirdpartyModal "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/ThirdpartyBridgeModal"
    click Header "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/Header"
    click Sidebar "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/Sidebar"
    click TxPool "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/tree/eclipse-apps/app/components/TransactionPool"
    click ABIConst "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/components/constants/abi.json"
    click NetworkCtx "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/contexts/NetworkContext.tsx"
    click SidebarCtx "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/contexts/SidebarContext.tsx"
    click AppContext "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/context.tsx"
    click WagmiProv "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/providers/wagmiProvider.tsx"
    click RelayProv "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/providers/RelayKitProvider.tsx"
    click GasProv "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/providers/GasProviders.tsx"
    click DynProv "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/providers/DynamicProvider.tsx"
    click AllProv "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/app/providers/providers.tsx"
    click NetUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/networkUtils.ts"
    click PriceUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/priceUtils.ts"
    click RelayUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/relay.ts"
    click SolUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/solanaUtils.ts"
    click EthUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/ethUtils.ts"
    click WithdrawUtil "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/withdrawUtils.ts"
    click WalletClient "https://github.com/eclipse-laboratories-inc/eclipse-bridge-ux/blob/eclipse-apps/lib/walletClient.ts"

    %% Styles
    classDef internal fill:#e3f2fd,stroke:#1e88e5
    classDef frontend fill:#e8f5e9,stroke:#43a047
    classDef component fill:#fff3e0,stroke:#fb8c00
    classDef context fill:#f3e5f5,stroke:#8e24aa
    classDef provider fill:#ede7f6,stroke:#5e35b1
    classDef hook fill:#e0f7fa,stroke:#00838f
    classDef api fill:#ffebee,stroke:#e53935
    classDef util fill:#f9fbe7,stroke:#c0ca33
    classDef db fill:#ffecb3,stroke:#ffb300
    classDef cloud fill:#e1f5fe,stroke:#039be5
    classDef hex fill:#fce4ec,stroke:#d81b60
    classDef external fill:#ffffff,stroke:#000000,stroke-width:1px
```
