# parthpatel2000/expedia_price_tracker_extension architecture

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

- Interactive diagram: https://gitdiagram.com/parthpatel2000/expedia_price_tracker_extension
- Repository: https://github.com/parthpatel2000/expedia_price_tracker_extension

## Overview

##### Project Type and Purpose
- This is a full-stack Chrome extension (“Expedia Price Tracker”) that automates hotel price scraping on Expedia, persists history in Firebase, provides both an in-extension popup UI and a web-based React dashboard, and sends daily email notifications via Firebase Cloud Functions.

##### File Structure Analysis
- Top-Level
- .env.*, firebase.json, .firebaserc, manifest.json, webpack.config.js, tailwind.config.js
- functions/ (Node.js Cloud Functions)
- src/
– background/ (service-worker logic: scraping, scheduling, messaging)
– popup/ (React-based popup UI)
– dashboard/ (React dashboard & analytics)
– lib/ (shared Firebase helper modules)
- Build Config
- webpack.config.js / Babel / PostCSS / TailwindCSS
- CI/CD
- .github/workflows/webpack.yml

##### Architectural Insights from README
- Chrome Extension (Manifest v3)
- Background service worker orchestrates alarms, scrapers, message passing
- React UIs in popup & dashboard (built with Webpack & Tailwind)
- Firebase: Auth + Firestore + Cloud Functions for email notifications
- External dependencies: Expedia website (scraped), SMTP/email provider

##### Main Components & Their Relationships
A. Browser-Side Extension
1. Manifest v3 → registers background service worker
2. Background Service Worker
- alarmScheduling.js triggers daily/frequent scrape
- scraper.js fetches Expedia pages → DOM parse → extract prices
- firebase_utils.js writes to Firestore via chrome.identity token
- priceStorage.js/ monthlyHistory.js handle data modeling
- emailNotification.js enqueues Cloud Function triggers
3. Popup UI (React)
- App.jsx + Views (DailyScrapeView, PricesView, SettingsView)
- Communicates with background via chrome.runtime.sendMessage
- Reads/Writes user settings to chrome.storage and Firestore
4. Dashboard UI (React + Recharts)
- dashboard.html + Dashboard.jsx
- Queries Firestore directly to render price history, logs, analytics
B. Cloud-Side Services
1. Firebase Authentication (Google OAuth, anonymous)
2. Firestore Database (collections: users, properties, dailyPrices, monthlyHistory)
3. Cloud Functions (functions/index.js)
- Trigger: Firestore writes or scheduled via Pub/Sub
- Uses Nodemailer to send email summaries
C. External Systems
- Expedia website (HTML pages to scrape)
- SMTP/email provider (via Nodemailer)

##### Architectural Patterns & Principles
- Separation of concerns:
- Background worker for all scraping & scheduling logic
- React UIs strictly for presentation and user interaction
- Firebase helper modules in src/lib shared across UIs & background
- Event-driven:
- Chrome alarms & messages drive the scrape pipeline
- Firestore triggers drive email notifications
- Modular bundling:
- Webpack organizes code into entry points (background, popup, dashboard)

