# gabybrow/zonaprop-price-per-m2 architecture

> Architecture diagram of the GitHub repository gabybrow/zonaprop-price-per-m2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gabybrow/zonaprop-price-per-m2
- Repository: https://github.com/gabybrow/zonaprop-price-per-m2

## Overview

##### Project Type & Purpose
- The project is clearly a browser extension tailored to enhancing the user experience on a specific website (Zonaprop). Its primary function is to inject logic into listing pages to perform price calculations (including ARS to USD conversion) and display them in real time.
- The extension is built for the Chrome browser and uses a content script to interact with the web page’s DOM, while external resources like an exchange rate API might be used for real-time currency conversion.

##### File Structure to Identify Components
- Top-Level Files:
- manifest.json: The core configuration file for the extension, which declares permissions, scripts, and extension metadata.
- content.js: The main content script that runs in the context of Zonaprop pages, responsible for DOM manipulation, price extraction, calculations, and display updates.
- index.html: Likely serves as a fallback page or for extension options (even if minimal) — it should be included if it plays a role in user interaction or settings.
- package.json/package-lock.json: Define dependencies and indicate the project uses Node.js for development (for testing, building, etc.).
- Directory "tests":
- Contains automated tests using Jest (e.g., tests/content.test.js) and manual test pages (e.g., tests/manual-test.html) to verify both the extension’s logic and UI behavior.

##### Main Components & Data Flow
a. Chrome Extension Manifest: Acts as the entry point and configuration for the extension. It specifies which scripts to load and what permissions are required.
b. Content Script (content.js): Loaded on Zonaprop pages via the manifest. It extracts property prices from the DOM, performs calculations (using possibly some helper functions for exchange rate conversion), and injects the calculated price per square meter into the page.
c. External Service Interaction: Though not explicitly defined as a separate code file, the README indicates that real-time exchange rate data is fetched from an external API. Represent this component to show API communication and data flow.
d. Testing Framework: Include a component representing automated tests (Jest) and manual testing components (HTML-based test pages) that validate the core functionality.
e. User Interaction Path: The browser (user’s Chrome session) where the extension runs, interacts with the modified DOM on Zonaprop pages.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The extension’s logic is separated from configuration (manifest.json), into distinct testing modules, and visual assets are kept separately.
- Dynamic Content Injection: The content script is designed to detect changes in the DOM (as the user scrolls) and update calculations in real time.
- Test-Driven Development: Automated tests ensure that core functions such as number extraction, currency conversion, and formatting are robust.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Chrome Extension Core"
        A["Chrome Extension Manifest"]:::extension
        B["Content Script (Price Calculation & DOM Manipulation)"]:::extension
        E["Extension Options/User Interface"]:::extension
    end

    C["Zonaprop Web Page (DOM)"]:::ui
    D["Exchange Rate API"]:::external

    subgraph "Testing"
        G["Automated Tests (Jest)"]:::testing
        H["Manual Testing Pages"]:::testing
    end

    subgraph "Visual Assets"
        I["Icons"]:::assets
        J["Screenshots"]:::assets
    end

    A -->|"loads"| B
    A -->|"defines_options"| E
    B -->|"updates"| C
    B -->|"fetches_data"| D
    G -->|"validates_logic"| B
    H -->|"verifies_UI_updates"| C

    click A "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/manifest.json"
    click B "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/content.js"
    click E "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/index.html"
    click G "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/tests/content.test.js"
    click H "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/tests/manual-test.html"
    click I "https://github.com/gabybrow/zonaprop-price-per-m2/tree/main/icons"
    click J "https://github.com/gabybrow/zonaprop-price-per-m2/blob/main/screenshots/README.md"

    classDef extension fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef testing fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef assets fill:#f4a460,stroke:#000,stroke-width:2px;
    classDef external fill:#ffa500,stroke:#000,stroke-width:2px;
    classDef ui fill:#d3d3d3,stroke:#000,stroke-width:2px;
    
    class D external;
    class C ui;
```
