# sahil-dalwani/real-time-network-anayliser architecture

> Architecture diagram of the GitHub repository sahil-dalwani/real-time-network-anayliser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahil-dalwani/real-time-network-anayliser
- Repository: https://github.com/sahil-dalwani/real-time-network-anayliser

## Overview

This is a Flask-based network analyzer. A user selects an interface and starts capture; the analyzer sniffs IP packets, tracks protocol, connection, and port statistics, detects suspicious patterns, and serves results through API endpoints. The UI template is served at `/`, while interfaces, capture control, statistics, ports, and reset are exposed by `app.py`. The analyzer excerpt shows capture and aggregation behavior, but not the template's client-side interactions or all packet-processing details, so those links are omitted.

Main entry points: [`app.py`](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py) (Flask routes), [`analyzer.py`](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py) (NetworkAnalyzer), [`templates/index.html`](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/templates/index.html) (Analyzer page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_ui["Analyzer page<br/>[index.html]"]
  node_flask["Flask routes<br/>[app.py]"]
  node_interfaces["Interface listing<br/>[app.py]"]
  node_capture_api["Capture control<br/>[app.py]"]
  node_stats_api["Stats and ports API<br/>[app.py]"]
  node_reset_api["Reset API<br/>[app.py]"]
end

subgraph group_analysis["Packet analysis"]
  node_analyzer["NetworkAnalyzer<br/>[analyzer.py]"]
  node_sniffer["Packet sniffing<br/>[analyzer.py]"]
  node_packet_analysis["Packet processing<br/>[analyzer.py]"]
  node_traffic_state[("Traffic statistics<br/>[analyzer.py]")]
  node_threat_detection["Suspicious activity detection<br/>[analyzer.py]"]
end

node_user(("Operator"))
node_psutil["Network interfaces"]
node_scapy["Scapy"]

node_user -->|"uses"| node_flask
node_flask -->|"renders"| node_ui
node_flask -->|"routes"| node_interfaces
node_interfaces -->|"lists interfaces"| node_psutil
node_flask -->|"routes"| node_capture_api
node_capture_api -->|"starts or stops"| node_analyzer
node_flask -->|"routes"| node_stats_api
node_stats_api -->|"gets stats"| node_analyzer
node_flask -->|"routes"| node_reset_api
node_reset_api -->|"resets stats"| node_analyzer
node_analyzer -->|"starts capture"| node_sniffer
node_sniffer -->|"sniffs packets"| node_scapy
node_sniffer -->|"dispatches packets"| node_packet_analysis
node_packet_analysis -->|"updates"| node_traffic_state
node_packet_analysis -->|"checks activity"| node_threat_detection
node_threat_detection -->|"records alerts"| node_traffic_state

click node_ui "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/templates/index.html"
click node_flask "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py"
click node_interfaces "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py"
click node_capture_api "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py"
click node_stats_api "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py"
click node_reset_api "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py"
click node_analyzer "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py"
click node_sniffer "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py"
click node_packet_analysis "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py"
click node_traffic_state "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py"
click node_threat_detection "https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.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_ui,node_flask,node_interfaces,node_capture_api,node_stats_api,node_reset_api toneBlue
class node_analyzer,node_sniffer,node_packet_analysis,node_traffic_state,node_threat_detection toneAmber
class node_user,node_psutil,node_scapy toneIndigo
```

## Components

### Web interface

- [Analyzer page](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/templates/index.html): `templates/index.html`
- [Flask routes](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py): `app.py`
- [Interface listing](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py): `app.py`
- [Capture control](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py): `app.py`
- [Stats and ports API](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py): `app.py`
- [Reset API](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/app.py): `app.py`

### Packet analysis

- [NetworkAnalyzer](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py): `analyzer.py`
- [Packet sniffing](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py): `analyzer.py`
- [Packet processing](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py): `analyzer.py`
- [Traffic statistics](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py): `analyzer.py`
- [Suspicious activity detection](https://github.com/sahil-dalwani/real-time-network-anayliser/blob/main/analyzer.py): `analyzer.py`

### Other components

- **Operator**
- **Network interfaces**
- **Scapy**

## Connections

- Operator → Flask routes: uses (evidence: `app.py`)
- Flask routes → Analyzer page: renders (evidence: `app.py`)
- Flask routes → Interface listing: routes (evidence: `app.py`)
- Interface listing → Network interfaces: lists interfaces (evidence: `app.py`)
- Flask routes → Capture control: routes (evidence: `app.py`)
- Capture control → NetworkAnalyzer: starts or stops (evidence: `app.py`)
- Flask routes → Stats and ports API: routes (evidence: `app.py`)
- Stats and ports API → NetworkAnalyzer: gets stats (evidence: `app.py`)
- Flask routes → Reset API: routes (evidence: `app.py`)
- Reset API → NetworkAnalyzer: resets stats (evidence: `app.py`)
- NetworkAnalyzer → Packet sniffing: starts capture (evidence: `analyzer.py`)
- Packet sniffing → Scapy: sniffs packets (evidence: `analyzer.py`)
- Packet sniffing → Packet processing: dispatches packets (evidence: `analyzer.py`)
- Packet processing → Traffic statistics: updates (evidence: `analyzer.py`)
- Packet processing → Suspicious activity detection: checks activity (evidence: `analyzer.py`)
- Suspicious activity detection → Traffic statistics: records alerts (evidence: `analyzer.py`)
