# dhaw44/lead-research-agent architecture

> Architecture diagram of the GitHub repository dhaw44/lead-research-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhaw44/lead-research-agent
- Repository: https://github.com/dhaw44/lead-research-agent

## Overview

This repository is a Python lead-research and competitor-analysis agent. Its two user workflows accept a company URL (and, for comparison, a niche), fetch and clean site text, then classify and analyze the target or discover competitors, summarize each site, and compare the summaries. Both workflows produce a displayed, timestamped text report. The graph emphasizes calls owned by the CLI orchestrators; README documents the report and major capabilities. The benchmark and saved report examples are not runtime product stages.

Main entry points: [`competitor_main.py`](https://github.com/dhaw44/lead-research-agent/blob/main/competitor_main.py) (Competitor CLI), [`main.py`](https://github.com/dhaw44/lead-research-agent/blob/main/main.py) (Single-site CLI), [`config.py`](https://github.com/dhaw44/lead-research-agent/blob/main/config.py) (Pipeline settings), [`scraper.py`](https://github.com/dhaw44/lead-research-agent/blob/main/scraper.py) (Fetch and clean)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Website ingestion"]
  node_scraper["Fetch and clean<br/>[scraper.py]"]
end

subgraph group_single["Single-site analysis"]
  node_single_cli["Single-site CLI<br/>[main.py]"]
  node_classifier["Business classifier<br/>[classifier.py]"]
end

subgraph group_competitive["Competitor research"]
  node_competitor_cli["Competitor CLI<br/>[competitor_main.py]"]
  node_summarizer["Site summarizer<br/>[summarizer.py]"]
  node_finder["Competitor discovery"]
end

subgraph group_shared["Shared services"]
  node_analyzer["Analysis and comparison<br/>[analyzer.py]"]
  node_settings["Pipeline settings<br/>[config.py]"]
  node_reports["Saved text reports"]
end

node_user(("Researcher"))
node_ollama["Local Ollama"]
node_website["Company websites"]
node_search["DuckDuckGo search"]

node_user -->|"provides URL"| node_single_cli
node_user -->|"provides URL and niche"| node_competitor_cli
node_single_cli -->|"fetches target"| node_scraper
node_single_cli -->|"classifies text"| node_classifier
node_single_cli -->|"analyzes text"| node_analyzer
node_single_cli -->|"writes report"| node_reports
node_competitor_cli -->|"fetches sites"| node_scraper
node_competitor_cli -->|"classifies target"| node_classifier
node_competitor_cli -->|"summarizes sites"| node_summarizer
node_competitor_cli -->|"finds competitors"| node_finder
node_competitor_cli -->|"compares summaries"| node_analyzer
node_competitor_cli -->|"writes report"| node_reports
node_scraper -->|"requests pages"| node_website
node_finder -->|"searches niche"| node_search
node_classifier -->|"classifies via"| node_ollama
node_summarizer -->|"summarizes via"| node_ollama
node_analyzer -->|"analyzes via"| node_ollama
node_scraper -->|"reads limits"| node_settings
node_classifier -->|"reads model settings"| node_settings
node_summarizer -->|"reads model settings"| node_settings
node_analyzer -->|"reads model settings"| node_settings
node_single_cli -->|"reads output path"| node_settings
node_competitor_cli -->|"reads output path"| node_settings

click node_single_cli "https://github.com/dhaw44/lead-research-agent/blob/main/main.py"
click node_competitor_cli "https://github.com/dhaw44/lead-research-agent/blob/main/competitor_main.py"
click node_scraper "https://github.com/dhaw44/lead-research-agent/blob/main/scraper.py"
click node_classifier "https://github.com/dhaw44/lead-research-agent/blob/main/classifier.py"
click node_summarizer "https://github.com/dhaw44/lead-research-agent/blob/main/summarizer.py"
click node_analyzer "https://github.com/dhaw44/lead-research-agent/blob/main/analyzer.py"
click node_finder "https://github.com/dhaw44/lead-research-agent/blob/main/competitor_finder.py"
click node_settings "https://github.com/dhaw44/lead-research-agent/blob/main/config.py"
click node_reports "https://github.com/dhaw44/lead-research-agent/tree/main/reports"

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_scraper toneBlue
class node_single_cli,node_classifier toneAmber
class node_competitor_cli,node_summarizer,node_finder toneMint
class node_analyzer,node_settings,node_reports toneRose
class node_user,node_ollama,node_website,node_search toneIndigo
```

## Components

### Website ingestion

- [Fetch and clean](https://github.com/dhaw44/lead-research-agent/blob/main/scraper.py): `scraper.py`

### Single-site analysis

- [Single-site CLI](https://github.com/dhaw44/lead-research-agent/blob/main/main.py): `main.py`
- [Business classifier](https://github.com/dhaw44/lead-research-agent/blob/main/classifier.py): `classifier.py`

### Competitor research

- [Competitor CLI](https://github.com/dhaw44/lead-research-agent/blob/main/competitor_main.py): `competitor_main.py`
- [Site summarizer](https://github.com/dhaw44/lead-research-agent/blob/main/summarizer.py): `summarizer.py`
- [Competitor discovery](https://github.com/dhaw44/lead-research-agent/blob/main/competitor_finder.py): `competitor_finder.py`

### Shared services

- [Analysis and comparison](https://github.com/dhaw44/lead-research-agent/blob/main/analyzer.py): `analyzer.py`
- [Pipeline settings](https://github.com/dhaw44/lead-research-agent/blob/main/config.py): `config.py`
- [Saved text reports](https://github.com/dhaw44/lead-research-agent/tree/main/reports): `reports`

### Other components

- **Researcher**
- **Local Ollama**
- **Company websites**
- **DuckDuckGo search**

## Connections

- Researcher → Single-site CLI: provides URL (evidence: `README.md`)
- Researcher → Competitor CLI: provides URL and niche (evidence: `README.md`)
- Single-site CLI → Fetch and clean: fetches target (evidence: `main.py`)
- Single-site CLI → Business classifier: classifies text (evidence: `main.py`)
- Single-site CLI → Analysis and comparison: analyzes text (evidence: `main.py`)
- Single-site CLI → Saved text reports: writes report (evidence: `main.py`)
- Competitor CLI → Fetch and clean: fetches sites (evidence: `competitor_main.py`)
- Competitor CLI → Business classifier: classifies target (evidence: `competitor_main.py`)
- Competitor CLI → Site summarizer: summarizes sites (evidence: `competitor_main.py`)
- Competitor CLI → Competitor discovery: finds competitors (evidence: `competitor_main.py`)
- Competitor CLI → Analysis and comparison: compares summaries (evidence: `competitor_main.py`)
- Competitor CLI → Saved text reports: writes report (evidence: `competitor_main.py`)
- Fetch and clean → Company websites: requests pages (evidence: `scraper.py`)
- Competitor discovery → DuckDuckGo search: searches niche (evidence: `competitor_finder.py`)
- Business classifier → Local Ollama: classifies via (evidence: `classifier.py`)
- Site summarizer → Local Ollama: summarizes via (evidence: `summarizer.py`)
- Analysis and comparison → Local Ollama: analyzes via (evidence: `analyzer.py`)
- Fetch and clean → Pipeline settings: reads limits (evidence: `scraper.py`)
- Business classifier → Pipeline settings: reads model settings (evidence: `classifier.py`)
- Site summarizer → Pipeline settings: reads model settings (evidence: `summarizer.py`)
- Analysis and comparison → Pipeline settings: reads model settings (evidence: `analyzer.py`)
- Single-site CLI → Pipeline settings: reads output path (evidence: `main.py`)
- Competitor CLI → Pipeline settings: reads output path (evidence: `competitor_main.py`)
