# bhwthy/seo-audit-tool architecture

> Architecture diagram of the GitHub repository bhwthy/seo-audit-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhwthy/seo-audit-tool
- Repository: https://github.com/bhwthy/seo-audit-tool

## Overview

#### Purpose and entry points
This repository is a Python SEO-audit system for inspecting one or many public website URLs, scoring SEO health, and rendering/exporting results. Primary invocation is `run_audit.py`, which dispatches CLI single/batch audits or launches the local Flask dashboard. Direct library use centers on `SEOAuditor` in `seo_audit.py`.

Grounding: `run_audit.py`, `seo_audit.py`, `README.md`

#### Core audit engine
`SEOAuditor` is the authoritative single-page analysis pipeline. It fetches a target URL through an HTTP session, parses the returned HTML, derives technical, metadata, content, image, link, social, and structured-data findings, then combines rule-based deductions into an overall numeric score and letter grade. It also emits detailed results and summaries.

Grounding: `seo_audit.py`, `seo_audit_example.com_20250804_152323.json`

#### External boundary: target websites
The principal runtime boundary is outbound HTTP(S) access to arbitrary audited sites. The engine depends on response status, headers, timing, TLS/HTTPS availability, compression, HTML markup, and linked resources. This means audit completeness and latency are governed by remote-server availability, redirects, certificate behavior, and configured request timeouts/user-agent behavior.

Grounding: `seo_audit.py`, `requirements.txt`

#### Batch orchestration and reporting
`BatchSEOAuditor` coordinates independent single-site audits concurrently, aggregates individual result objects, identifies cross-site patterns, and produces comparison-oriented output. Batch URLs are supplied from a file or programmatically; results can be exported as JSON and CSV for spreadsheet or automation consumers.

Grounding: `batch_seo_audit.py`, `sample_urls.txt`, `run_audit.py`

#### Web/API delivery layer
The Flask dashboard provides browser-facing single and batch submission flows, progress/result presentation, and report download behavior. It also exposes the audit capability as an HTTP API, separating request/UI handling from the underlying audit engine and batch executor. HTML rendering is server-template based rather than a separate frontend application.

Grounding: `web_dashboard.py`, `templates/index.html`, `run_audit.py`

#### Deployment-facing API surface
A second Python HTTP entry point exists under `api/`, likely intended for serverless deployment. Vercel configuration, a Procfile, build script, runtime pin, and separate API dependencies indicate two hosting models: a conventional Flask process and a Vercel-compatible API deployment. Engineers should reconcile behavior/dependencies between these surfaces when changing audit endpoints.

Grounding: `api/index.py`, `api/requirements.txt`, `vercel.json`

#### Material runtime and artifacts
The system runs on Python with dependencies declared both globally and for the API deployment. It requires network egress and uses local filesystem output for generated report artifacts; checked-in example audit JSON files demonstrate the persisted report shape. Static HTML files at the repository root appear to be alternate/prototype dashboard pages, while the deployed template is under `templates/`.

Grounding: `requirements.txt`, `runtime.txt`, `seo_audit_example.com_20250804_153508.json`

