# hmshb/scraping-agent-ai architecture

> Architecture diagram of the GitHub repository hmshb/scraping-agent-ai, 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/hmshb/scraping-agent-ai
- Repository: https://github.com/hmshb/scraping-agent-ai

## Overview

Scraping Agent AI accepts a seed URL, initializes workflow state, crawls for same-domain links, scrapes those links in batches, formats content with an LLM, and saves structured JSON. LangGraph owns stage registration, sequencing, and retry routing; the stage implementations own calls to Firecrawl, URL filtering, formatting, and file output. The README also describes flexible output and LangSmith monitoring, but sampled source does not show their runtime wiring, so those relationships are omitted or marked unverified.

Main entry points: [`agent/utils/graph.py`](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/graph.py) (LangGraph workflow), [`agent/utils/nodes.py`](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py) (Crawl links), [`agent/utils/helpers.py`](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/helpers.py) (URL filtering and errors), [`agent/agent.py`](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/agent.py) (Agent entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow orchestration"]
  node_entry["Agent entry<br/>[agent.py]"]
  node_graph["LangGraph workflow<br/>[graph.py]"]
end

subgraph group_stages["Scraping stages"]
  node_initialize["Initialize state<br/>[nodes.py]"]
  node_crawl["Crawl links<br/>[nodes.py]"]
  node_scrap["Batch scrape<br/>[nodes.py]"]
  node_format["Format content<br/>[nodes.py]"]
  node_save["Save results<br/>[nodes.py]"]
  node_error["Retry handler<br/>[nodes.py]"]
  node_json_output["Saved JSON<br/>[nodes.py]"]
end

subgraph group_support["State and helpers"]
  node_state["Workflow state<br/>[states.py]"]
  node_helpers["URL filtering and errors<br/>[helpers.py]"]
end

subgraph group_integrations["External services"]
  node_firecrawl_client["Firecrawl client<br/>[firecrawl.py]"]
  node_firecrawl_service{{"Firecrawl service"}}
  node_llm_client["Anthropic model<br/>[llm.py]"]
  node_anthropic{{"Anthropic API"}}
  node_langsmith{{"LangSmith"}}
end

node_user(("URL requester"))

node_user -.->|"starts run"| node_entry
node_entry -->|"builds graph"| node_graph
node_graph -->|"uses schemas"| node_state
node_graph -->|"registers"| node_initialize
node_graph -->|"registers"| node_crawl
node_graph -->|"registers"| node_scrap
node_graph -->|"registers"| node_format
node_graph -->|"registers"| node_save
node_graph -->|"registers"| node_error
node_graph -->|"starts at"| node_initialize
node_graph -->|"routes next"| node_crawl
node_graph -->|"routes on success"| node_scrap
node_graph -->|"routes on success"| node_format
node_graph -->|"routes on success"| node_save
node_graph -->|"routes on failure"| node_error
node_graph -->|"retries failed stage"| node_crawl
node_graph -->|"retries failed stage"| node_scrap
node_graph -->|"retries failed stage"| node_format
node_initialize -->|"creates state"| node_state
node_crawl -->|"crawls URL"| node_firecrawl_client
node_crawl -->|"filters links"| node_helpers
node_scrap -->|"scrapes batches"| node_firecrawl_client
node_format -->|"formats content"| node_llm_client
node_save -->|"writes results"| node_json_output
node_crawl -->|"uses error wrapper"| node_helpers
node_scrap -->|"uses error wrapper"| node_helpers
node_format -->|"uses error wrapper"| node_helpers
node_save -->|"uses error wrapper"| node_helpers
node_firecrawl_client -->|"requests crawl"| node_firecrawl_service
node_llm_client -.->|"calls model"| node_anthropic
node_entry -.->|"monitoring integration"| node_langsmith

click node_entry "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/agent.py"
click node_graph "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/graph.py"
click node_state "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/states.py"
click node_initialize "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_crawl "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_scrap "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_format "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_save "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_error "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"
click node_helpers "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/helpers.py"
click node_firecrawl_client "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/firecrawl.py"
click node_llm_client "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/llm.py"
click node_json_output "https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py"

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_entry,node_graph toneBlue
class node_initialize,node_crawl,node_scrap,node_format,node_save,node_error,node_json_output toneAmber
class node_state,node_helpers,node_user toneMint
class node_firecrawl_client,node_firecrawl_service,node_llm_client,node_anthropic,node_langsmith toneRose
```

## Components

### Workflow orchestration

- [Agent entry](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/agent.py): `agent/agent.py`
- [LangGraph workflow](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/graph.py): `agent/utils/graph.py`

### Scraping stages

- [Initialize state](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Crawl links](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Batch scrape](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Format content](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Save results](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Retry handler](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`
- [Saved JSON](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/nodes.py): `agent/utils/nodes.py`

### State and helpers

- [Workflow state](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/states.py): `agent/utils/states.py`
- [URL filtering and errors](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/helpers.py): `agent/utils/helpers.py`

### External services

- [Firecrawl client](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/firecrawl.py): `agent/utils/firecrawl.py`
- **Firecrawl service**
- [Anthropic model](https://github.com/hmshb/scraping-agent-ai/blob/main/agent/utils/llm.py): `agent/utils/llm.py`
- **Anthropic API**
- **LangSmith**

### Other components

- **URL requester**

## Connections

- URL requester → Agent entry: starts run (evidence: `README.md`)
- Agent entry → LangGraph workflow: builds graph (evidence: `agent/agent.py`)
- LangGraph workflow → Workflow state: uses schemas (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Initialize state: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Crawl links: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Batch scrape: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Format content: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Save results: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Retry handler: registers (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Initialize state: starts at (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Crawl links: routes next (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Batch scrape: routes on success (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Format content: routes on success (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Save results: routes on success (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Retry handler: routes on failure (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Crawl links: retries failed stage (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Batch scrape: retries failed stage (evidence: `agent/utils/graph.py`)
- LangGraph workflow → Format content: retries failed stage (evidence: `agent/utils/graph.py`)
- Initialize state → Workflow state: creates state (evidence: `agent/utils/nodes.py`)
- Crawl links → Firecrawl client: crawls URL (evidence: `agent/utils/nodes.py`)
- Crawl links → URL filtering and errors: filters links (evidence: `agent/utils/nodes.py`)
- Batch scrape → Firecrawl client: scrapes batches (evidence: `agent/utils/nodes.py`)
- Format content → Anthropic model: formats content (evidence: `agent/utils/nodes.py`)
- Save results → Saved JSON: writes results (evidence: `agent/utils/nodes.py`)
- Crawl links → URL filtering and errors: uses error wrapper (evidence: `agent/utils/nodes.py`)
- Batch scrape → URL filtering and errors: uses error wrapper (evidence: `agent/utils/nodes.py`)
- Format content → URL filtering and errors: uses error wrapper (evidence: `agent/utils/nodes.py`)
- Save results → URL filtering and errors: uses error wrapper (evidence: `agent/utils/nodes.py`)
- Firecrawl client → Firecrawl service: requests crawl (evidence: `agent/utils/firecrawl.py`)
- Anthropic model → Anthropic API: calls model (evidence: `agent/utils/llm.py`)
- Agent entry → LangSmith: monitoring integration (evidence: `README.md`)
