# mgrant8792/portscannerpro architecture

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

- Interactive diagram: https://gitdiagram.com/mgrant8792/portscannerpro
- Repository: https://github.com/mgrant8792/portscannerpro

## Overview

PortScannerPro is a command-line TCP port scanner for authorized testing. The user supplies a host and port selection; the CLI parses the ports, runs concurrent connection checks, annotates results with common-service guesses, prints a summary, and optionally writes JSON or CSV. The sampled source supports these runtime links; the network target and output destinations are external.

Main entry points: [`port_scanner.py`](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py) (CLI orchestration), [`common_ports.py`](https://github.com/mgrant8792/portscannerpro/blob/main/common_ports.py) (Common service lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli_entry["CLI orchestration<br/>[port_scanner.py]"]
  node_port_parser["Port selection parser<br/>[port_scanner.py]"]
end

subgraph group_scanning["Port scanning"]
  node_scan_host["Concurrent host scan<br/>[port_scanner.py]"]
  node_scan_port["TCP connection check<br/>[port_scanner.py]"]
  node_service_lookup["Common service lookup<br/>[common_ports.py]"]
end

subgraph group_reporting["Results and export"]
  node_summary["Terminal summary<br/>[port_scanner.py]"]
  node_json_export["JSON export<br/>[port_scanner.py]"]
  node_csv_export["CSV export<br/>[port_scanner.py]"]
end

node_user(("User"))
node_target(("Target host"))
node_terminal["Terminal"]
node_json_file["JSON output file"]
node_csv_file["CSV output file"]

node_user -->|"runs"| node_cli_entry
node_cli_entry -->|"parses ports"| node_port_parser
node_cli_entry -->|"starts scan"| node_scan_host
node_scan_host -->|"dispatches checks"| node_scan_port
node_scan_port -->|"connects to"| node_target
node_scan_host -->|"reads guesses"| node_service_lookup
node_cli_entry -->|"prints results"| node_summary
node_summary -->|"writes summary"| node_terminal
node_cli_entry -->|"calls when requested"| node_json_export
node_json_export -->|"writes JSON"| node_json_file
node_cli_entry -->|"calls when requested"| node_csv_export
node_csv_export -->|"writes CSV"| node_csv_file

click node_cli_entry "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_port_parser "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_scan_host "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_scan_port "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_service_lookup "https://github.com/mgrant8792/portscannerpro/blob/main/common_ports.py"
click node_summary "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_json_export "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py"
click node_csv_export "https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.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_entry,node_port_parser,node_user toneBlue
class node_scan_host,node_scan_port,node_service_lookup toneAmber
class node_summary,node_json_export,node_csv_export toneMint
class node_target,node_terminal,node_json_file,node_csv_file toneIndigo
```

## Components

### CLI workflow

- [CLI orchestration](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`
- [Port selection parser](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`

### Port scanning

- [Concurrent host scan](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`
- [TCP connection check](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`
- [Common service lookup](https://github.com/mgrant8792/portscannerpro/blob/main/common_ports.py): `common_ports.py`

### Results and export

- [Terminal summary](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`
- [JSON export](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`
- [CSV export](https://github.com/mgrant8792/portscannerpro/blob/main/port_scanner.py): `port_scanner.py`

### Other components

- **User**
- **Target host**
- **Terminal**
- **JSON output file**
- **CSV output file**

## Connections

- User → CLI orchestration: runs
- CLI orchestration → Port selection parser: parses ports
- CLI orchestration → Concurrent host scan: starts scan
- Concurrent host scan → TCP connection check: dispatches checks
- TCP connection check → Target host: connects to
- Concurrent host scan → Common service lookup: reads guesses
- CLI orchestration → Terminal summary: prints results
- Terminal summary → Terminal: writes summary
- CLI orchestration → JSON export: calls when requested
- JSON export → JSON output file: writes JSON
- CLI orchestration → CSV export: calls when requested
- CSV export → CSV output file: writes CSV
