# saberops/ai_pentest_agent_2 architecture

> Architecture diagram of the GitHub repository saberops/ai_pentest_agent_2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saberops/ai_pentest_agent_2
- Repository: https://github.com/saberops/ai_pentest_agent_2

## Overview

AI Pentester is an authorized security-assessment starter with a CLI and FastAPI entry point. Both expose scan requests through the shared scan service, which validates module selection and invokes a LangGraph workflow; the README cautions that scanner modules are placeholders, so this is not yet an executing scanner pipeline. The product also includes scope allowlisting and JSON-to-HTML reporting. Edges reflect shown calls or explicit README statements; scanner execution and database wiring are not evidenced, and the workflow graph excerpt is empty.

Main entry points: [`cli/main.py`](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/main.py) (Typer CLI), [`cli/commands/scan.py`](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/scan.py) (Scan command), [`backend/app/services/scan_service.py`](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/services/scan_service.py) (Scan service), [`cli/commands/report.py`](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/report.py) (Report command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_cli["Typer CLI<br/>[main.py]"]
  node_api["FastAPI API<br/>[main.py]"]
  node_scan_command["Scan command<br/>[scan.py]"]
end

subgraph group_workflow["Scan workflow"]
  node_scan_service["Scan service<br/>[scan_service.py]"]
  node_scan_graph["LangGraph workflow<br/>[graph.py]"]
  node_scan_schema["Scan state<br/>[scan.py]"]
  node_finding_schema["Finding schema<br/>[finding.py]"]
end

subgraph group_modules["Assessment modules"]
  node_network_scanner["Network scanner<br/>[scanner.py]"]
  node_http_scanner["HTTP scanner<br/>[scanner.py]"]
  node_sqli_scanner["SQLi scanner<br/>[scanner.py]"]
  node_xss_scanner["XSS scanner<br/>[scanner.py]"]
end

subgraph group_support["Controls and reporting"]
  node_scope_validator["Scope validator<br/>[scope_validator.py]"]
  node_config["App configuration<br/>[config.py]"]
  node_tools_command["Tools command<br/>[tools.py]"]
  node_report_command["Report command<br/>[report.py]"]
end

node_operator(("Assessment operator"))
node_report_file["JSON scan result"]
node_html_report["HTML report"]
node_openrouter["OpenRouter"]

node_operator -->|"runs commands"| node_cli
node_operator -->|"submits scans"| node_api
node_cli -->|"registers"| node_scan_command
node_cli -->|"registers"| node_report_command
node_cli -->|"registers"| node_tools_command
node_scan_command -->|"calls"| node_scan_service
node_api -->|"calls"| node_scan_service
node_scan_service -->|"invokes"| node_scan_graph
node_scan_schema -->|"uses"| node_finding_schema
node_scan_command -->|"writes JSON"| node_report_file
node_scan_command -->|"writes HTML"| node_html_report
node_report_file -->|"reads JSON"| node_report_command
node_report_command -->|"writes HTML"| node_html_report
node_scope_validator -.->|"gates requests"| node_scan_service
node_config -->|"configures"| node_openrouter

click node_cli "https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/main.py"
click node_api "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/main.py"
click node_scan_command "https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/scan.py"
click node_scan_service "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/services/scan_service.py"
click node_scan_graph "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/agents/graph.py"
click node_scan_schema "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/schemas/scan.py"
click node_finding_schema "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/schemas/finding.py"
click node_network_scanner "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/network/scanner.py"
click node_http_scanner "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/http/scanner.py"
click node_sqli_scanner "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/sqli/scanner.py"
click node_xss_scanner "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/xss/scanner.py"
click node_scope_validator "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/core/scope_validator.py"
click node_config "https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/core/config.py"
click node_tools_command "https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/tools.py"
click node_report_command "https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/report.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_cli,node_api,node_scan_command toneBlue
class node_scan_service,node_scan_graph,node_scan_schema,node_finding_schema toneAmber
class node_network_scanner,node_http_scanner,node_sqli_scanner,node_xss_scanner,node_openrouter toneMint
class node_scope_validator,node_config,node_tools_command,node_report_command toneRose
class node_operator,node_report_file,node_html_report toneIndigo
```

## Components

### User entry points

- [Typer CLI](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/main.py): `cli/main.py`
- [FastAPI API](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/main.py): `backend/app/main.py`
- [Scan command](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/scan.py): `cli/commands/scan.py`

### Scan workflow

- [Scan service](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/services/scan_service.py): `backend/app/services/scan_service.py`
- [LangGraph workflow](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/agents/graph.py): `backend/app/agents/graph.py`
- [Scan state](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/schemas/scan.py): `backend/app/schemas/scan.py`
- [Finding schema](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/schemas/finding.py): `backend/app/schemas/finding.py`

### Assessment modules

- [Network scanner](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/network/scanner.py): `backend/app/modules/network/scanner.py`
- [HTTP scanner](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/http/scanner.py): `backend/app/modules/http/scanner.py`
- [SQLi scanner](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/sqli/scanner.py): `backend/app/modules/sqli/scanner.py`
- [XSS scanner](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/modules/xss/scanner.py): `backend/app/modules/xss/scanner.py`

### Controls and reporting

- [Scope validator](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/core/scope_validator.py): `backend/app/core/scope_validator.py`
- [App configuration](https://github.com/saberops/ai_pentest_agent_2/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Tools command](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/tools.py): `cli/commands/tools.py`
- [Report command](https://github.com/saberops/ai_pentest_agent_2/blob/main/cli/commands/report.py): `cli/commands/report.py`

### Other components

- **Assessment operator**
- **JSON scan result**
- **HTML report**
- **OpenRouter**

## Connections

- Assessment operator → Typer CLI: runs commands (evidence: `cli/main.py`)
- Assessment operator → FastAPI API: submits scans (evidence: `README.md`)
- Typer CLI → Scan command: registers (evidence: `cli/main.py`)
- Typer CLI → Report command: registers (evidence: `cli/main.py`)
- Typer CLI → Tools command: registers (evidence: `cli/main.py`)
- Scan command → Scan service: calls (evidence: `cli/commands/scan.py`)
- FastAPI API → Scan service: calls (evidence: `backend/app/main.py`)
- Scan service → LangGraph workflow: invokes (evidence: `backend/app/services/scan_service.py`)
- Scan state → Finding schema: uses (evidence: `backend/app/schemas/scan.py`)
- Scan command → JSON scan result: writes JSON (evidence: `cli/commands/scan.py`)
- Scan command → HTML report: writes HTML (evidence: `cli/commands/scan.py`)
- JSON scan result → Report command: reads JSON (evidence: `cli/commands/report.py`)
- Report command → HTML report: writes HTML (evidence: `cli/commands/report.py`)
- Scope validator → Scan service: gates requests (evidence: `README.md`)
- App configuration → OpenRouter: configures
