# ktt-tran/ycp-hack-webscraper architecture

> Architecture diagram of the GitHub repository ktt-tran/ycp-hack-webscraper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ktt-tran/ycp-hack-webscraper
- Repository: https://github.com/ktt-tran/ycp-hack-webscraper

## Overview

This is an interactive web-research script: a user enters a query, the script searches Google Custom Search, fetches and extracts paragraphs from result pages, then tokenizes and filters the collected text. It writes the text and source URLs to intermediate files, produces a PDF from the processed output, and opens it for the user. The single source file contains the whole workflow; no README or additional implementation was provided.

Main entry points: [`WEBScraper/FinalWebScraper.py`](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py) (Search loop), [`dataTextFile`](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/dataTextFile) (Collected text), [`scrapedData`](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/scrapedData) (Processed text file), [`output.pdf`](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/output.pdf) (Output PDF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_search["Search and extraction"]
  node_workflow["Search loop<br/>[FinalWebScraper.py]"]
  node_custom_search["Google Custom Search"]
  node_page_fetch["Page fetch and parse<br/>[FinalWebScraper.py]"]
  node_paragraphs["Paragraph extraction<br/>[FinalWebScraper.py]"]
end

subgraph group_text["Text processing"]
  node_preprocess["Tokenize and filter<br/>[FinalWebScraper.py]"]
  node_important_data["Processed text<br/>[FinalWebScraper.py]"]
end

subgraph group_output["Files and presentation"]
  node_data_file["Collected text"]
  node_scraped_file["Processed text file"]
  node_pdf["PDF generation<br/>[FinalWebScraper.py]"]
  node_pdf_file["Output PDF<br/>[output.pdf]"]
  node_browser["Web browser"]
end

node_user(("User"))

node_user -->|"enters query"| node_workflow
node_workflow -->|"requests results"| node_custom_search
node_workflow -->|"calls scraper"| node_page_fetch
node_page_fetch -->|"fetches result page"| node_custom_search
node_page_fetch -->|"parses paragraphs"| node_paragraphs
node_paragraphs -->|"writes text"| node_data_file
node_workflow -->|"reads collected text"| node_data_file
node_workflow -->|"tokenizes and filters"| node_preprocess
node_preprocess -->|"returns sentences and words"| node_important_data
node_workflow -->|"writes processed text"| node_scraped_file
node_workflow -->|"converts file"| node_pdf
node_pdf -->|"reads text"| node_scraped_file
node_pdf -->|"writes PDF"| node_pdf_file
node_workflow -->|"opens PDF"| node_browser
node_browser -->|"displays"| node_pdf_file

click node_workflow "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_page_fetch "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_paragraphs "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_data_file "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/dataTextFile"
click node_preprocess "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_important_data "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_scraped_file "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/scrapedData"
click node_pdf "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py"
click node_pdf_file "https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/output.pdf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workflow,node_custom_search,node_page_fetch,node_paragraphs,node_user toneBlue
class node_preprocess,node_important_data toneAmber
class node_data_file,node_scraped_file,node_pdf,node_pdf_file,node_browser toneMint
```

## Components

### Search and extraction

- [Search loop](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`
- **Google Custom Search**
- [Page fetch and parse](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`
- [Paragraph extraction](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`

### Text processing

- [Tokenize and filter](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`
- [Processed text](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`

### Files and presentation

- [Collected text](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/dataTextFile): `dataTextFile`
- [Processed text file](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/scrapedData): `scrapedData`
- [PDF generation](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/WEBScraper/FinalWebScraper.py): `WEBScraper/FinalWebScraper.py`
- [Output PDF](https://github.com/ktt-tran/ycp-hack-webscraper/blob/master/output.pdf): `output.pdf`
- **Web browser**

### Other components

- **User**

## Connections

- User → Search loop: enters query (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Google Custom Search: requests results (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Page fetch and parse: calls scraper (evidence: `WEBScraper/FinalWebScraper.py`)
- Page fetch and parse → Google Custom Search: fetches result page (evidence: `WEBScraper/FinalWebScraper.py`)
- Page fetch and parse → Paragraph extraction: parses paragraphs (evidence: `WEBScraper/FinalWebScraper.py`)
- Paragraph extraction → Collected text: writes text (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Collected text: reads collected text (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Tokenize and filter: tokenizes and filters (evidence: `WEBScraper/FinalWebScraper.py`)
- Tokenize and filter → Processed text: returns sentences and words (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Processed text file: writes processed text (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → PDF generation: converts file (evidence: `WEBScraper/FinalWebScraper.py`)
- PDF generation → Processed text file: reads text (evidence: `WEBScraper/FinalWebScraper.py`)
- PDF generation → Output PDF: writes PDF (evidence: `WEBScraper/FinalWebScraper.py`)
- Search loop → Web browser: opens PDF (evidence: `WEBScraper/FinalWebScraper.py`)
- Web browser → Output PDF: displays
