# godrums/betterfloat architecture

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

- Interactive diagram: https://gitdiagram.com/godrums/betterfloat
- Repository: https://github.com/godrums/betterfloat

## Overview

##### Main Components

a) Browser Extension Architecture:
- Popup Interface (src/popup/)
- Background Service (src/background/)
- Content Scripts (src/contents/)
- Shared Libraries (src/lib/)

b) External Systems:
- Multiple Marketplace APIs (CSFloat, Skinport, Skinbid, etc.)
- Browser Extension APIs

##### Key Architectural Elements

**┌─ Browser Extension ─────────────────────────────────────────┐**
- ┌─ UI Layer ─────┐  ┌─ Background ──┐  ┌─ Content Scripts ─┐│
- Popup          │  │ Message        │  │ Site-specific     ││
- Components   │  │ Handlers      │  │ Injection         ││
- Tabs         │  │ - Notifications│  │ - DOM Mutations  ││
- UI Elements  │  │ - Tab Control │  │ - API Intercepts  ││
- ┘  └───────────────┘  └─────────────────┘ ││
- ┌─ Shared Libraries ──────────────────────────────────────┐││
- Cache Handlers                                        │││
- Network Handlers                                      │││
- Event Handlers                                        │││
- Utility Functions                                     │││
- ┘│
- ┘

##### Specific Implementation Details

a) Message Passing System:
- How background/content scripts communicate
- Event handling system
- Cache management flow

b) Site Integration:
- Custom HTTP controller injection
- Mutation listener system
- UI enhancement injection points

c) Data Flow:
- Price fetching from multiple sources
- Currency conversion system
- Cache management
- Real-time updates

##### Important Relationships

- Content script interaction with marketplace websites
- Background service communication with BetterFloat's API
- Popup UI interaction with stored data
- Event propagation between components

##### Technical Stack Integration

