# ryah/rosie-addon-suite architecture

> Architecture diagram of the GitHub repository ryah/rosie-addon-suite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ryah/rosie-addon-suite
- Repository: https://github.com/ryah/rosie-addon-suite

## Overview

##### Main Components
- User Script (main.user.js): This is the core file that Tampermonkey installs and runs. It coordinates all the enhancements.
- Utility/Helper Library (js/waitForKeyElements_offline.js): A helper script used to wait for specific DOM elements before executing enhancements.
- Custom CSS (css/styles.css): Contains styling rules that override or adjust the appearance of the target website, ensuring that design fixes and layout tweaks are applied.
- HTML Snippets (html/orderHist.html, html/paymentCalculator.html): Provide or mimic the structure for new UI elements (for example, to display order history or payment calculator results).
- External Environment: The Rosie Retailers website where this script is executed and the Tampermonkey extension that facilitates the injection of the script.

##### Relationships and Data Flow
- Tampermonkey Environment → Loads the main.user.js when visiting the target website.
- main.user.js → Calls utility functions from waitForKeyElements_offline.js to ensure that the required webpage elements are available.
- main.user.js → Injects the custom CSS (from css/styles.css) into the site to perform design corrections.
- main.user.js → Uses HTML templates/snippets from the html folder to insert additional UI components (like the order history display or live payment calculator panels).
- main.user.js → Adjusts functionality such as time conversion, payment calculations, auto refresh actions, and element re-formatting directly in the DOM of the Rosie Retailers website.

##### Architectural Patterns and Design Principles
- Client-Side Injection: The entire functionality is built around enhancing an existing page by dynamically injecting scripts, styles, and HTML.
- Incremental Enhancement: The script listens for elements to appear (using waitForKeyElements) and then ‘patches’ the UI accordingly—a common pattern in userscript development.

##### Relevant Technologies
- Tampermonkey as the extension framework.
- JavaScript for DOM manipulation and business logic.
- CSS for visual styling adjustments.
- HTML for the UI components that are added to the page.
- (Potentially) any external libraries loaded by the script as dependencies (even though the current tree just shows local files).

##### Details
- Every critical connection—even though the project is relatively simple, denote all interactions.
- Detail that the injection pattern (via Tampermonkey) is the core mechanism, and that the script enhances the DOM on multiple fronts (time conversion, payment calculation, auto refresh, etc.) as outlined in the README.
- Also, note that the README provides contextual clues (like features and bug-fix history) which reinforce the modular adjustments the script makes to the website. This helps in understanding the evolution of the system and why each component exists.

## Diagram (Mermaid)

```mermaid
flowchart TD
    tm["Tampermonkey Environment"]:::external
    us["main.user.js"]:::logic
    helper["waitForKeyElements_offline.js<br/>(Utility Function)"]:::logic
    css["css/styles.css<br/>(Custom CSS)"]:::css
    orderHist["html/orderHist.html<br/>(Order History Template)"]:::ui
    payCalc["html/paymentCalculator.html<br/>(Payment Calculator Template)"]:::ui
    website["Rosie Retailers Website"]:::external

    tm -->|"loads"| us
    us -->|"calls"| helper
    us -->|"injects"| css
    us -->|"inserts"| orderHist
    us -->|"inserts"| payCalc
    us -->|"modifiesDOM"| website

    click us "https://github.com/ryah/rosie-addon-suite/blob/main/main.user.js"
    click helper "https://github.com/ryah/rosie-addon-suite/blob/main/js/waitForKeyElements_offline.js"
    click css "https://github.com/ryah/rosie-addon-suite/blob/main/css/styles.css"
    click orderHist "https://github.com/ryah/rosie-addon-suite/blob/main/html/orderHist.html"
    click payCalc "https://github.com/ryah/rosie-addon-suite/blob/main/html/paymentCalculator.html"

classDef logic fill:#e0bbf4,stroke:#4a235a,stroke-width:2px,color:#4a235a;
classDef external fill:#cce5ff,stroke:#339af0,stroke-width:2px,color:#333;
classDef css fill:#ffe6cc,stroke:#ff8c1a,stroke-width:2px,color:#333;
classDef ui fill:#d4edda,stroke:#28a745,stroke-width:2px,color:#333;
```
