# tharun272004/ids-using-ml architecture

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

- Interactive diagram: https://gitdiagram.com/tharun272004/ids-using-ml
- Repository: https://github.com/tharun272004/ids-using-ml

## Overview

This is a Flask-based real-time network intrusion detection system. An operator starts packet scanning from the web console; captured packets are aggregated into flows, classified and checked by behavioral detectors, then correlated into a risk result recorded for dashboards and investigation. The app also serves analytics and report generation. README-documented model evaluation is a separate offline capability. Some route and storage wiring is not visible in the excerpts, so uncertain links are omitted or identified as documented.

Main entry points: [`packet_capture/live_predictor.py`](https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py) (Flow aggregation), [`evaluation/evaluate_ids.py`](https://github.com/tharun272004/ids-using-ml/blob/main/evaluation/evaluate_ids.py) (Offline evaluation), [`app.py`](https://github.com/tharun272004/ids-using-ml/blob/main/app.py) (Flask routes), [`ml/risk_engine.py`](https://github.com/tharun272004/ids-using-ml/blob/main/ml/risk_engine.py) (Unified risk)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Traffic Capture"]
  node_scanner["Packet scanner<br/>[live_predictor.py]"]
  node_flow["Flow aggregation<br/>[live_predictor.py]"]
end

subgraph group_detection["Detection and Risk"]
  node_classifier["ML classification<br/>[live_predictor.py]"]
  node_dns["DNS tunneling<br/>[dns_tunneling.py]"]
  node_c2["C2 beaconing<br/>[c2_detector.py]"]
  node_exfil["Exfiltration"]
  node_risk["Unified risk<br/>[risk_engine.py]"]
  node_predictions[("Prediction log")]
end

subgraph group_web["Web Console"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_console["Monitoring console"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_report["PDF reporting<br/>[generate_report.py]"]
end

subgraph group_analysis["Evaluation"]
  node_evaluation["Offline evaluation<br/>[evaluate_ids.py]"]
end

node_operator(("Network operator"))

node_operator -->|"starts scanning"| node_console
node_console -->|"controls scanner"| node_webapp
node_webapp -.->|"starts scanning"| node_scanner
node_scanner -->|"aggregates packets"| node_flow
node_flow -->|"classifies flows"| node_classifier
node_flow -->|"analyzes DNS"| node_dns
node_flow -->|"checks beaconing"| node_c2
node_flow -->|"checks uploads"| node_exfil
node_flow -->|"correlates signals"| node_risk
node_risk -.->|"records alerts"| node_predictions
node_webapp -.->|"reads predictions"| node_predictions
node_dashboard -->|"requests analytics"| node_webapp
node_webapp -->|"generates report"| node_report
node_evaluation -->|"evaluates detector"| node_dns
node_evaluation -->|"evaluates detector"| node_c2
node_evaluation -->|"evaluates detector"| node_exfil
node_evaluation -->|"evaluates scoring"| node_risk
node_evaluation -->|"benchmarks live path"| node_flow

click node_scanner "https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py"
click node_flow "https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py"
click node_classifier "https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py"
click node_dns "https://github.com/tharun272004/ids-using-ml/blob/main/ml/dns_tunneling.py"
click node_c2 "https://github.com/tharun272004/ids-using-ml/blob/main/ml/c2_detector.py"
click node_exfil "https://github.com/tharun272004/ids-using-ml/blob/main/ml/exfiltration_detector.py"
click node_risk "https://github.com/tharun272004/ids-using-ml/blob/main/ml/risk_engine.py"
click node_predictions "https://github.com/tharun272004/ids-using-ml/blob/main/data/live_predictions.csv"
click node_webapp "https://github.com/tharun272004/ids-using-ml/blob/main/app.py"
click node_console "https://github.com/tharun272004/ids-using-ml/blob/main/templates/live_monitoring.html"
click node_dashboard "https://github.com/tharun272004/ids-using-ml/blob/main/static/js/dashboard.js"
click node_report "https://github.com/tharun272004/ids-using-ml/blob/main/report/generate_report.py"
click node_evaluation "https://github.com/tharun272004/ids-using-ml/blob/main/evaluation/evaluate_ids.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_scanner,node_flow toneBlue
class node_classifier,node_dns,node_c2,node_exfil,node_risk,node_predictions toneAmber
class node_webapp,node_console,node_dashboard,node_report toneMint
class node_evaluation toneRose
class node_operator toneIndigo
```

## Components

### Traffic Capture

- [Packet scanner](https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py): `packet_capture/live_predictor.py`
- [Flow aggregation](https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py): `packet_capture/live_predictor.py`

### Detection and Risk

- [ML classification](https://github.com/tharun272004/ids-using-ml/blob/main/packet_capture/live_predictor.py): `packet_capture/live_predictor.py`
- [DNS tunneling](https://github.com/tharun272004/ids-using-ml/blob/main/ml/dns_tunneling.py): `ml/dns_tunneling.py`
- [C2 beaconing](https://github.com/tharun272004/ids-using-ml/blob/main/ml/c2_detector.py): `ml/c2_detector.py`
- [Exfiltration](https://github.com/tharun272004/ids-using-ml/blob/main/ml/exfiltration_detector.py): `ml/exfiltration_detector.py`
- [Unified risk](https://github.com/tharun272004/ids-using-ml/blob/main/ml/risk_engine.py): `ml/risk_engine.py`
- [Prediction log](https://github.com/tharun272004/ids-using-ml/blob/main/data/live_predictions.csv): `data/live_predictions.csv`

### Web Console

- [Flask routes](https://github.com/tharun272004/ids-using-ml/blob/main/app.py): `app.py`
- [Monitoring console](https://github.com/tharun272004/ids-using-ml/blob/main/templates/live_monitoring.html): `templates/live_monitoring.html`
- [Dashboard](https://github.com/tharun272004/ids-using-ml/blob/main/static/js/dashboard.js): `static/js/dashboard.js`
- [PDF reporting](https://github.com/tharun272004/ids-using-ml/blob/main/report/generate_report.py): `report/generate_report.py`

### Evaluation

- [Offline evaluation](https://github.com/tharun272004/ids-using-ml/blob/main/evaluation/evaluate_ids.py): `evaluation/evaluate_ids.py`

### Other components

- **Network operator**

## Connections

- Network operator → Monitoring console: starts scanning (evidence: `README.md`)
- Monitoring console → Flask routes: controls scanner (evidence: `README.md`)
- Flask routes → Packet scanner: starts scanning
- Packet scanner → Flow aggregation: aggregates packets (evidence: `packet_capture/live_predictor.py`)
- Flow aggregation → ML classification: classifies flows (evidence: `packet_capture/live_predictor.py`)
- Flow aggregation → DNS tunneling: analyzes DNS (evidence: `packet_capture/live_predictor.py`)
- Flow aggregation → C2 beaconing: checks beaconing (evidence: `packet_capture/live_predictor.py`)
- Flow aggregation → Exfiltration: checks uploads (evidence: `packet_capture/live_predictor.py`)
- Flow aggregation → Unified risk: correlates signals (evidence: `packet_capture/live_predictor.py`)
- Unified risk → Prediction log: records alerts
- Flask routes → Prediction log: reads predictions
- Dashboard → Flask routes: requests analytics (evidence: `static/js/dashboard.js`)
- Flask routes → PDF reporting: generates report (evidence: `app.py`)
- Offline evaluation → DNS tunneling: evaluates detector (evidence: `evaluation/evaluate_ids.py`)
- Offline evaluation → C2 beaconing: evaluates detector (evidence: `evaluation/evaluate_ids.py`)
- Offline evaluation → Exfiltration: evaluates detector (evidence: `evaluation/evaluate_ids.py`)
- Offline evaluation → Unified risk: evaluates scoring (evidence: `evaluation/evaluate_ids.py`)
- Offline evaluation → Flow aggregation: benchmarks live path (evidence: `evaluation/evaluate_ids.py`)
