# yuvarajgitcat/scrapeultimate architecture

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

- Interactive diagram: https://gitdiagram.com/yuvarajgitcat/scrapeultimate
- Repository: https://github.com/yuvarajgitcat/scrapeultimate

## Overview

##### Project type and purpose
- ScrapeUltimate is an open-source, Python-based web scraping application.
- Purpose: Provide a universal scraper for static and JavaScript-rendered sites, with AI-driven extraction, attended mode for captchas/logins, pagination/infinite-scroll handling, and flexible output (JSON/CSV/Excel).

##### File structure
- Top-level scripts:
- scraper.py – core scraping logic (Selenium, BeautifulSoup, html2text)
- pagination_detector.py – logic to detect and iterate pages
- api_management.py & api_test.py – wrapper around AI APIs (OpenAI GPT, Llama)
- streamlit_app.py – Streamlit UI
- requirements.txt – dependencies
- output/… – per-session folders containing rawData, sorted_data in .md/.json/.xlsx
- External binaries: chromedriver-win64 (Selenium driver).
- Virtual env: .venv, __pycache__, .gitignore.

##### README for architecture hints
- Methodology steps I–XI outline the data pipeline:
1. HTML fetching & preprocessing (Selenium + scroll simulation)
2. Conversion to Markdown
3. AI-based schema generation & extraction
4. Local LLM processing via LLM Studio
5. Dynamic Pydantic models
6. Data cleaning, pagination, infinite scroll, attended mode
7. Output to file system

##### Main system components & interactions
a. Components:
- User (interacts via CLI or Streamlit UI)
- Streamlit frontend (streamlit_app.py)
- Scraper Engine
- Selenium + ChromeDriver (HTML fetch & dynamic interactions)
- BeautifulSoup + html2text (cleaning & Markdown conversion)
- pagination_detector (detect & loop pages)
- AI Processing Layer
- OpenAI GPT (cloud API calls via api_management)
- Local LLM (via LLM Studio & Llama model)
- Data Modeling
- Pydantic dynamic schemas
- Output Service
- JSON/CSV/Excel writer (assets.py helpers)
- File system storage (output/<session>/…)
- External Services
- OpenAI API endpoint
- Local LLM Studio server

b. Relationships & Data flows:
1. User → Streamlit UI → Scraper Engine (URL + settings)
2. Scraper Engine → Selenium/ChromeDriver → fetch raw HTML
3. Scraper Engine → BeautifulSoup/html2text → cleaned Markdown
4. Markdown → API Management → OpenAI GPT → schema suggestions & extraction
5. Markdown → Local LLM Studio → advanced processing (summarization, classification)
6. Extracted data → Pydantic models → cleaned JSON/Excel
7. Write to file system → user download

c. Architectural patterns & principles:
- Pipeline (fetch → clean → transform → extract → output)
- Modular separation (fetcher, parser, AI client, output writer)
- Extensibility hooks (attended mode, pagination, infinite scroll)

d. Key technologies/frameworks:
- Python, Selenium, ChromeDriver, BeautifulSoup, html2text
- OpenAI GPT API, Llama via LLM Studio
- Pydantic for dynamic schemas
- Streamlit for UI
- pandas/openpyxl for Excel

## Diagram (Mermaid)

```mermaid
graph TD
    %% User and UI
    User["User"]:::ui
    Streamlit["Streamlit UI\n(streamlit_app.py)"]:::ui

    %% Scraper Engine
    subgraph "Scraper Engine" 
        direction TB
        ScraperCore["Core Scraper Engine\n(scraper.py)"]:::core
        Pagination["Pagination & Infinite Scroll\n(pagination_detector.py)"]:::core
        Selenium["Selenium + ChromeDriver"]:::core
        Parser["BeautifulSoup + html2text"]:::core
    end

    %% AI Processing Layer
    subgraph "AI Processing Layer"
        direction TB
        APIWrapper["AI API Wrapper\n(api_management.py)"]:::core
        APITests["API Tests & Examples\n(api_test.py)"]:::core
        OpenAI["OpenAI GPT API"]:::external
        LocalLLM["Local LLM Studio"]:::external
    end

    %% Data Modeling & Output
    subgraph "Data Modeling & Output"
        direction TB
        Pydantic["Pydantic Dynamic Schemas"]:::core
        OutputWriter["JSON/CSV/Excel Writer\n(assets.py)"]:::core
        FileSystem["File System Storage\n(output/)"]:::storage
    end

    %% Setup & Infrastructure
    subgraph "Setup / Infrastructure"
        direction TB
        Requirements["Project Dependencies\n(requirements.txt)"]:::infra
        ChromedriverBin["ChromeDriver Binary\n(chromedriver-win64/chromedriver.exe)"]:::infra
        Gitignore[".gitignore"]:::infra
        Venv["Virtual Env & Caches\n(.venv/, __pycache__)"]:::infra
        README["README & Documentation\n(readme.md)"]:::infra
        License["Chromedriver License & Notices\n(LICENSE.chromedriver, THIRD_PARTY_NOTICES.chromedriver)"]:::infra
    end

    %% Connections
    User -->|"interacts via"| Streamlit
    Streamlit -->|"start scraping"| ScraperCore
    ScraperCore -->|fetch HTML| Selenium
    Selenium -->|raw HTML| Parser
    Parser -->|Markdown| APIWrapper
    Parser -->|Markdown| LocalLLM
    APIWrapper -->|schema/extraction| Pydantic
    APITests -->|example calls| OpenAI
    APIWrapper -->|calls| OpenAI
    LocalLLM -->|processing| Pydantic
    Pydantic -->|cleaned data| OutputWriter
    OutputWriter -->|writes files| FileSystem
    FileSystem -->|"user downloads"| User

    %% Setup connections (dotted)
    Requirements -.-> ScraperCore
    ChromedriverBin -.-> Selenium
    Venv -.-> ScraperCore
    Gitignore -.-> Venv
    README -.-> ScraperCore
    License -.-> ChromedriverBin

    %% Click Events
    click Streamlit "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/streamlit_app.py"
    click ScraperCore "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/scraper.py"
    click Pagination "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/pagination_detector.py"
    click APIWrapper "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/api_management.py"
    click APITests "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/api_test.py"
    click OutputWriter "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/assets.py"
    click ChromedriverBin "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/chromedriver-win64/chromedriver.exe"
    click Requirements "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/requirements.txt"
    click FileSystem "https://github.com/yuvarajgitcat/scrapeultimate/tree/master/output/"
    click Gitignore "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/.gitignore"
    click README "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/readme.md"
    click Venv "https://github.com/yuvarajgitcat/scrapeultimate/tree/master/.venv/"
    click License "https://github.com/yuvarajgitcat/scrapeultimate/blob/master/chromedriver-win64/LICENSE.chromedriver"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72;
    classDef core fill:#A3E4D7,stroke:#196F3D;
    classDef external fill:#F9E79F,stroke:#B9770E,stroke-dasharray: 5 5;
    classDef storage fill:#F5B7B1,stroke:#922B21;
    classDef infra fill:#D7BDE2,stroke:#6C3483,stroke-dasharray: 2 2;
```
