# 3mper0rr/scan-automation-engine-toolv2 architecture

> Architecture diagram of the GitHub repository 3mper0rr/scan-automation-engine-toolv2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/3mper0rr/scan-automation-engine-toolv2
- Repository: https://github.com/3mper0rr/scan-automation-engine-toolv2

## Overview

#### Purpose and Entry Point
This is a Python 3.10 CLI security-scan automation engine. It scans a supplied target with Nmap, parses discovered services, recommends candidate Metasploit modules, optionally obtains AI analysis, and renders or exports a report.

Primary entry point: `scan automation engine/main.py`.

#### CLI Orchestration
`main.py` owns command-line flow: target selection, scan profile (`quick`, `standard`, `aggressive`), rule-layer enablement, AI prompting, and Markdown/JSON export selection. It coordinates scanner, advisor, and output layers rather than exposing a web or service API.

Paths:
- `scan automation engine/main.py`
- `scan automation engine/config.py`

#### Nmap Scan Boundary
The scanner layer is the system boundary to the locally installed Nmap executable. It converts the chosen profile into an Nmap invocation and collects scan output for downstream processing. Nmap is a required external runtime and likely requires network access and appropriate scan privileges.

Paths:
- `scan automation engine/scanner/nmap_runner.py`
- `scan automation engine/config.py`

#### Structured Scan Parsing
Nmap output is transformed into application-level findings—principally hosts, open ports, services, and version/context data. This parsing boundary isolates advisor logic from raw scanner output and provides the data model used for reporting and recommendations.

Paths:
- `scan automation engine/scanner/report_parser.py`
- `scan automation engine/scanner/nmap_runner.py`

#### Rule-Based Exploit Advisory
The advisory pipeline maps parsed service findings to candidate Metasploit modules. A local module database supports matching/filtering, while the recommender applies rules unless the user passes `--no-rules`. This produces actionable candidates, not exploit execution.

Paths:
- `scan automation engine/advisor/msf_modules_db.py`
- `scan automation engine/advisor/recommender.py`

#### Optional AI Analysis
When `--ai` is enabled, scan findings and recommended modules are supplied to an AI-analysis adapter, optionally augmented by a user prompt. The README describes multi-provider readiness for OpenAI, Anthropic, and Nvidia; provider credentials and request configuration are expected to be managed outside the scanning core.

Paths:
- `scan automation engine/advisor/ai_analyst.py`
- `scan automation engine/config.py`

#### Presentation and Export
The final aggregated report flows to terminal-oriented rich formatting and optional file export. Markdown is the default documented report style; JSON is selected with `--fmt json`. Output is downstream of scanning, rule evaluation, and optional AI enrichment.

Paths:
- `scan automation engine/output/formatter.py`
- `scan automation engine/main.py`

#### Primary Control Flow
`main.py` parses CLI options → `nmap_runner.py` executes the selected scan → `report_parser.py` normalizes findings → `recommender.py` consults `msf_modules_db.py` for module candidates → optional `ai_analyst.py` enriches conclusions → `formatter.py` prints and/or exports the consolidated report.

Main entry points: [`scan automation engine/advisor/recommender.py`](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/advisor/recommender.py) (Rule recommender), [`scan automation engine/main.py`](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/main.py) (CLI entry point), [`scan automation engine/scanner/nmap_runner.py`](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/scanner/nmap_runner.py) (Nmap runner), [`scan automation engine/advisor/ai_analyst.py`](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/advisor/ai_analyst.py) (AI analyst)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI orchestration"]
  node_main["CLI entry point<br/>Python CLI<br/>[main.py]"]
  node_config["Runtime configuration<br/>Python config<br/>[config.py]"]
end

subgraph group_scanning["Scan pipeline"]
  node_nmap_runner["Nmap runner<br/>scanner adapter<br/>[nmap_runner.py]"]
  node_nmap{{"Local Nmap<br/>external runtime"}}
  node_report_parser["Findings parser<br/>scan parser<br/>[report_parser.py]"]
end

subgraph group_advisory["Advisory pipeline"]
  node_msf_db[("Module database<br/>module catalog<br/>[msf_modules_db.py]")]
  node_recommender["Rule recommender<br/>advisory engine<br/>[recommender.py]"]
  node_ai_analyst["AI analyst<br/>optional AI adapter<br/>[ai_analyst.py]"]
  node_ai_provider{{"AI provider<br/>external service"}}
