# dhananjaylab/price-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/dhananjaylab/price-tracker
- Repository: https://github.com/dhananjaylab/price-tracker

## Overview

##### Project type and purpose
- This is a small, single‐script Python tool named Price-Tracker.
- Its purpose is to fetch prices for one or more Amazon product pages on a schedule, record or compare them, and notify the user when conditions are met.

##### File structure
- Top-level items:
– Amazon_Price_Tracker.py (main script containing scraper logic, scheduler and notification routines)
– README.md (very brief; no additional modules or subdirectories)
- No separate “src” or “lib” directories, so all functionality is in one file or imported libraries.
- No explicit tests or configuration files; likely any scheduling is done externally (cron, Task Scheduler) or via in‐script loop.

##### README for additional insights
- It only names the project “Price-Tracker.”

a. Main components
1. Scheduler (cron job, Windows Task Scheduler, or in-script loop)
2. Price-Tracker Script (Amazon_Price_Tracker.py)
– HTTP Client / Scraper module
– HTML Parser for price extraction
– Data Layer for persisting results (CSV, SQLite, or external DB)
– Notification Module (email, SMS, Slack, etc.)
3. Data Store (CSV file, SQLite database, or other)
4. External Services
– Amazon product pages (data source)
– Notification service (SMTP server, SMS gateway, or Slack API)
b. Relationships and interactions
- Scheduler triggers the Price-Tracker Script at defined intervals.
- Script sends HTTP requests to Amazon, parses the HTML response to extract current price.
- Parsed price data is saved in the Data Store.
- Script evaluates price threshold or change conditions; if triggered, it invokes the Notification Module.
- Notification Module calls an external notification service to deliver alerts.
c. Architectural patterns/design principles
- Single responsibility within modules: separate scraping, parsing, data persistence, and notifications.
- Externalize scheduling to keep the script focused on data retrieval/processing.
- Use a simple data store to track history and avoid re-scraping unchanged sites.
d. Key technologies/libraries
- Python 3.x
- requests or urllib3 for HTTP requests
- BeautifulSoup or lxml for HTML parsing
- sqlite3 or csv module for storage
- smtplib, Twilio, or Slack SDK for notifications
- Cron (Linux) / Task Scheduler (Windows) for scheduling

##### Elements
– “trigger” from Scheduler to Script
– “HTTP GET” to Amazon
– “write/read” between Script and Data Store
– “send alert” from Script to Notification Service
– Rectangles for internal components (Script, Data Store)
– Clouds for external services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Scheduler Layer
    Scheduler["Scheduler"]:::scheduler
    click Scheduler "https://github.com/dhananjaylab/price-tracker/blob/main/Amazon_Price_Tracker.py"

    %% Script Components
    subgraph "Price-Tracker Script"
        Scraper["HTTP Client / Scraper"]:::scraper
        Parser["HTML Parser"]:::scraper
        Persist["Data Layer"]:::storage
        Notify["Notification Module"]:::notification
    end
    click Scraper "https://github.com/dhananjaylab/price-tracker/blob/main/Amazon_Price_Tracker.py"
    click Parser "https://github.com/dhananjaylab/price-tracker/blob/main/Amazon_Price_Tracker.py"
    click Persist "https://github.com/dhananjaylab/price-tracker/blob/main/Amazon_Price_Tracker.py"
    click Notify "https://github.com/dhananjaylab/price-tracker/blob/main/Amazon_Price_Tracker.py"

    %% Data Store
    DataStore["Data Store (CSV/SQLite)"]:::storage

    %% External Services
    Amazon["Amazon Product Pages"]:::external
    NotifyService["Notification Service"]:::external
    Doc["Project Documentation (README.md)"]:::external
    click Doc "https://github.com/dhananjaylab/price-tracker/blob/main/README.md"

    %% Flows
    Scheduler -->|"trigger"| Scraper
    Scraper -->|"HTTP GET"| Amazon
    Amazon -->|"HTML Response"| Parser
    Parser -->|"Parsed Price Data"| Persist
    Persist -->|"write/read"| DataStore
    Parser -.->|"threshold check"| Notify
    Notify -->|"notification payload"| NotifyService

    %% Styles
    classDef scheduler fill:#b2f2bb,stroke:#333,stroke-width:1px;
    classDef scraper fill:#a5d8ff,stroke:#333,stroke-width:1px;
    classDef storage fill:#ffd8a8,stroke:#333,stroke-width:1px;
    classDef notification fill:#eebefa,stroke:#333,stroke-width:1px;
    classDef external fill:#d9d9d9,stroke:#333,stroke-width:1px;
```
