# symaticvisuals/betos-fe architecture

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

- Interactive diagram: https://gitdiagram.com/symaticvisuals/betos-fe
- Repository: https://github.com/symaticvisuals/betos-fe

## Overview

##### Main Components

A. Frontend Layer (Next.js Application)
- Client-side Components (/src/components)
- Pages and Routes (/src/app)
- Wallet Integration (/src/components/common/wallet.provider.tsx)
- UI Components (/src/components/ui)

B. Blockchain Integration Layer
- Aptos Integration (/src/lib/aptos.ts)
- Keyless Authentication (/src/lib/core/keyless.ts)
- Wallet Hooks (/src/hooks/use-aptos-wallet.tsx)

C. External Services
- Switchboard Oracles (for match data)
- RapidAPI Football Data
- Panora Integration
- Kana Labs Integration

D. Smart Contracts Layer (referenced but not in this repo)
- Betting Contracts
- Market Creation
- Payout System

**[User Interface Layer]**

**[Frontend Application Layer]**

**[Blockchain Integration Layer]**

**[Smart Contracts Layer]**

**[External Services Layer]**

##### Key Relationships to Highlight

a. User Flow:
- Wallet Connection → Authentication → Betting Interface
- Match Selection → Odds Display → Bet Placement → Payout

b. Data Flow:
- External APIs → Backend → Frontend
- Smart Contracts ↔ Oracle Data
- Wallet ↔ Transaction Processing

##### Specific Implementation Details

- Keyless sign-in implementation (/src/lib/core/keyless.ts)
- Wallet integration patterns (/src/components/common/wallet.provider.tsx)
- Match data handling (/src/components/common/match-cards.tsx)
- Balance management (/src/hooks/use-account-balance.tsx)

##### Component Interactions

- Frontend ↔ Aptos Blockchain
- Smart Contracts ↔ Oracles
- User Interface ↔ Wallet Provider

##### Additional Elements

Include:
- Authentication flow
- Transaction processing pipeline
- Real-time data updates
- Error handling paths

##### Notes for Implementation

- Keep the main flow clear and centered
- Related components together
- Use consistent spacing and alignment
- Version/environment indicators
- Important configuration notes

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        WS["Wallet Selector"]
        AC["Auto Connect"]
        MC["Match Cards"]
        MCH["Match Cards Home"]
        TC["Team Cards"]
        SS["Select Side"]
        WStats["Winning Stats"]
        WStatsH["Winning Stats Home"]
        BAL["Balance Display"]
    end

    subgraph FA["Frontend Application Layer"]
        Pages["Pages & Routes"]
        UIComp["UI Components"]
        CommonComp["Common Components"]
        WP["Wallet Provider"]
    end

    subgraph BI["Blockchain Integration Layer"]
        AptosInt["Aptos Integration"]
        AptosCtx["Aptos Context"]
        WalletHooks["Wallet Hooks"]
        KeylessImpl["Keyless Implementation"]
        KeylessCtx["Keyless Context"]
        AuthUtils["Authentication Utils"]
        AccBalance["Account Balance Hook"]
    end

    subgraph Core["Core Layer"]
        Constants["Constants"]
        Types["Types"]
        Utils["Utilities"]
    end

    subgraph EX["External Services"]
        SwitchOracle["Switchboard Oracles"]
        RapidAPI["RapidAPI Football"]
        Panora["Panora Integration"]
        KanaLabs["Kana Labs"]
    end

    subgraph SC["Smart Contracts Layer"]
        BetContracts["Betting Contracts"]
        MarketCreation["Market Creation"]
        PayoutSystem["Payout System"]
    end

    %% Relationships
    UI --> FA
    FA --> BI
    BI --> SC
    SC <--> EX
    Core --> FA
    Core --> BI

    %% Click events
    click Pages "https://github.com/symaticvisuals/betos-fe/tree/main/src/app"
    click UIComp "https://github.com/symaticvisuals/betos-fe/tree/main/src/components/ui"
    click CommonComp "https://github.com/symaticvisuals/betos-fe/tree/main/src/components/common"
    click WP "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/wallet.provider.tsx"
    click WS "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/wallet-selector.tsx"
    click AC "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/auto-connect-wallet.tsx"
    click AptosInt "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/aptos.ts"
    click AptosCtx "https://github.com/symaticvisuals/betos-fe/blob/main/src/contexts/aptos-context.tsx"
    click WalletHooks "https://github.com/symaticvisuals/betos-fe/blob/main/src/hooks/use-aptos-wallet.tsx"
    click KeylessImpl "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/core/keyless.ts"
    click KeylessCtx "https://github.com/symaticvisuals/betos-fe/blob/main/src/contexts/keyless-contect.tsx"
    click AuthUtils "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/core/utils.ts"
    click MC "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/match-cards.tsx"
    click MCH "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/match-cards-home.tsx"
    click TC "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/team-card-home.tsx"
    click SS "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/select-side.tsx"
    click BAL "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/balance.tsx"
    click AccBalance "https://github.com/symaticvisuals/betos-fe/blob/main/src/hooks/use-account-balance.tsx"
    click WStats "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/winning-stats.tsx"
    click WStatsH "https://github.com/symaticvisuals/betos-fe/blob/main/src/components/common/winning-stats-home.tsx"
    click Constants "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/core/constants.ts"
    click Types "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/core/types.ts"
    click Utils "https://github.com/symaticvisuals/betos-fe/blob/main/src/lib/utils.ts"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef blockchain fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#FF9800,stroke:#EF6C00,color:white
    classDef smart fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef core fill:#607D8B,stroke:#37474F,color:white

    class UI,FA,Pages,UIComp,CommonComp,WP,WS,AC,MC,MCH,TC,SS,WStats,WStatsH,BAL frontend
    class BI,AptosInt,AptosCtx,WalletHooks,KeylessImpl,KeylessCtx,AuthUtils,AccBalance blockchain
    class EX,SwitchOracle,RapidAPI,Panora,KanaLabs external
    class SC,BetContracts,MarketCreation,PayoutSystem smart
    class Core,Constants,Types,Utils core
```
