# me-heer/affordable architecture

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

- Interactive diagram: https://gitdiagram.com/me-heer/affordable
- Repository: https://github.com/me-heer/affordable

## Overview

##### Main Components

A. Browser Components:
- Chrome Extension Popup UI
- Options Page
- Content Scripts
- Background Script
- Extension Storage

B. External Components:
- E-commerce Websites (Amazon, Flipkart, etc.)
- Chrome Web Store (distribution)

**User Interface Layer**

**Extension Core Layer**

**Website Integration Layer**

##### Component Details and Relationships

A. User Interface Components (Top Layer):
- Use rounded rectangles for UI components

B. Extension Core (Middle Layer):
- "Configuration Manager" (src/config.js)
- "Currency Handler" (src/lib/currency.js)

C. Website Integration (Bottom Layer):
- "Price Parser" subcomponent
- "DOM Manipulator" subcomponent
- Use rectangles for these components
- Supported e-commerce website logos as external systems

- Bidirectional communication between Background Script and Content Scripts
- Green: User interactions
- Blue: Internal communication
- Orange: External website interaction

##### Technical Details

- Chrome Extension APIs being used
- Content Script injection points
- Message passing between components
- Storage access patterns
- DOM manipulation flows

##### The configuration options and their impact on the system

Remember to indicate the asynchronous nature of content script injection and price updates, as this is crucial for the extension's performance on e-commerce websites.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#a8d1f0,stroke:#2c3e50
    classDef core fill:#f9d79b,stroke:#2c3e50
    classDef integration fill:#abebc6,stroke:#2c3e50
    classDef storage fill:#d2b4de,stroke:#2c3e50
    classDef external fill:#f2f3f4,stroke:#2c3e50

    %% User Interface Layer
    subgraph UI
        Popup["Chrome Extension Popup"]
        Options["Options Page"]
        Bootstrap["Bootstrap UI Components"]
        GlobalCSS["Global Styles"]
    end

    %% Core Layer
    subgraph Core
        Background["Background Script"]
        Config["Configuration Manager"]
        Currency["Currency Handler"]
        Main["Main Extension Logic"]
        Settings["Settings Management"]
    end

    %% Integration Layer
    subgraph Integration
        Content["Content Scripts"]
        subgraph ContentComponents
            PriceParser["Price Parser"]
            DOMManip["DOM Manipulator"]
        end
        Manifest["Extension Manifest"]
    end

    %% External Systems
    subgraph External
        Ecommerce["E-commerce Websites"]
        ChromeStore["Chrome Web Store"]
    end

    %% Storage
    Storage[("Extension Storage")]

    %% Relationships
    Popup --> Background
    Options --> Settings
    Background --> Content
    Content --> ContentComponents
    Config --> Background
    Currency --> Background
    Main --> Background
    Content --> Ecommerce
    Storage --> Background
    Storage --> Content
    Background --> Storage
    Settings --> Storage
    Bootstrap --> Popup
    Bootstrap --> Options
    GlobalCSS --> UI
    Manifest --> ChromeStore

    %% Click Events
    click Popup "https://github.com/me-heer/affordable/tree/master/src/popup/"
    click Options "https://github.com/me-heer/affordable/tree/master/src/options/"
    click Content "https://github.com/me-heer/affordable/blob/master/src/content.js"
    click Background "https://github.com/me-heer/affordable/blob/master/src/background.js"
    click Config "https://github.com/me-heer/affordable/blob/master/src/config.js"
    click Currency "https://github.com/me-heer/affordable/blob/master/src/lib/currency.js"
    click Main "https://github.com/me-heer/affordable/blob/master/src/main.js"
    click Manifest "https://github.com/me-heer/affordable/blob/master/src/manifest.json"
    click Settings "https://github.com/me-heer/affordable/blob/master/src/settingsPage.js"
    click GlobalCSS "https://github.com/me-heer/affordable/blob/master/src/main.css"
    click Bootstrap "https://github.com/me-heer/affordable/tree/master/src/bootstrap/"

    %% Style Applications
    class Popup,Options,Bootstrap,GlobalCSS ui
    class Background,Config,Currency,Main,Settings core
    class Content,PriceParser,DOMManip,Manifest integration
    class Storage storage
    class Ecommerce,ChromeStore external

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Core_L["Core Components"]:::core
        Int_L["Integration Components"]:::integration
        Store_L["Storage"]:::storage
        Ext_L["External Systems"]:::external
    end
```