##### Final Checklist
- Component labels (e.g., “Background Service Worker”, “Popup React App”)
- Arrowheads and annotations (e.g., “Firestore.write()”, “chrome.alarms API”)
- Data flow loops (scrape → store → dashboard → notify)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser/Extension Layer
    subgraph "Browser / Chrome Extension"
        direction TB
        Manifest["Manifest v3"]:::browser
        click Manifest "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/manifest.json"
        subgraph "Background Service Worker"
            direction TB
            BG_Index["index.js"]:::browser
            click BG_Index "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/index.js"
            Alarm["Alarm Scheduling"]:::browser
            click Alarm "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/alarmScheduling.js"
            Scraper["Scraper & DOM Parsing"]:::browser
            click Scraper "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/scraper.js"
            FirebaseUtils["Firebase Utils"]:::browser
            click FirebaseUtils "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/firebase_utils.js"
            PriceModel["Price Storage"]:::browser
            click PriceModel "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/priceStorage.js"
            Monthly["Monthly History"]:::browser
            click Monthly "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/monthlyHistory.js"
            PropertyLinks["Property Links"]:::browser
            click PropertyLinks "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/propertyLinks.js"
            EmailNotif["Email Notification Trigger"]:::browser
            click EmailNotif "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/background/emailNotification.js"
        end
        subgraph "Popup React App"
            direction TB
            PopupHTML["popup.html"]:::browser
            click PopupHTML "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/popup.html"
            PopupEntry["popup.jsx"]:::browser
            click PopupEntry "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/popup.jsx"
            AppPopup["App.jsx"]:::browser
            click AppPopup "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/App.jsx"
            DailyView["DailyScrapeView.jsx"]:::browser
            click DailyView "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/DailyScrapeView.jsx"
            PricesView["PricesView.jsx"]:::browser
            click PricesView "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/PricesView.jsx"
            PropertiesView["PropertiesView.jsx"]:::browser
            click PropertiesView "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/PropertiesView.jsx"
            SettingsView["SettingsView.jsx"]:::browser
            click SettingsView "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/SettingsView.jsx"
            PopupStyle["tailwind.css"]:::browser
            click PopupStyle "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/popup/tailwind.css"
        end
        subgraph "Dashboard React App"
            direction TB
            DashHTML["dashboard.html"]:::browser
            click DashHTML "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/dashboard/dashboard.html"
            DashEntry["main.jsx"]:::browser
            click DashEntry "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/dashboard/main.jsx"
            Dashboard["Dashboard.jsx"]:::browser
            click Dashboard "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/dashboard/Dashboard.jsx"
            DashStyle["tailwind.css"]:::browser
            click DashStyle "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/dashboard/tailwind.css"
        end
    end

    %% Shared Library
    subgraph "Shared Firebase Helpers"
        direction TB
        FB_Init["firebase.js"]:::cloud
        click FB_Init "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/lib/firebase.js"
        PriceDB["priceHistoryDB.js"]:::cloud
        click PriceDB "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/src/lib/priceHistoryDB.js"
    end

    %% Cloud Layer
    subgraph "Cloud / Firebase"
        direction TB
        Auth["Firebase Auth"]:::cloud
        Firestore["Firestore DB"]:::db
        Functions["Cloud Functions"]:::cloud
        click Functions "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/functions/index.js"
        click Functions "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/functions/package.json"
        click Functions "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/functions/.eslintrc.js"
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        Expedia["Expedia Website"]:::external
        EmailSvc["SMTP Email Provider"]:::external
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        Webpack["webpack.config.js"]:::cloud
        TailwindCfg["tailwind.config.js"]:::cloud
        PostCSS["postcss.config.js"]:::cloud
        FirebaseCfg["firebase.json/.firebaserc"]:::cloud
        CI["CI Workflow"]:::cloud
        click Webpack "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/webpack.config.js"
        click TailwindCfg "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/tailwind.config.js"
        click PostCSS "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/postcss.config.js"
        click FirebaseCfg "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/firebase.json"
        click CI "https://github.com/parthpatel2000/expedia_price_tracker_extension/blob/main/.github/workflows/webpack.yml"
    end

    %% Data & Control Flows
    Manifest -->|"registers"| BG_Index
    Alarm -->|"chrome.alarms"| Scraper
    Scraper -->|"extract prices"| PriceModel
    Scraper -->|"fetch pages"| Expedia
    PriceModel -->|"Firestore.write()"| Firestore
    FirebaseUtils -->|"Auth Token"| Firestore
    Monthly -->|"aggregate dailyPrices"| Firestore
    EmailNotif -->|"enqueue trigger"| Functions
    Functions -->|"Nodemailer SMTP"| EmailSvc
    AppPopup -->|"chrome.runtime.sendMessage"| BG_Index
    AppPopup -->|"Firestore SDK"| Firestore
    Dashboard -->|"Firestore SDK"| Firestore
    FB_Init --> Auth
    PriceDB --> Firestore

    %% Styles and Classes
    classDef browser fill:#E0F2FF,stroke:#333,stroke-width:1px
    classDef cloud fill:#E0FFE0,stroke:#333,stroke-width:1px
    classDef db fill:#FFFFFF,stroke:#2E7D32,stroke-width:2px,stroke-dasharray: 5 5
    classDef external fill:#FFE0B2,stroke:#333,stroke-width:1px
    class Manifest,BG_Index,Alarm,Scraper,FirebaseUtils,PriceModel,Monthly,PropertyLinks,EmailNotif,PopupHTML,PopupEntry,AppPopup,DailyView,PricesView,PropertiesView,SettingsView,PopupStyle,DashHTML,DashEntry,Dashboard,DashStyle browser
    class FB_Init,PriceDB,Auth,Functions,Webpack,TailwindCfg,PostCSS,FirebaseCfg,CI cloud
    class Firestore db
    class Expedia,EmailSvc external
```
