# ka-369/vpn-traffic-identification architecture

> Architecture diagram of the GitHub repository ka-369/vpn-traffic-identification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ka-369/vpn-traffic-identification
- Repository: https://github.com/ka-369/vpn-traffic-identification

## Overview

This repository trains a VPN-versus-non-VPN Random Forest and documents a live-classification workflow. Offline, the dataset is normalized and aligned to 23 features, labels are encoded, the model is trained and validated, and model assets are saved. Live, NFStream captures flows, features are reconstructed, and a trained model produces a label and confidence. The live implementation is described in the README but is absent from the supplied tree and source excerpts, so its internal links are documented rather than source-verified.

Main entry points: [`model.py`](https://github.com/ka-369/vpn-traffic-identification/blob/main/model.py) (Prepare and train), [`consolidated_traffic_data.csv`](https://github.com/ka-369/vpn-traffic-identification/blob/main/consolidated_traffic_data.csv) (Labeled flow data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_dataset["Labeled flow data"]
  node_trainer["Prepare and train<br/>[model.py]"]
  node_model_asset["Random Forest model"]
  node_encoder_asset["Label encoder"]
end

subgraph group_detection["Live detection"]
  node_capture["Flow capture"]
  node_feature_reconstruction["Feature reconstruction"]
  node_inference["Flow inference"]
end

subgraph group_results["Classification results"]
  node_output["VPN classification"]
end

node_operator(("Network operator"))
node_network(("Network traffic"))

node_dataset -->|"loads"| node_trainer
node_trainer -->|"saves model"| node_model_asset
node_trainer -->|"saves encoder"| node_encoder_asset
node_operator -->|"starts capture"| node_capture
node_network -->|"provides flows"| node_capture
node_capture -->|"extracts features"| node_feature_reconstruction
node_feature_reconstruction -.->|"supplies features"| node_inference
node_model_asset -->|"loads model"| node_inference
node_encoder_asset -->|"loads encoder"| node_inference
node_inference -->|"prints label"| node_output

click node_dataset "https://github.com/ka-369/vpn-traffic-identification/blob/main/consolidated_traffic_data.csv"
click node_trainer "https://github.com/ka-369/vpn-traffic-identification/blob/main/model.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_dataset,node_trainer,node_model_asset,node_encoder_asset toneBlue
class node_capture,node_feature_reconstruction,node_inference toneAmber
class node_output toneMint
class node_operator,node_network toneIndigo
```

## Components

### Model training

- [Labeled flow data](https://github.com/ka-369/vpn-traffic-identification/blob/main/consolidated_traffic_data.csv): `consolidated_traffic_data.csv`
- [Prepare and train](https://github.com/ka-369/vpn-traffic-identification/blob/main/model.py): `model.py`
- **Random Forest model**
- **Label encoder**

### Live detection

- **Flow capture**
- **Feature reconstruction**
- **Flow inference**

### Classification results

- **VPN classification**

### Other components

- **Network operator**
- **Network traffic**

## Connections

- Labeled flow data → Prepare and train: loads (evidence: `model.py`)
- Prepare and train → Random Forest model: saves model (evidence: `model.py`)
- Prepare and train → Label encoder: saves encoder (evidence: `model.py`)
- Network operator → Flow capture: starts capture (evidence: `README.md`)
- Network traffic → Flow capture: provides flows (evidence: `README.md`)
- Flow capture → Feature reconstruction: extracts features (evidence: `README.md`)
- Feature reconstruction → Flow inference: supplies features
- Random Forest model → Flow inference: loads model (evidence: `README.md`)
- Label encoder → Flow inference: loads encoder (evidence: `README.md`)
- Flow inference → VPN classification: prints label (evidence: `README.md`)
