# 1loro/buscalibre_scraper architecture

> Architecture diagram of the GitHub repository 1loro/buscalibre_scraper, 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/1loro/buscalibre_scraper
- Repository: https://github.com/1loro/buscalibre_scraper

## Overview

##### Main Components
- Scraper Module (scraper.py): This is the component that interacts directly with Buscalibre. Its main responsibility is to extract relevant book data, such as the current price, from the wishlist.
- Comparator Module (comparar.py): This module likely takes care of comparing the newly scraped data with past values. It determines if a price drop has occurred.
- Notifier Module (notificador.py): Once a price drop is detected by the comparator, this module is responsible for sending a personalized email alert to the user.

##### Relationships and Data Flow
- Data Flow Sequence: The process begins with the Scraper module, which fetches data from Buscalibre. The scraped data is then passed to the Comparator module, which analyzes whether the price has dropped from its previous value. If it has, a trigger is sent to the Notifier module to dispatch an email alert.
- Scraper → Comparator (data extraction & analysis flow)
- Comparator → Notifier (triggering action based on comparison)

##### Architectural Patterns and Design Principles
- Modular Design: Each Python file represents a specific responsibility within the tool, keeping the application loosely coupled and easy to maintain.
- Pipeline Workflow: The sequential nature of scraping, comparing, and finally notifying represents a clear data pipeline.
- Extensibility: Although simple, this design allows easily adding extra modules (e.g., storing historical data, enhanced logging, or adding retry logic for failed scrapes).

##### Relevant Technologies and Frameworks
- Python is the main language.
- You might be using common Python libraries for web scraping (e.g., requests, BeautifulSoup, or Scrapy) though they are not explicitly mentioned, they are implied.
- Email handling libraries such as smtplib or other mail services for notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Source
    Buscalibre["Buscalibre Website"]:::external

    %% Processing Pipeline
    Scraper["Scraper Module (scraper.py)"]:::module
    Comparator["Comparator Module (comparar.py)"]:::module
    Notifier["Notifier Module (notificador.py)"]:::module

    %% External Email Service
    Email["Email Service (SMTP)"]:::external

    %% Data Flow Connections
    Buscalibre -->|"fetches data"| Scraper
    Scraper -->|"passes data"| Comparator
    Comparator -->|"detects price drop"| Notifier
    Notifier -->|"sends alert"| Email

    %% Click Events for Internal Modules
    click Scraper "https://github.com/1loro/buscalibre_scraper/blob/main/scraper.py"
    click Comparator "https://github.com/1loro/buscalibre_scraper/blob/main/comparar.py"
    click Notifier "https://github.com/1loro/buscalibre_scraper/blob/main/notificador.py"

    %% Styling Classes
    classDef module fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#cce5ff,stroke:#004085,stroke-width:2px;
```
