# y6thay/network_traffic_analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/y6thay/network_traffic_analyzer
- Repository: https://github.com/y6thay/network_traffic_analyzer

## Overview

This is a single-script, interactive network traffic analyzer. An operator optionally filters traffic, starts live capture, watches packet and security telemetry, then can export session records. The README documents the major dashboard, analytics, masking, and export capabilities; sampled source confirms packet parsing, shared counters and buffers, alert rules, and CSV export. The source excerpt is partial, so some documented subsystem connections are shown only where the README establishes them.

Main entry points: [`analyzer.py`](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py) (Dashboard renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and analysis"]
  node_entry["Analyzer entry<br/>[analyzer.py]"]
  node_filter["Target IP filter<br/>[analyzer.py]"]
  node_sniffer["Packet sniffer<br/>[analyzer.py]"]
  node_parser["Packet parser<br/>[analyzer.py]"]
  node_services["Service resolver<br/>[analyzer.py]"]
  node_state[("Shared packet state<br/>[analyzer.py]")]
  node_threats["Threat rules<br/>[analyzer.py]"]
  node_rates["Rate calculator<br/>[analyzer.py]"]
end

subgraph group_dashboard["Live dashboard"]
  node_dashboard_ui["Dashboard renderer<br/>[analyzer.py]"]
  node_talkers["Top talkers<br/>[analyzer.py]"]
  node_telemetry["Telemetry watchlist<br/>[analyzer.py]"]
end

subgraph group_forensics["Privacy and export"]
  node_masking["Display masking<br/>[analyzer.py]"]
  node_export["Session exporter<br/>[analyzer.py]"]
  node_csv["CSV audit log<br/>[analyzer.py]"]
  node_pcap["PCAP export<br/>[analyzer.py]"]
end

node_operator(("Operator"))
node_network(("Network traffic"))

node_operator -->|"starts"| node_entry
node_operator -->|"sets filter"| node_filter
node_entry -->|"starts thread"| node_sniffer
node_network -->|"supplies packets"| node_sniffer
node_sniffer -->|"calls callback"| node_parser
node_parser -->|"resolves ports"| node_services
node_parser -->|"updates counters"| node_state
node_parser -->|"checks traffic"| node_threats
node_entry -->|"starts thread"| node_rates
node_rates -->|"updates rates"| node_state
node_entry -->|"renders live"| node_dashboard_ui
node_dashboard_ui -->|"reads packets"| node_state
node_dashboard_ui -->|"shows hosts"| node_talkers
node_dashboard_ui -->|"shows metrics"| node_telemetry
node_telemetry -->|"shows alerts"| node_threats
node_dashboard_ui -->|"masks display"| node_masking
node_operator -->|"requests export"| node_export
node_export -->|"reads captured records"| node_state
node_export -->|"writes CSV"| node_csv
node_export -->|"writes PCAP"| node_pcap

click node_entry "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_filter "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_sniffer "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_parser "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_services "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_state "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_threats "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_rates "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_dashboard_ui "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_talkers "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_telemetry "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_masking "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_export "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_csv "https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py"
click node_pcap "https://github.com/y6thay/network_traffic_analyzer/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_entry,node_filter,node_sniffer,node_parser,node_services,node_state,node_threats,node_rates toneBlue
class node_dashboard_ui,node_talkers,node_telemetry toneAmber
class node_masking,node_export,node_csv,node_pcap toneMint
class node_operator,node_network toneIndigo
```

## Components

### Capture and analysis

- [Analyzer entry](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Target IP filter](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Packet sniffer](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Packet parser](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Service resolver](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Shared packet state](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Threat rules](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Rate calculator](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`

### Live dashboard

- [Dashboard renderer](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Top talkers](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Telemetry watchlist](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`

### Privacy and export

- [Display masking](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [Session exporter](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [CSV audit log](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`
- [PCAP export](https://github.com/y6thay/network_traffic_analyzer/blob/main/analyzer.py): `analyzer.py`

### Other components

- **Operator**
- **Network traffic**

## Connections

- Operator → Analyzer entry: starts (evidence: `README.md`)
- Operator → Target IP filter: sets filter (evidence: `README.md`)
- Analyzer entry → Packet sniffer: starts thread (evidence: `analyzer.py`)
- Network traffic → Packet sniffer: supplies packets (evidence: `README.md`)
- Packet sniffer → Packet parser: calls callback (evidence: `README.md`)
- Packet parser → Service resolver: resolves ports (evidence: `analyzer.py`)
- Packet parser → Shared packet state: updates counters (evidence: `analyzer.py`)
- Packet parser → Threat rules: checks traffic (evidence: `analyzer.py`)
- Analyzer entry → Rate calculator: starts thread (evidence: `README.md`)
- Rate calculator → Shared packet state: updates rates (evidence: `README.md`)
- Analyzer entry → Dashboard renderer: renders live (evidence: `README.md`)
- Dashboard renderer → Shared packet state: reads packets (evidence: `README.md`)
- Dashboard renderer → Top talkers: shows hosts (evidence: `README.md`)
- Dashboard renderer → Telemetry watchlist: shows metrics (evidence: `README.md`)
- Telemetry watchlist → Threat rules: shows alerts (evidence: `README.md`)
- Dashboard renderer → Display masking: masks display (evidence: `README.md`)
- Operator → Session exporter: requests export (evidence: `README.md`)
- Session exporter → Shared packet state: reads captured records (evidence: `analyzer.py`)
- Session exporter → CSV audit log: writes CSV (evidence: `analyzer.py`)
- Session exporter → PCAP export: writes PCAP (evidence: `analyzer.py`)
