# varun2871/network-congestion-system architecture

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

- Interactive diagram: https://gitdiagram.com/varun2871/network-congestion-system
- Repository: https://github.com/varun2871/network-congestion-system

## Overview

This repository is a live network congestion prediction and adaptive traffic-management system. Its main workflow collects network and Wi-Fi telemetry, derives features, predicts congestion, applies safety validation and a traffic policy, then measures the network again for feedback. A Flask dashboard exposes live metrics, controller state, events, and reports. Controlled iPerf3 experiments and before/after comparisons are a separate capability. The README documents the overall loop; sampled source confirms key file flows. Some controller internals and experiment wiring were not sampled, so those links are documented or left unasserted.

Main entry points: [`prediction/closed_loop_controller.py`](https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py) (Closed-loop controller), [`dashboard/app.py`](https://github.com/varun2871/network-congestion-system/blob/main/dashboard/app.py) (Dashboard API), [`monitoring/collector.py`](https://github.com/varun2871/network-congestion-system/blob/main/monitoring/collector.py) (Telemetry collector), [`data/live_network_metrics.csv`](https://github.com/varun2871/network-congestion-system/blob/main/data/live_network_metrics.csv) (Network metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_observe["Telemetry and features"]
  node_collector["Telemetry collector<br/>[collector.py]"]
  node_wifi["Wi-Fi monitor<br/>[wifi_monitor.py]"]
  node_metrics[("Network metrics")]
  node_features["Feature engineering<br/>[feature_engine.py]"]
  node_featuredata[("Live features<br/>[live_features.csv]")]
end

subgraph group_control["Prediction and control"]
  node_controller["Closed-loop controller"]
  node_prediction["ML prediction"]
  node_safety["Safety validation"]
  node_policy["Adaptive policy"]
  node_traffic["Traffic control<br/>[traffic_manager.py]"]
  node_state[("Controller state")]
  node_events[("Controller events")]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard_app["Dashboard API<br/>[app.py]"]
  node_dashboard_ui["Dashboard UI<br/>[dashboard.html]"]
end

subgraph group_experiments["Experiments and evaluation"]
  node_iperf["iPerf3 tests"]
  node_experiment_data[("Experiment results")]
  node_evaluation["Result comparison<br/>[compare_results.py]"]
  node_before_after[("Before/after results")]
end

node_network(("Live network"))
node_linux_tc["Linux traffic control"]
node_user(("Operator"))

node_network -->|"measures"| node_collector
node_collector -->|"queries"| node_wifi
node_collector -->|"writes telemetry"| node_metrics
node_metrics -->|"provides measurements"| node_features
node_features -->|"writes features"| node_featuredata
node_controller -.->|"reads features"| node_featuredata
node_controller -->|"runs model"| node_prediction
node_prediction -->|"validates prediction"| node_safety
node_safety -->|"selects state"| node_policy
node_controller -.->|"applies policy"| node_traffic
node_traffic -->|"configures classes"| node_linux_tc
node_linux_tc -->|"shapes traffic"| node_network
node_controller -.->|"records state"| node_state
node_controller -.->|"records events"| node_events
node_user -->|"views"| node_dashboard_ui
node_dashboard_ui -.->|"requests dashboard data"| node_dashboard_app
node_dashboard_app -->|"reads telemetry"| node_metrics
node_dashboard_app -->|"reads controller state"| node_state
node_dashboard_app -->|"reads events"| node_events
node_network -.->|"generates test traffic"| node_iperf
node_iperf -->|"writes results"| node_experiment_data
node_experiment_data -.->|"supplies measurements"| node_evaluation
node_evaluation -->|"writes comparison"| node_before_after

click node_collector "https://github.com/varun2871/network-congestion-system/blob/main/monitoring/collector.py"
click node_wifi "https://github.com/varun2871/network-congestion-system/blob/main/monitoring/wifi_monitor.py"
click node_metrics "https://github.com/varun2871/network-congestion-system/blob/main/data/live_network_metrics.csv"
click node_features "https://github.com/varun2871/network-congestion-system/blob/main/prediction/feature_engine.py"
click node_featuredata "https://github.com/varun2871/network-congestion-system/blob/main/data/live_features.csv"
click node_controller "https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py"
click node_prediction "https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py"
click node_safety "https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py"
click node_policy "https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py"
click node_traffic "https://github.com/varun2871/network-congestion-system/blob/main/traffic_management/traffic_manager.py"
click node_state "https://github.com/varun2871/network-congestion-system/blob/main/data/controller_state.json"
click node_events "https://github.com/varun2871/network-congestion-system/blob/main/data/controller_events.jsonl"
click node_dashboard_app "https://github.com/varun2871/network-congestion-system/blob/main/dashboard/app.py"
click node_dashboard_ui "https://github.com/varun2871/network-congestion-system/blob/main/dashboard/templates/dashboard.html"
click node_iperf "https://github.com/varun2871/network-congestion-system/blob/main/experiments/run-wsl-experiments.py"
click node_experiment_data "https://github.com/varun2871/network-congestion-system/blob/main/data/controlled_experiments.csv"
click node_evaluation "https://github.com/varun2871/network-congestion-system/blob/main/experiments/compare_results.py"
click node_before_after "https://github.com/varun2871/network-congestion-system/blob/main/data/before_after_comparison.csv"

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_collector,node_wifi,node_metrics,node_features,node_featuredata toneBlue
class node_controller,node_prediction,node_safety,node_policy,node_traffic,node_state,node_events toneAmber
class node_dashboard_app,node_dashboard_ui toneMint
class node_iperf,node_experiment_data,node_evaluation,node_before_after toneRose
class node_network,node_linux_tc,node_user toneIndigo
```

## Components

### Telemetry and features

- [Telemetry collector](https://github.com/varun2871/network-congestion-system/blob/main/monitoring/collector.py): `monitoring/collector.py`
- [Wi-Fi monitor](https://github.com/varun2871/network-congestion-system/blob/main/monitoring/wifi_monitor.py): `monitoring/wifi_monitor.py`
- [Network metrics](https://github.com/varun2871/network-congestion-system/blob/main/data/live_network_metrics.csv): `data/live_network_metrics.csv`
- [Feature engineering](https://github.com/varun2871/network-congestion-system/blob/main/prediction/feature_engine.py): `prediction/feature_engine.py`
- [Live features](https://github.com/varun2871/network-congestion-system/blob/main/data/live_features.csv): `data/live_features.csv`

### Prediction and control

- [Closed-loop controller](https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py): `prediction/closed_loop_controller.py`
- [ML prediction](https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py): `prediction/closed_loop_controller.py`
- [Safety validation](https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py): `prediction/closed_loop_controller.py`
- [Adaptive policy](https://github.com/varun2871/network-congestion-system/blob/main/prediction/closed_loop_controller.py): `prediction/closed_loop_controller.py`
- [Traffic control](https://github.com/varun2871/network-congestion-system/blob/main/traffic_management/traffic_manager.py): `traffic_management/traffic_manager.py`
- [Controller state](https://github.com/varun2871/network-congestion-system/blob/main/data/controller_state.json): `data/controller_state.json`
- [Controller events](https://github.com/varun2871/network-congestion-system/blob/main/data/controller_events.jsonl): `data/controller_events.jsonl`

### Dashboard

- [Dashboard API](https://github.com/varun2871/network-congestion-system/blob/main/dashboard/app.py): `dashboard/app.py`
- [Dashboard UI](https://github.com/varun2871/network-congestion-system/blob/main/dashboard/templates/dashboard.html): `dashboard/templates/dashboard.html`

### Experiments and evaluation

- [iPerf3 tests](https://github.com/varun2871/network-congestion-system/blob/main/experiments/run-wsl-experiments.py): `experiments/run-wsl-experiments.py`
- [Experiment results](https://github.com/varun2871/network-congestion-system/blob/main/data/controlled_experiments.csv): `data/controlled_experiments.csv`
- [Result comparison](https://github.com/varun2871/network-congestion-system/blob/main/experiments/compare_results.py): `experiments/compare_results.py`
- [Before/after results](https://github.com/varun2871/network-congestion-system/blob/main/data/before_after_comparison.csv): `data/before_after_comparison.csv`

### Other components

- **Live network**
- **Linux traffic control**
- **Operator**

## Connections

- Live network → Telemetry collector: measures (evidence: `README.md`)
- Telemetry collector → Wi-Fi monitor: queries (evidence: `monitoring/collector.py`)
- Telemetry collector → Network metrics: writes telemetry (evidence: `monitoring/collector.py`)
- Network metrics → Feature engineering: provides measurements (evidence: `prediction/feature_engine.py`)
- Feature engineering → Live features: writes features (evidence: `prediction/feature_engine.py`)
- Closed-loop controller → Live features: reads features
- Closed-loop controller → ML prediction: runs model (evidence: `README.md`)
- ML prediction → Safety validation: validates prediction (evidence: `README.md`)
- Safety validation → Adaptive policy: selects state (evidence: `README.md`)
- Closed-loop controller → Traffic control: applies policy
- Traffic control → Linux traffic control: configures classes (evidence: `traffic_management/traffic_manager.py`)
- Linux traffic control → Live network: shapes traffic (evidence: `README.md`)
- Closed-loop controller → Controller state: records state
- Closed-loop controller → Controller events: records events
- Operator → Dashboard UI: views (evidence: `README.md`)
- Dashboard UI → Dashboard API: requests dashboard data
- Dashboard API → Network metrics: reads telemetry (evidence: `dashboard/app.py`)
- Dashboard API → Controller state: reads controller state (evidence: `dashboard/app.py`)
- Dashboard API → Controller events: reads events (evidence: `dashboard/app.py`)
- Live network → iPerf3 tests: generates test traffic
- iPerf3 tests → Experiment results: writes results (evidence: `experiments/run-wsl-experiments.py`)
- Experiment results → Result comparison: supplies measurements
- Result comparison → Before/after results: writes comparison (evidence: `experiments/compare_results.py`)
