How arjun-bhattarai/netrecon works
1. Overall shape
NetRecon is a small three-layer application: a browser UI in templates/, a FastAPI backend in app.py, and a core analysis engine in Core/. The backend is the orchestration layer that turns user requests into network discovery, port scanning, device classification, and risk analysis.
2. Entry point and API boundary
app.py is the main server process. It likely exposes REST endpoints such as /scan and /scan-network mentioned in the README, and serves the HTML/JS frontend. This is the main boundary between the user interface and the scanning logic.
3. Frontend subsystem
templates/index.html and templates/api.js form the client-side dashboard. The HTML provides the UI, while api.js sends requests to the FastAPI endpoints and renders scan results. The frontend does not appear to contain business logic; it delegates all analysis to the backend.
4. Network discovery subsystem
Core/network_scanner.py is the network-wide discovery layer. Based on the README, it discovers active hosts on a subnet like 192.168.1.0/24 and gathers basic identity data such as IP, MAC address, and vendor. This is the first data-producing stage in the pipeline.
5. Port scanning subsystem
Core/port_scanner.py handles host-level port inspection. It likely uses low-level socket probing for open ports, and may complement or validate Nmap-based discovery. The output of this module is a per-device list of exposed services or ports.
6. Device classification subsystem
Core/device_classifier.py turns raw scan artifacts into a device type label such as router, PC, IP camera, or IoT device. This is a fingerprinting layer that likely uses observed ports, vendor information, and other host traits rather than requiring user input.
7. Risk analysis subsystem
Core/risk_engine.py evaluates the security posture of a device based on what is exposed. The README calls out services such as SSH, SMB, and RDP, so this module likely maps open ports/services to a risk score or warnings. This is the final enrichment step before results are returned to the UI.
8. End-to-end data flow
The main flow is: user action in the browser → API request to FastAPI → network discovery → port scanning → device classification → risk scoring → JSON response → dashboard display. For whole-network scans, the pipeline starts with subnet discovery and then enriches each discovered host. For single-host scans, the flow likely starts at the port-scanning stage.
9. External tooling and runtime dependencies
The project runs on Python and uses FastAPI for the server. The README explicitly calls out Nmap for network discovery and socket for low-level port scanning. These tools are the key infrastructure dependencies and materially shape the architecture.
10. Primary architectural boundary
The Core/ package is the domain logic boundary. Everything under Core/ is responsible for scan intelligence, while app.py is responsible for HTTP, request handling, and response formatting. That separation makes it straightforward to diagram the system as UI → API → core engines.
11. Intended deployment context
This is a local-network reconnaissance tool, not a general internet-facing service. Its scope is centered on authorized LAN scanning and security inspection, so the important architectural constraint is that it operates on internal subnets and host-level exposures rather than on cloud resources or external integrations.
12. What to show in an architecture diagram
A good diagram would include: a browser/dashboard, a FastAPI backend, the four core modules as separate processing blocks, and the external scanning dependencies (Nmap and socket) feeding those modules. The final outputs are discovered devices, open ports, device types, and risk indicators displayed back in the UI.
Main entry points: app.py FastAPI app · network_scanner.py Network scan · port_scanner.py Port scan · api.js API client
Components 15
Frontend
Browser-facing UI
- Browser · User initiates scans and views results
- Dashboard · Main scan interface and results view
templates/index.html - API client · Calls backend endpoints and renders responses
templates/api.js
Backend
HTTP and orchestration layer
- FastAPI app · HTTP server, routing, and orchestration
app.py - Scan routes · Exposes scan and network-scan operations
- Response format · Packages analysis results for the UI
- Scan results · Hosts, ports, device types, and vendor data
- Risk flags · Warnings and security posture indicators
Core
Scan and analysis engines
- Network scan · Finds active hosts and basic identity data
Core/network_scanner.py - Port scan · Checks host ports and exposed services
Core/port_scanner.py - Classifier · Infers device type from scan artifacts
Core/device_classifier.py - Risk engine · Scores exposed services and flags concerns
Core/risk_engine.py
External
Runtime and scanning dependencies
- Nmap · Network discovery dependency
- Socket · Low-level port probing dependency
- Python · Executes the backend and core modules
Connections 18
- Browser → Dashboard: opens · The user views the web dashboard
- Dashboard → API client: loads · HTML loads client-side request logic
- API client → Scan routes: requests · Client calls scan endpoints
- Scan routes → FastAPI app: handled by · FastAPI receives HTTP requests
- FastAPI app → Network scan: network scan · Subnet discovery starts here
- FastAPI app → Port scan: port scan · Host-level probing for open services
- FastAPI app → Classifier: classify · Observed traits are turned into device labels
- FastAPI app → Risk engine: assess · Exposure data is converted into risk signals
- Network scan → Nmap: uses · Discovery relies on Nmap
- Port scan → Socket: uses · Port probing relies on sockets
- Network scan → Scan results: produces · Outputs discovered hosts and identity data
- Port scan → Scan results: produces · Outputs open ports and services
- Classifier → Scan results: enriches · Adds inferred device types
- Risk engine → Risk flags: produces · Creates warnings and risk scores
- Scan results → Response format: assembled by · Backend combines discovery outputs
- Risk flags → Response format: assembled by · Risk data is merged into the response
- Response format → API client: returns · JSON response is consumed by the UI
- FastAPI app → Python: runs on · Backend executes in the Python runtime