# smk1367/scan architecture

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

- Interactive diagram: https://gitdiagram.com/smk1367/scan
- Repository: https://github.com/smk1367/scan

## Overview

Wireless Monitor Enterprise is a web dashboard and multi-city wireless-device monitor. Users browse cities and device details, or start a scan; the service scans configured targets, collects device data, and exposes results and scan history. The README also describes blacklist/manual-radio management, Excel import/export, automatic backups, and history retention. Source excerpts show the web and persistence boundaries, but omit the background worker implementation, so uncertain internal scan wiring is not expanded.

Main entry points: [`app.py`](https://github.com/smk1367/scan/blob/main/app.py) (HTTP service), [`scanner.py`](https://github.com/smk1367/scan/blob/main/scanner.py) (Target scanner), [`excel_manager.py`](https://github.com/smk1367/scan/blob/main/excel_manager.py) (Excel import/export), [`index.html`](https://github.com/smk1367/scan/blob/main/index.html) (Web dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Dashboard and API"]
  node_dashboard["Web dashboard<br/>[index.html]"]
  node_service["HTTP service<br/>[app.py]"]
  node_cities["City settings<br/>[database.py]"]
end

subgraph group_scan["Scanning and collection"]
  node_scanrun["Scan worker<br/>[app.py]"]
  node_scanner["Target scanner<br/>[scanner.py]"]
  node_snmp["SNMP collection<br/>[scanner.py]"]
  node_ros["RouterOS collection<br/>[scanner.py]"]
  node_api_client["RouterOS API client<br/>[routeros_api.py]"]
  node_ssh["SSH fallback<br/>[scanner.py]"]
end

subgraph group_state["Monitoring state"]
  node_devices[("Device records<br/>[database.py]")]
  node_scans[("Scan history<br/>[database.py]")]
  node_changes[("Change history<br/>[database.py]")]
end

subgraph group_ops["Management and export"]
  node_blacklist[("Blacklist and targets<br/>[database.py]")]
  node_manual_radios[("Manual radios<br/>[database.py]")]
  node_excel["Excel import/export<br/>[excel_manager.py]"]
  node_backup["Automatic backups<br/>[app.py]"]
end

node_operator(("Operator"))
node_mikrotik{{"MikroTik devices"}}
node_other_devices{{"Other network devices"}}
node_snmp_service{{"SNMP agents"}}
node_ssh_service{{"SSH endpoints"}}
node_backup_store[("Backup files")]

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"requests"| node_service
node_service -->|"serves"| node_dashboard
node_service -->|"reads settings"| node_cities
node_service -->|"starts scan"| node_scanrun
node_scanrun -->|"scans targets"| node_scanner
node_scanner -->|"reads settings"| node_cities
node_scanner -->|"collects data"| node_snmp
node_scanner -->|"collects data"| node_ros
node_scanner -.->|"falls back"| node_ssh
node_ros -->|"issues commands"| node_api_client
node_snmp -->|"queries"| node_snmp_service
node_api_client -->|"queries"| node_mikrotik
node_ssh -.->|"connects"| node_ssh_service
node_scanner -->|"probes"| node_other_devices
node_scanner -->|"upserts records"| node_devices
node_scanrun -->|"records results"| node_scans
node_scanrun -->|"records changes"| node_changes
node_service -->|"reads and updates"| node_devices
node_service -->|"reads history"| node_scans
node_service -->|"manages entries"| node_blacklist
node_service -->|"manages radios"| node_manual_radios
node_service -->|"imports and exports"| node_excel
node_excel -->|"reads and writes"| node_devices
node_excel -->|"reads and writes"| node_blacklist
node_excel -->|"reads and writes"| node_manual_radios
node_service -->|"runs backups"| node_backup
node_backup -->|"writes files"| node_backup_store

click node_dashboard "https://github.com/smk1367/scan/blob/main/index.html"
click node_service "https://github.com/smk1367/scan/blob/main/app.py"
click node_cities "https://github.com/smk1367/scan/blob/main/database.py"
click node_scanrun "https://github.com/smk1367/scan/blob/main/app.py"
click node_scanner "https://github.com/smk1367/scan/blob/main/scanner.py"
click node_snmp "https://github.com/smk1367/scan/blob/main/scanner.py"
click node_ros "https://github.com/smk1367/scan/blob/main/scanner.py"
click node_api_client "https://github.com/smk1367/scan/blob/main/routeros_api.py"
click node_ssh "https://github.com/smk1367/scan/blob/main/scanner.py"
click node_devices "https://github.com/smk1367/scan/blob/main/database.py"
click node_scans "https://github.com/smk1367/scan/blob/main/database.py"
click node_changes "https://github.com/smk1367/scan/blob/main/database.py"
click node_blacklist "https://github.com/smk1367/scan/blob/main/database.py"
click node_manual_radios "https://github.com/smk1367/scan/blob/main/database.py"
click node_excel "https://github.com/smk1367/scan/blob/main/excel_manager.py"
click node_backup "https://github.com/smk1367/scan/blob/main/app.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_dashboard,node_service,node_cities toneBlue
class node_scanrun,node_scanner,node_snmp,node_ros,node_api_client,node_ssh,node_backup_store toneAmber
class node_devices,node_scans,node_changes toneMint
class node_blacklist,node_manual_radios,node_excel,node_backup toneRose
class node_operator,node_mikrotik,node_other_devices,node_snmp_service,node_ssh_service toneIndigo
```

## Components

### Dashboard and API

- [Web dashboard](https://github.com/smk1367/scan/blob/main/index.html): `index.html`
- [HTTP service](https://github.com/smk1367/scan/blob/main/app.py): `app.py`
- [City settings](https://github.com/smk1367/scan/blob/main/database.py): `database.py`

### Scanning and collection

- [Scan worker](https://github.com/smk1367/scan/blob/main/app.py): `app.py`
- [Target scanner](https://github.com/smk1367/scan/blob/main/scanner.py): `scanner.py`
- [SNMP collection](https://github.com/smk1367/scan/blob/main/scanner.py): `scanner.py`
- [RouterOS collection](https://github.com/smk1367/scan/blob/main/scanner.py): `scanner.py`
- [RouterOS API client](https://github.com/smk1367/scan/blob/main/routeros_api.py): `routeros_api.py`
- [SSH fallback](https://github.com/smk1367/scan/blob/main/scanner.py): `scanner.py`

### Monitoring state

- [Device records](https://github.com/smk1367/scan/blob/main/database.py): `database.py`
- [Scan history](https://github.com/smk1367/scan/blob/main/database.py): `database.py`
- [Change history](https://github.com/smk1367/scan/blob/main/database.py): `database.py`

### Management and export

- [Blacklist and targets](https://github.com/smk1367/scan/blob/main/database.py): `database.py`
- [Manual radios](https://github.com/smk1367/scan/blob/main/database.py): `database.py`
- [Excel import/export](https://github.com/smk1367/scan/blob/main/excel_manager.py): `excel_manager.py`
- [Automatic backups](https://github.com/smk1367/scan/blob/main/app.py): `app.py`

### Other components

- **Operator**
- **MikroTik devices**
- **Other network devices**
- **SNMP agents**
- **SSH endpoints**
- **Backup files**

## Connections

- Operator → Web dashboard: uses
- Web dashboard → HTTP service: requests
- HTTP service → Web dashboard: serves
- HTTP service → City settings: reads settings
- HTTP service → Scan worker: starts scan
- Scan worker → Target scanner: scans targets
- Target scanner → City settings: reads settings
- Target scanner → SNMP collection: collects data
- Target scanner → RouterOS collection: collects data
- Target scanner → SSH fallback: falls back
- RouterOS collection → RouterOS API client: issues commands
- SNMP collection → SNMP agents: queries
- RouterOS API client → MikroTik devices: queries
- SSH fallback → SSH endpoints: connects
- Target scanner → Other network devices: probes
- Target scanner → Device records: upserts records
- Scan worker → Scan history: records results
- Scan worker → Change history: records changes
- HTTP service → Device records: reads and updates
- HTTP service → Scan history: reads history
- HTTP service → Blacklist and targets: manages entries
- HTTP service → Manual radios: manages radios
- HTTP service → Excel import/export: imports and exports
- Excel import/export → Device records: reads and writes
- Excel import/export → Blacklist and targets: reads and writes
- Excel import/export → Manual radios: reads and writes
- HTTP service → Automatic backups: runs backups
- Automatic backups → Backup files: writes files
