How albirgit/lead_generation_pipeline works
Purpose and execution model
This repository is a file-oriented lead-generation pipeline. It turns campaign source data into enriched, ranked, and batchable Excel lead lists. The main reusable entry points are stage pipeline modules rather than a web service or CLI: lead_pipeline/modules/step1_document_intelligence/pipeline.py and lead_pipeline/modules/step2_thomasnet_scraper/pipeline.py.
Campaign workspace and artifacts
Campaigns are organized as input/output directories, exemplified by lead_pipeline/campaigns/electrical_Illinois/. The current campaign consumes Input/raw.xlsx and persists intermediate and final workbook artifacts under Output/, including ranked leads, domain-upload files, scraper result batches, merged batches, and final batches. This filesystem boundary is the primary integration contract between stages and manual/external enrichment processes.
Stage 1: document intelligence
lead_pipeline/modules/step1_document_intelligence/pipeline.py orchestrates document ingestion, interpretation, and output persistence. document_parser.py extracts source-document content, while llm_analyzer.py applies LLM-based analysis to produce structured lead-relevant information. models.py defines the stage’s domain/result structures; output_io.py materializes results for subsequent processing. Configuration and failure behavior are isolated in config.py and exceptions.py.
Stage 2: Thomasnet discovery and scraping
lead_pipeline/modules/step2_thomasnet_scraper/pipeline.py drives supplier/company discovery against Thomasnet. Browser lifecycle and automation are separated in browser.py; request/page collection is handled by scraper.py; and extracted page content is transformed in parser.py. Structured records and Excel/file exchange are owned by models.py and output_io.py. This stage is the principal external-service boundary and likely requires a browser-capable runtime plus network access.
Lead enrichment, scoring, and reviews
The post-discovery layer is implemented in lead_pipeline/modules/preprocessorANDscorer.py and lead_pipeline/modules/maps_reviews.py. These modules normalize/enrich candidate lead data, derive ranking signals, and incorporate map/review information before leads are written to leads_ranked.xlsx. Maps/reviews represent another external data boundary, separate from Thomasnet scraping.
Batch assembly and downstream handoff
lead_pipeline/modules/files_merger.py combines enrichment outputs into campaign-ready batches. The artifact sequence in Output/ indicates an iterative handoff: scraper results (snov_results_batch_*.xlsx) are merged (merged_batch_*.xlsx) and finalized (final_batch_*.xlsx), with domains_upload.xlsx supporting domain-based external enrichment/upload workflows. The repository therefore supports both automated processing and spreadsheet-mediated operational steps.
Runtime and dependencies
The project is Python-based (lead_pipeline/__init__.py) with dependencies declared in requirements.txt. Material infrastructure is local filesystem storage for campaign artifacts, browser automation for Thomasnet, an LLM provider/runtime for document intelligence, and external maps/review plus likely email/domain enrichment systems implied by Snov-named output files. There is no evidence in the tree of a deployed API, database, queue, or frontend.
Main entry points: llm_analyzer.py LLM analyzer · scraper.py Thomasnet scraper · preprocessorANDscorer.py Lead enrichment and scoring · maps_reviews.py Maps and reviews
Components 19
Campaign workspace
Spreadsheet artifacts are the inter-stage contract.
- Raw campaign workbook
lead_pipeline/campaigns/electrical_Illinois/Input/raw.xlsx - Campaign Output · Stores intermediate, ranked, and final workbooks.
- Ranked leads workbook
- Domain upload workbook · Supports external domain/email enrichment workflows.
- Final batch workbooks · Snov results are merged into final campaign batches.
Document intelligence
- Stage 1 pipeline
lead_pipeline/modules/step1_document_intelligence/pipeline.py - Document parser
lead_pipeline/modules/step1_document_intelligence/document_parser.py - LLM analyzer
lead_pipeline/modules/step1_document_intelligence/llm_analyzer.py - LLM provider/runtime
Thomasnet discovery
- Stage 2 pipeline
lead_pipeline/modules/step2_thomasnet_scraper/pipeline.py - Browser automation
lead_pipeline/modules/step2_thomasnet_scraper/browser.py - Thomasnet scraper
lead_pipeline/modules/step2_thomasnet_scraper/scraper.py - Thomasnet · Requires network and browser-capable execution.
- Page parser
lead_pipeline/modules/step2_thomasnet_scraper/parser.py
Enrichment and handoff
- Lead enrichment and scoring · Normalizes candidates and derives ranking signals.
lead_pipeline/modules/preprocessorANDscorer.py - Maps and reviews
lead_pipeline/modules/maps_reviews.py - Maps/review sources
- Batch merger
lead_pipeline/modules/files_merger.py - Domain/email enrichment · Spreadsheet-mediated external handoff.
Connections 20
- Raw campaign workbook → Stage 1 pipeline: ingests
- Stage 1 pipeline → Document parser: extracts content
- Document parser → LLM analyzer: source content
- LLM analyzer → LLM provider/runtime: analysis request
- LLM analyzer → Campaign Output: structured artifacts
- Campaign Output → Stage 2 pipeline: campaign inputs
- Stage 2 pipeline → Browser automation: controls
- Browser automation → Thomasnet scraper: browser session
- Thomasnet scraper → Thomasnet: collects pages
- Thomasnet scraper → Page parser: page content
- Page parser → Campaign Output: scraper result batches
- Campaign Output → Lead enrichment and scoring: candidate leads
- Lead enrichment and scoring → Maps and reviews: enrichment requests
- Maps and reviews → Maps/review sources: retrieves signals
- Maps and reviews → Ranked leads workbook: review-enriched leads
- Lead enrichment and scoring → Domain upload workbook: domains for handoff
- Domain upload workbook → Domain/email enrichment: upload/download workflow
- Domain/email enrichment → Campaign Output: Snov result batches
- Campaign Output → Batch merger: merged batch inputs
- Batch merger → Final batch workbooks: finalizes batches