Technology indicators:
- React for UI components
- TypeScript for type safety
- Plasmo framework structure
- shadcn/ui and Aceternity UI components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph BrowserExtension["Browser Extension Layer"]
        subgraph UILayer["UI Layer"]
            Popup["Popup Interface"]:::ui
            UIComponents["UI Components"]:::ui
            Tabs["Tab System"]:::ui
            BaseUI["Base UI Elements"]:::ui
            Layout["Layout System"]:::ui
        end

        subgraph BackgroundLayer["Background Layer"]
            Background["Background Service"]:::background
            MessageHandlers["Message Handlers"]:::background
            NotificationSystem["Notification System"]:::background
            TabControl["Tab Control"]:::background
        end

        subgraph ContentLayer["Content Scripts Layer"]
            ContentScripts["Content Scripts"]:::content
            CSFloatScript["CSFloat Script"]:::content
            SkinportScript["Skinport Script"]:::content
            InjectionHandler["Injection Handler"]:::content
        end

        subgraph SharedLibs["Shared Libraries Layer"]
            CacheManagement["Cache Management"]:::lib
            NetworkHandler["Network Handler"]:::lib
            EventHandler["Event Handler"]:::lib
            URLHandler["URL Handler"]:::lib
            WebSocketHandler["WebSocket Handler"]:::lib
        end

        subgraph Types["Type Definitions"]
            MarketplaceTypes["Marketplace Types"]:::types
            ExtensionTypes["Extension Types"]:::types
        end

        subgraph UIInjection["UI Injection Components"]
            CSFComponents["CSFloat Components"]:::injection
            SPComponents["Skinport Components"]:::injection
        end

        subgraph Utils["Utility Functions"]
            HelperFunctions["Helper Functions"]:::util
            StorageManagement["Storage Management"]:::util
            UIGeneration["UI Generation"]:::util
            SteamIntegration["Steam Integration"]:::util
        end
    end

    subgraph ExternalSystems["External Systems"]
        CSFloatAPI["CSFloat API"]:::external
        SkinportAPI["Skinport API"]:::external
        SkinbidAPI["Skinbid API"]:::external
        BetterFloatAPI["BetterFloat API"]:::external
        BrowserAPI["Browser Extension API"]:::external
    end

    %% Relationships
    Popup --> UIComponents
    Popup --> Tabs
    Popup --> BaseUI
    Popup --> Layout
    Background --> MessageHandlers
    Background --> NotificationSystem
    Background --> TabControl
    ContentScripts --> CSFloatScript
    ContentScripts --> SkinportScript
    ContentScripts --> InjectionHandler
    
    ContentScripts --> CSFComponents
    ContentScripts --> SPComponents
    
    Background --> SharedLibs
    ContentScripts --> SharedLibs
    Popup --> SharedLibs
    
    SharedLibs --> Utils
    
    ContentScripts --> ExternalSystems
    Background --> ExternalSystems
    
    MarketplaceTypes --> CSFloatScript
    MarketplaceTypes --> SkinportScript
    ExtensionTypes --> Background

    %% Click Events
    click Popup "https://github.com/GODrums/BetterFloat/tree/main/src/popup/"
    click UIComponents "https://github.com/GODrums/BetterFloat/tree/main/src/popup/components/"
    click Tabs "https://github.com/GODrums/BetterFloat/tree/main/src/popup/tabs/"
    click BaseUI "https://github.com/GODrums/BetterFloat/tree/main/src/popup/ui/"
    click Layout "https://github.com/GODrums/BetterFloat/tree/main/src/popup/layout/"
    click Background "https://github.com/GODrums/BetterFloat/tree/main/src/background/"
    click MessageHandlers "https://github.com/GODrums/BetterFloat/tree/main/src/background/messages/"
    click NotificationSystem "https://github.com/GODrums/BetterFloat/blob/main/src/background/messages/createNotification.ts"
    click TabControl "https://github.com/GODrums/BetterFloat/blob/main/src/background/messages/openTab.ts"
    click ContentScripts "https://github.com/GODrums/BetterFloat/tree/main/src/contents/"
    click CSFloatScript "https://github.com/GODrums/BetterFloat/blob/main/src/contents/csfloat_script.ts"
    click SkinportScript "https://github.com/GODrums/BetterFloat/blob/main/src/contents/skinport_script.ts"
    click InjectionHandler "https://github.com/GODrums/BetterFloat/blob/main/src/contents/injectionhandler.ts"
    click CacheManagement "https://github.com/GODrums/BetterFloat/tree/main/src/lib/handlers/cache/"
    click NetworkHandler "https://github.com/GODrums/BetterFloat/blob/main/src/lib/handlers/networkhandler.ts"
    click EventHandler "https://github.com/GODrums/BetterFloat/blob/main/src/lib/handlers/eventhandler.ts"
    click URLHandler "https://github.com/GODrums/BetterFloat/blob/main/src/lib/handlers/urlhandler.tsx"
    click WebSocketHandler "https://github.com/GODrums/BetterFloat/blob/main/src/lib/helpers/websockethandler.ts"
    click HelperFunctions "https://github.com/GODrums/BetterFloat/blob/main/src/lib/util/helperfunctions.ts"
    click StorageManagement "https://github.com/GODrums/BetterFloat/blob/main/src/lib/util/storage.ts"
    click UIGeneration "https://github.com/GODrums/BetterFloat/blob/main/src/lib/util/uigeneration.ts"
    click SteamIntegration "https://github.com/GODrums/BetterFloat/blob/main/src/lib/util/steam.ts"

    %% Styling
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef background fill:#4CAF50,stroke:#2E7D32,color:white
    classDef content fill:#FF9800,stroke:#F57C00,color:white
    classDef lib fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef types fill:#607D8B,stroke:#455A64,color:white
    classDef injection fill:#E91E63,stroke:#C2185B,color:white
    classDef util fill:#795548,stroke:#5D4037,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white

    %% Legend
    subgraph Legend
        UI["UI Components"]:::ui
        BG["Background Processes"]:::background
        CS["Content Scripts"]:::content
        LB["Shared Libraries"]:::lib
        TY["Types"]:::types
        IN["Injection Components"]:::injection
        UT["Utilities"]:::util
        EX["External Systems"]:::external
    end
```
