How shyam7291/document-monitor works
Purpose and Entry Points
document-monitor is a file-backed document/URL monitoring pipeline. It scrapes source links, normalizes document records, compares them with known prior records, captures issues, and emits CSV reports. Primary executable entry points are scrape.py and the development variant scrape_dev.py.
Pipeline Orchestration
GitHub Actions divides execution into staged runs: initial processing, subsequent phases, and a parallel final phase. Workflows in .github/workflows/run_p1.yml, .github/workflows/run_p2_p3.yml, and .github/workflows/run_p4_p5_parallel.yml define the production control plane; .github/workflows/run_test_dev.yml supports development/testing runs.
Scraping and Link Acquisition
The scraper ingests and produces URL/link datasets. scrape.py is the main acquisition/processing boundary, with CSV inputs/outputs such as raw_links.csv, raw_links_p2_p3_latest.csv, and test_urls.csv. This is the likely external-network boundary: URL availability and document retrieval depend on remote sites.
Document Record Stages
Document data is partitioned by processing phase rather than held in a database. Early/intermediate outputs include documents.csv, documents_p1.csv, documents_p2.csv, and documents_p3.csv. Final parallel-phase shards are stored in p4_p5/documents_p4_p5_01.csv through p4_p5/documents_p4_p5_06.csv, enabling distributed or batched processing.
Identity, Change Detection, and State
Known-document datasets provide the comparison baseline for determining additions, changes, or removals: known_documents.csv and p4_p5/known_documents_p4_p5.csv. Canonical identity is explicitly materialized in p4_p5/document_canonical_keys_p4_p5.csv. Change/difference outputs are persisted in diff.csv, diff_p4_p5.csv, and diffbackup.csv; these CSVs are the pipeline’s durable state and handoff boundary between runs.
Validation and Issue Capture
Failures and anomalous records are captured separately from normal document outputs. Key artifacts are capture_issues.csv, capture_issues_p2_p3_latest.csv, and p4_p5/capture_issues_p4_p5.csv. URL-level outcomes are retained in p4_p5/url_status_p4_p5.csv, separating fetch/status diagnostics from document comparison results.
Reporting and Final Outputs
The pipeline produces consolidated outputs for consumers and run-level oversight. Main deliverables include output.csv, output_test.csv, and p4_p5/output_p4_p5.csv. Summary/reporting artifacts—run_summary_master.csv, run_summary_v2.csv, and report_keywords.csv—support aggregation, run tracking, and keyword-oriented reporting.
Main entry points: scrape.py Main scraper · run_summary_master.csv Run reporting · scrape_dev.py Development scraper · raw_links.csv Link datasets
Components 18
Workflow Control Plane
GitHub Actions stages production and development runs.
- Phase 1 workflow
.github/workflows/run_p1.yml - Phases 2–3 workflow
.github/workflows/run_p2_p3.yml - Parallel phases 4–5 · Runs final work in parallel shards.
.github/workflows/run_p4_p5_parallel.yml - Development workflow
.github/workflows/run_test_dev.yml
Processing Pipeline
Scraping, normalization, comparison, and issue capture.
- Main scraper · Acquires links and processes document records.
scrape.py - Development scraper
scrape_dev.py - Change detection · Classifies additions, changes, and removals against known records.
CSV State and Outputs
File-backed handoffs, baselines, and reports.
- Link datasets · Raw and test URLs feed acquisition.
raw_links.csv - Early document stages · Phase-partitioned normalized document records.
documents_p1.csv - Final document shards · Six phase 4–5 batches enable parallel processing.
p4_p5/documents_p4_p5_01.csv - Known-document baseline · Prior records used for change detection.
known_documents.csv - Canonical identities
p4_p5/document_canonical_keys_p4_p5.csv - Difference state · Durable comparison handoff between runs.
diff.csv - Issue capture · Separates anomalous or failed records from normal output.
capture_issues.csv - URL status diagnostics · Retains fetch and availability outcomes.
p4_p5/url_status_p4_p5.csv - Consumer output
output.csv - Final parallel output
p4_p5/output_p4_p5.csv - Run reporting · Run summaries and keyword-oriented reporting.
run_summary_master.csv
Connections 22
- Phase 1 workflow → Main scraper: runs
- Phases 2–3 workflow → Main scraper: runs
- Parallel phases 4–5 → Main scraper: runs in parallel
- Development workflow → Development scraper: runs
- Link datasets → Main scraper: URLs and links
- Main scraper → Early document stages: normalizes
- Main scraper → Final document shards: writes phase 4–5 batches
- Main scraper → Issue capture: captures failures
- Main scraper → URL status diagnostics: records fetch status
- Development scraper → Link datasets: uses test URLs
- Early document stages → Change detection: candidate records
- Final document shards → Change detection: parallel candidates
- Known-document baseline → Change detection: prior baseline
- Canonical identities → Change detection: canonical identity
- Change detection → Difference state: persists differences
- Change detection → Consumer output: emits results
- Change detection → Final parallel output: emits final results
- Difference state → Known-document baseline: informs next-run state
- Consumer output → Run reporting: summarizes
- Final parallel output → Run reporting: summarizes
- Issue capture → Run reporting: tracks issues
- URL status diagnostics → Run reporting: tracks URL outcomes