# chleba/netscanner architecture

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

- Interactive diagram: https://gitdiagram.com/chleba/netscanner
- Repository: https://github.com/chleba/netscanner

## Overview

netscanner is a terminal network-scanning and diagnostics application. Users select an interface and scan a CIDR for IPv4 hosts, then inspect hosts, TCP ports, captured packets, and traffic; they can also scan Wi-Fi networks, view signal charts, filter packet logs, and export results. The app coordinates a Ratatui event loop and feature components through actions. The README documents these capabilities; sampled source confirms parts of the event, packet-capture, discovery, and port-scan behavior, while wiring for unsampled components is not inferred.

Main entry points: [`src/app.rs`](https://github.com/chleba/netscanner/blob/main/src/app.rs) (App coordinator), [`src/action.rs`](https://github.com/chleba/netscanner/blob/main/src/action.rs) (Action messages), [`src/components/discovery.rs`](https://github.com/chleba/netscanner/blob/main/src/components/discovery.rs) (CIDR discovery), [`src/components/ports.rs`](https://github.com/chleba/netscanner/blob/main/src/components/ports.rs) (TCP port scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Program entry<br/>[main.rs]"]
  node_cli["CLI options<br/>[cli.rs]"]
  node_app["App coordinator<br/>[app.rs]"]
  node_tui["Terminal events<br/>[tui.rs]"]
  node_config["Keybindings config<br/>[config.rs]"]
  node_actions["Action messages<br/>[action.rs]"]
end

subgraph group_network["Network discovery"]
  node_interfaces["Interface selection<br/>[interfaces.rs]"]
  node_discovery["CIDR discovery<br/>[discovery.rs]"]
  node_ports["TCP port scan<br/>[ports.rs]"]
  node_host_services["Network services"]
end

subgraph group_inspection["Traffic inspection"]
  node_packetdump["Packet capture<br/>[packetdump.rs]"]
  node_sniff["Traffic accounting<br/>[sniff.rs]"]
  node_traffic_view["Traffic chart<br/>[scroll_traffic.rs]"]
end

subgraph group_wireless["Wi-Fi tools"]
  node_wifi_scan["Wi-Fi scanning<br/>[wifi_scan.rs]"]
  node_wifi_interface["Wi-Fi interface<br/>[wifi_interface.rs]"]
  node_wifi_chart["Signal chart<br/>[wifi_chart.rs]"]
end

subgraph group_output["Results and export"]
  node_export["CSV export<br/>[export.rs]"]
  node_packet_logs["Packet logs and filters<br/>[packetdump.rs]"]
end

node_user(("Operator"))
node_network(("Host network"))
node_wifi_service(("Wi-Fi scan service"))
node_dns(("DNS lookup"))
node_csv_files[("CSV files")]

node_user -->|"starts"| node_main
node_main -->|"parses options"| node_cli
node_main -->|"runs"| node_app
node_user -->|"provides input"| node_tui
node_tui -->|"sends events"| node_app
node_app -->|"reads bindings"| node_config
node_app -->|"dispatches events"| node_interfaces
node_app -->|"dispatches events"| node_discovery
node_app -->|"dispatches actions"| node_ports
node_app -->|"dispatches actions"| node_packetdump
node_app -->|"dispatches actions"| node_sniff
node_app -->|"dispatches events"| node_wifi_scan
node_app -->|"dispatches events"| node_wifi_interface
node_app -->|"dispatches events"| node_wifi_chart
node_app -->|"dispatches export"| node_export
node_interfaces -->|"emits actions"| node_actions
node_discovery -->|"emits scan results"| node_actions
node_ports -->|"emits scan results"| node_actions
node_packetdump -->|"emits packets"| node_actions
node_app -->|"routes actions"| node_actions
node_interfaces -->|"lists interfaces"| node_network
node_discovery -->|"probes hosts"| node_network
node_ports -->|"tests TCP ports"| node_network
node_packetdump -->|"captures packets"| node_network
node_discovery -->|"resolves hostnames"| node_dns
node_ports -->|"looks up names"| node_dns
node_wifi_scan -->|"scans networks"| node_wifi_service
node_app -->|"delivers packet actions"| node_sniff
node_sniff -->|"renders traffic"| node_traffic_view
node_packetdump -->|"records and filters"| node_packet_logs
node_export -->|"writes exports"| node_csv_files
node_app -->|"selects active interface"| node_wifi_interface
node_wifi_scan -->|"provides signal data"| node_wifi_chart

click node_main "https://github.com/chleba/netscanner/blob/main/src/main.rs"
click node_cli "https://github.com/chleba/netscanner/blob/main/src/cli.rs"
click node_app "https://github.com/chleba/netscanner/blob/main/src/app.rs"
click node_tui "https://github.com/chleba/netscanner/blob/main/src/tui.rs"
click node_config "https://github.com/chleba/netscanner/blob/main/src/config.rs"
click node_actions "https://github.com/chleba/netscanner/blob/main/src/action.rs"
click node_interfaces "https://github.com/chleba/netscanner/blob/main/src/components/interfaces.rs"
click node_discovery "https://github.com/chleba/netscanner/blob/main/src/components/discovery.rs"
click node_ports "https://github.com/chleba/netscanner/blob/main/src/components/ports.rs"
click node_packetdump "https://github.com/chleba/netscanner/blob/main/src/components/packetdump.rs"
click node_sniff "https://github.com/chleba/netscanner/blob/main/src/components/sniff.rs"
click node_traffic_view "https://github.com/chleba/netscanner/blob/main/src/widgets/scroll_traffic.rs"
click node_wifi_scan "https://github.com/chleba/netscanner/blob/main/src/components/wifi_scan.rs"
click node_wifi_interface "https://github.com/chleba/netscanner/blob/main/src/components/wifi_interface.rs"
click node_wifi_chart "https://github.com/chleba/netscanner/blob/main/src/components/wifi_chart.rs"
click node_export "https://github.com/chleba/netscanner/blob/main/src/components/export.rs"
click node_packet_logs "https://github.com/chleba/netscanner/blob/main/src/components/packetdump.rs"

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_cli,node_app,node_tui,node_config,node_actions toneBlue
class node_interfaces,node_discovery,node_ports,node_host_services,node_csv_files toneAmber
class node_packetdump,node_sniff,node_traffic_view toneMint
class node_wifi_scan,node_wifi_interface,node_wifi_chart toneRose
class node_export,node_packet_logs,node_user,node_network,node_wifi_service,node_dns toneIndigo
```

## Components

### Application runtime

- [Program entry](https://github.com/chleba/netscanner/blob/main/src/main.rs): `src/main.rs`
- [CLI options](https://github.com/chleba/netscanner/blob/main/src/cli.rs): `src/cli.rs`
- [App coordinator](https://github.com/chleba/netscanner/blob/main/src/app.rs): `src/app.rs`
- [Terminal events](https://github.com/chleba/netscanner/blob/main/src/tui.rs): `src/tui.rs`
- [Keybindings config](https://github.com/chleba/netscanner/blob/main/src/config.rs): `src/config.rs`
- [Action messages](https://github.com/chleba/netscanner/blob/main/src/action.rs): `src/action.rs`

### Network discovery

- [Interface selection](https://github.com/chleba/netscanner/blob/main/src/components/interfaces.rs): `src/components/interfaces.rs`
- [CIDR discovery](https://github.com/chleba/netscanner/blob/main/src/components/discovery.rs): `src/components/discovery.rs`
- [TCP port scan](https://github.com/chleba/netscanner/blob/main/src/components/ports.rs): `src/components/ports.rs`
- **Network services**

### Traffic inspection

- [Packet capture](https://github.com/chleba/netscanner/blob/main/src/components/packetdump.rs): `src/components/packetdump.rs`
- [Traffic accounting](https://github.com/chleba/netscanner/blob/main/src/components/sniff.rs): `src/components/sniff.rs`
- [Traffic chart](https://github.com/chleba/netscanner/blob/main/src/widgets/scroll_traffic.rs): `src/widgets/scroll_traffic.rs`

### Wi-Fi tools

- [Wi-Fi scanning](https://github.com/chleba/netscanner/blob/main/src/components/wifi_scan.rs): `src/components/wifi_scan.rs`
- [Wi-Fi interface](https://github.com/chleba/netscanner/blob/main/src/components/wifi_interface.rs): `src/components/wifi_interface.rs`
- [Signal chart](https://github.com/chleba/netscanner/blob/main/src/components/wifi_chart.rs): `src/components/wifi_chart.rs`

### Results and export

- [CSV export](https://github.com/chleba/netscanner/blob/main/src/components/export.rs): `src/components/export.rs`
- [Packet logs and filters](https://github.com/chleba/netscanner/blob/main/src/components/packetdump.rs): `src/components/packetdump.rs`

### Other components

- **Operator**
- **Host network**
- **Wi-Fi scan service**
- **DNS lookup**
- **CSV files**

## Connections

- Operator → Program entry: starts
- Program entry → CLI options: parses options
- Program entry → App coordinator: runs
- Operator → Terminal events: provides input
- Terminal events → App coordinator: sends events
- App coordinator → Keybindings config: reads bindings
- App coordinator → Interface selection: dispatches events
- App coordinator → CIDR discovery: dispatches events
- App coordinator → TCP port scan: dispatches actions
- App coordinator → Packet capture: dispatches actions
- App coordinator → Traffic accounting: dispatches actions
- App coordinator → Wi-Fi scanning: dispatches events
- App coordinator → Wi-Fi interface: dispatches events
- App coordinator → Signal chart: dispatches events
- App coordinator → CSV export: dispatches export
- Interface selection → Action messages: emits actions
- CIDR discovery → Action messages: emits scan results
- TCP port scan → Action messages: emits scan results
- Packet capture → Action messages: emits packets
- App coordinator → Action messages: routes actions
- Interface selection → Host network: lists interfaces
- CIDR discovery → Host network: probes hosts
- TCP port scan → Host network: tests TCP ports
- Packet capture → Host network: captures packets
- CIDR discovery → DNS lookup: resolves hostnames
- TCP port scan → DNS lookup: looks up names
- Wi-Fi scanning → Wi-Fi scan service: scans networks
- App coordinator → Traffic accounting: delivers packet actions
- Traffic accounting → Traffic chart: renders traffic
- Packet capture → Packet logs and filters: records and filters
- CSV export → CSV files: writes exports
- App coordinator → Wi-Fi interface: selects active interface
- Wi-Fi scanning → Signal chart: provides signal data