end

subgraph group_output["Reporting"]
  node_formatter["Report formatter<br/>output renderer<br/>[formatter.py]"]
end

node_main -->|"loads"| node_config
node_main -->|"starts selected scan"| node_nmap_runner
node_config -->|"scan settings"| node_nmap_runner
node_nmap_runner -->|"executes"| node_nmap
node_nmap -->|"raw scan output"| node_nmap_runner
node_nmap_runner -->|"scan output"| node_report_parser
node_report_parser -->|"normalized findings"| node_recommender
node_recommender -->|"matches against"| node_msf_db
node_msf_db -->|"module candidates"| node_recommender
node_main -.->|"enables rules"| node_recommender
node_recommender -.->|"findings and recommendations"| node_ai_analyst
node_main -.->|"--ai prompt"| node_ai_analyst
node_config -.->|"provider settings"| node_ai_analyst
node_ai_analyst -.->|"analysis request"| node_ai_provider
node_report_parser -->|"findings"| node_formatter
node_recommender -->|"recommendations"| node_formatter
node_ai_analyst -.->|"optional enrichment"| node_formatter
node_main -->|"format and export selection"| node_formatter

click node_main "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/main.py"
click node_config "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/config.py"
click node_nmap_runner "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/scanner/nmap_runner.py"
click node_report_parser "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/scanner/report_parser.py"
click node_msf_db "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/advisor/msf_modules_db.py"
click node_recommender "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/advisor/recommender.py"
click node_ai_analyst "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/advisor/ai_analyst.py"
click node_formatter "https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/main/scan automation engine/output/formatter.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_main,node_config toneBlue
class node_nmap_runner,node_nmap,node_report_parser toneAmber
class node_msf_db,node_recommender,node_ai_analyst,node_ai_provider toneMint
class node_formatter toneRose
```

## Components

### CLI orchestration

- [CLI entry point](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/main.py): Python CLI · Selects target, profile, options, and report format. · `scan automation engine/main.py`
- [Runtime configuration](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/config.py): Python config · Supplies scan and AI-related settings. · `scan automation engine/config.py`

### Scan pipeline

- [Nmap runner](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/scanner/nmap_runner.py): scanner adapter · Builds profile-specific Nmap invocations and collects output. · `scan automation engine/scanner/nmap_runner.py`
- **Local Nmap**: external runtime · Performs network scanning with required access and privileges.
- [Findings parser](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/scanner/report_parser.py): scan parser · Normalizes raw scan output into hosts, ports, services, and context. · `scan automation engine/scanner/report_parser.py`

### Advisory pipeline

- [Module database](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/advisor/msf_modules_db.py): module catalog · Local data used to match service findings to Metasploit modules. · `scan automation engine/advisor/msf_modules_db.py`
- [Rule recommender](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/advisor/recommender.py): advisory engine · Produces candidate modules when rule evaluation is enabled. · `scan automation engine/advisor/recommender.py`
- [AI analyst](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/advisor/ai_analyst.py): optional AI adapter · Enriches findings and module recommendations using a selected provider. · `scan automation engine/advisor/ai_analyst.py`
- **AI provider**: external service · Optional OpenAI, Anthropic, or Nvidia analysis backend.

### Reporting

- [Report formatter](https://github.com/3mper0rr/scan-automation-engine-toolv2/blob/HEAD/scan%20automation%20engine/output/formatter.py): output renderer · Prints terminal output and exports Markdown or JSON reports. · `scan automation engine/output/formatter.py`

## Connections

- CLI entry point → Runtime configuration: loads
- CLI entry point → Nmap runner: starts selected scan
- Runtime configuration → Nmap runner: scan settings
- Nmap runner → Local Nmap: executes
- Local Nmap → Nmap runner: raw scan output
- Nmap runner → Findings parser: scan output
- Findings parser → Rule recommender: normalized findings
- Rule recommender → Module database: matches against
- Module database → Rule recommender: module candidates
- CLI entry point → Rule recommender: enables rules
- Rule recommender → AI analyst: findings and recommendations
- CLI entry point → AI analyst: --ai prompt
- Runtime configuration → AI analyst: provider settings
- AI analyst → AI provider: analysis request
- Findings parser → Report formatter: findings
- Rule recommender → Report formatter: recommendations
- AI analyst → Report formatter: optional enrichment
- CLI entry point → Report formatter: format and export selection