Main entry points: [`batch_seo_audit.py`](https://github.com/bhwthy/seo-audit-tool/blob/main/batch_seo_audit.py) (BatchSEOAuditor), [`seo_audit.py`](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py) (SEOAuditor), [`web_dashboard.py`](https://github.com/bhwthy/seo-audit-tool/blob/main/web_dashboard.py) (Flask dashboard), [`run_audit.py`](https://github.com/bhwthy/seo-audit-tool/blob/main/run_audit.py) (CLI dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI dispatcher<br/>Python entry point<br/>[run_audit.py]"]
  node_url_file["Batch URL input<br/>URL list<br/>[sample_urls.txt]"]
end

subgraph group_engine["Audit engine"]
  node_auditor["SEOAuditor<br/>single-page audit<br/>[seo_audit.py]"]
  node_http{{"HTTP session<br/>remote fetch<br/>[seo_audit.py]"}}
  node_html["HTML analysis<br/>parser and checks<br/>[seo_audit.py]"]
  node_scoring["Score and grade<br/>rule scoring<br/>[seo_audit.py]"]
  node_batch["BatchSEOAuditor<br/>concurrent orchestrator<br/>[batch_seo_audit.py]"]
end

subgraph group_delivery["Delivery and deployment"]
  node_dashboard["Flask dashboard<br/>web and API layer<br/>[web_dashboard.py]"]
  node_template["Dashboard template<br/>server HTML<br/>[index.html]"]
  node_serverless_api["Serverless API<br/>deployment HTTP entry<br/>[index.py]"]
  node_vercel{{"Vercel deployment<br/>serverless configuration<br/>[vercel.json]"}}
  node_python_deps["Python runtime<br/>dependencies<br/>[requirements.txt]"]
  node_api_deps["API dependencies<br/>deployment dependencies<br/>[requirements.txt]"]
end

subgraph group_outputs["Reports"]
  node_report["Audit result<br/>detailed result and summary"]
  node_exports["JSON and CSV exports<br/>report artifacts<br/>[batch_seo_audit.py]"]
  node_example_report["Persisted example report<br/>JSON artifact"]
end

node_target_sites{{"Audited websites<br/>external HTTP&#40;S&#41;"}}

node_cli -->|"single audit"| node_auditor
node_cli -->|"batch audit"| node_batch
node_cli -->|"launches"| node_dashboard
node_url_file -->|"URLs"| node_batch
node_batch -->|"concurrent audits"| node_auditor
node_auditor -->|"fetches URL"| node_http
node_http -->|"outbound HTTP&#40;S&#41;"| node_target_sites
node_http -->|"response HTML and headers"| node_html
node_html -->|"findings"| node_scoring
node_scoring -->|"results and summary"| node_report
node_batch -->|"exports JSON/CSV"| node_exports
node_batch -->|"aggregates"| node_report
node_dashboard -->|"single submission"| node_auditor
node_dashboard -->|"batch submission"| node_batch
node_dashboard -->|"renders"| node_template
node_dashboard -->|"downloads"| node_exports
node_serverless_api -->|"audit endpoint"| node_auditor
node_vercel -->|"deploys"| node_serverless_api
node_python_deps -.->|"runtime libraries"| node_auditor
node_api_deps -.->|"deployment libraries"| node_serverless_api
node_report -.->|"persisted shape"| node_example_report

click node_cli "https://github.com/bhwthy/seo-audit-tool/blob/main/run_audit.py"
click node_auditor "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py"
click node_http "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py"
click node_html "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py"
click node_scoring "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py"
click node_batch "https://github.com/bhwthy/seo-audit-tool/blob/main/batch_seo_audit.py"
click node_url_file "https://github.com/bhwthy/seo-audit-tool/blob/main/sample_urls.txt"
click node_dashboard "https://github.com/bhwthy/seo-audit-tool/blob/main/web_dashboard.py"
click node_template "https://github.com/bhwthy/seo-audit-tool/blob/main/templates/index.html"
click node_serverless_api "https://github.com/bhwthy/seo-audit-tool/blob/main/api/index.py"
click node_vercel "https://github.com/bhwthy/seo-audit-tool/blob/main/vercel.json"
click node_python_deps "https://github.com/bhwthy/seo-audit-tool/blob/main/requirements.txt"
click node_api_deps "https://github.com/bhwthy/seo-audit-tool/blob/main/api/requirements.txt"
click node_report "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit_example.com_20250804_152323.json"
click node_exports "https://github.com/bhwthy/seo-audit-tool/blob/main/batch_seo_audit.py"
click node_example_report "https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit_example.com_20250804_153508.json"

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_cli,node_url_file toneBlue
class node_auditor,node_http,node_html,node_scoring,node_batch toneAmber
class node_dashboard,node_template,node_serverless_api,node_vercel,node_python_deps,node_api_deps toneMint
class node_report,node_exports,node_example_report toneRose
class node_target_sites toneNeutral
```

## Components

### Entry points

- [CLI dispatcher](https://github.com/bhwthy/seo-audit-tool/blob/main/run_audit.py): Python entry point · Selects single, batch, or dashboard execution. · `run_audit.py`
- [Batch URL input](https://github.com/bhwthy/seo-audit-tool/blob/main/sample_urls.txt): URL list · `sample_urls.txt`

### Audit engine

- [SEOAuditor](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py): single-page audit · Authoritative URL analysis pipeline. · `seo_audit.py`
- [HTTP session](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py): remote fetch · Retrieves audited pages and response metadata. · `seo_audit.py`
- [HTML analysis](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py): parser and checks · Extracts technical, metadata, content, image, link, social, and schema findings. · `seo_audit.py`
- [Score and grade](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit.py): rule scoring · Combines findings into numeric and letter SEO health results. · `seo_audit.py`
- [BatchSEOAuditor](https://github.com/bhwthy/seo-audit-tool/blob/main/batch_seo_audit.py): concurrent orchestrator · Runs independent audits and identifies cross-site patterns. · `batch_seo_audit.py`

### Delivery and deployment

- [Flask dashboard](https://github.com/bhwthy/seo-audit-tool/blob/main/web_dashboard.py): web and API layer · Accepts audit submissions, renders progress/results, and serves downloads. · `web_dashboard.py`
- [Dashboard template](https://github.com/bhwthy/seo-audit-tool/blob/main/templates/index.html): server HTML · `templates/index.html`
- [Serverless API](https://github.com/bhwthy/seo-audit-tool/blob/main/api/index.py): deployment HTTP entry · Alternate Vercel-compatible audit endpoint. · `api/index.py`
- [Vercel deployment](https://github.com/bhwthy/seo-audit-tool/blob/main/vercel.json): serverless configuration · `vercel.json`
- [Python runtime](https://github.com/bhwthy/seo-audit-tool/blob/main/requirements.txt): dependencies · Global runtime dependencies support audit execution and network access. · `requirements.txt`
- [API dependencies](https://github.com/bhwthy/seo-audit-tool/blob/main/api/requirements.txt): deployment dependencies · Separate dependency set for the API deployment. · `api/requirements.txt`

### Reports

- [Audit result](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit_example.com_20250804_152323.json): detailed result and summary · Structured findings, score, grade, and aggregate comparisons. · `seo_audit_example.com_20250804_152323.json`
- [JSON and CSV exports](https://github.com/bhwthy/seo-audit-tool/blob/main/batch_seo_audit.py): report artifacts · Batch results are written for automation and spreadsheet consumers. · `batch_seo_audit.py`
- [Persisted example report](https://github.com/bhwthy/seo-audit-tool/blob/main/seo_audit_example.com_20250804_153508.json): JSON artifact · Demonstrates the local filesystem report shape. · `seo_audit_example.com_20250804_153508.json`

### Other components

- **Audited websites**: external HTTP(S) · Remote availability, redirects, TLS, markup, and linked resources govern audit completeness.

## Connections

- CLI dispatcher → SEOAuditor: single audit
- CLI dispatcher → BatchSEOAuditor: batch audit
- CLI dispatcher → Flask dashboard: launches
- Batch URL input → BatchSEOAuditor: URLs
- BatchSEOAuditor → SEOAuditor: concurrent audits
- SEOAuditor → HTTP session: fetches URL
- HTTP session → Audited websites: outbound HTTP(S)
- HTTP session → HTML analysis: response HTML and headers
- HTML analysis → Score and grade: findings
- Score and grade → Audit result: results and summary
- BatchSEOAuditor → JSON and CSV exports: exports JSON/CSV
- BatchSEOAuditor → Audit result: aggregates
- Flask dashboard → SEOAuditor: single submission
- Flask dashboard → BatchSEOAuditor: batch submission
- Flask dashboard → Dashboard template: renders
- Flask dashboard → JSON and CSV exports: downloads
- Serverless API → SEOAuditor: audit endpoint
- Vercel deployment → Serverless API: deploys
- Python runtime → SEOAuditor: runtime libraries
- API dependencies → Serverless API: deployment libraries
- Audit result → Persisted example report: persisted shape
