# soham-2305/cyber-nids-bda architecture

> Architecture diagram of the GitHub repository soham-2305/cyber-nids-bda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/soham-2305/cyber-nids-bda
- Repository: https://github.com/soham-2305/cyber-nids-bda

## Overview

The repository is a hybrid network intrusion detection and traffic-analysis project. Its main runtime captures packets, extracts features, applies rules, assigns severity, and logs alerts for dashboard viewing. Separate dataset workflows preprocess CICIDS2017 data, train and evaluate a classifier, and run Spark analytics; the README describes ML as separate from live detection. The simulator is a controlled-traffic utility. Some secondary ML modules are unsampled, so their internal links are omitted rather than inferred.

Main entry points: [`main.py`](https://github.com/soham-2305/cyber-nids-bda/blob/main/main.py) (NIDS orchestrator), [`data/processed`](https://github.com/soham-2305/cyber-nids-bda/tree/main/data/processed) (Processed dataset), [`dashboard/app.py`](https://github.com/soham-2305/cyber-nids-bda/blob/main/dashboard/app.py) (Dashboard and API), [`detector/packet_capture.py`](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/packet_capture.py) (Packet capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detection["Live Detection"]
  node_nids["NIDS orchestrator<br/>[main.py]"]
  node_capture["Packet capture<br/>[packet_capture.py]"]
  node_features["Feature extraction"]
  node_rules["Rule detection<br/>[rule_detector.py]"]
  node_severity["Severity mapping<br/>[severity_engine.py]"]
  node_logger["Alert logger<br/>[logger.py]"]
end

subgraph group_visibility["Alert Visibility"]
  node_logs[("Alert CSV logs")]
  node_dashboard["Dashboard and API<br/>[app.py]"]
  node_dashboard_ui["Dashboard page<br/>[dashboard.html]"]
end

subgraph group_datasets["Dataset Analysis"]
  node_raw_data[("Raw datasets")]
  node_preprocess["Dataset preprocessing"]
  node_processed_data[("Processed dataset")]
  node_spark["Spark analytics"]
  node_results[("Analytics results")]
end

subgraph group_ml["Machine Learning"]
  node_ml_workflows["ML dataset tools"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_model_artifacts[("Model artifacts")]
end

subgraph group_demo["Controlled Demo"]
  node_simulator["Traffic simulator"]
end

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

node_operator -->|"starts"| node_nids
node_nids -->|"starts capture"| node_capture
node_network -->|"supplies packets"| node_capture
node_capture -->|"calls callback"| node_nids
node_nids -->|"extracts features"| node_features
node_nids -->|"analyzes features"| node_rules
node_nids -->|"assigns severity"| node_severity
node_nids -->|"logs alerts"| node_logger
node_logger -->|"writes CSV"| node_logs
node_dashboard -->|"reads latest CSV"| node_logs
node_operator -->|"views"| node_dashboard
node_dashboard -->|"renders"| node_dashboard_ui
node_raw_data -.->|"supplies CSVs"| node_preprocess
node_preprocess -.->|"writes cleaned data"| node_processed_data
node_processed_data -->|"supplies dataset"| node_spark
node_spark -->|"saves analytics"| node_results
node_processed_data -->|"supplies dataset"| node_trainer
node_trainer -->|"saves model and reports"| node_model_artifacts
node_processed_data -.->|"dataset workflows"| node_ml_workflows
node_operator -->|"runs demo"| node_simulator
node_simulator -.->|"generates traffic"| node_network

click node_nids "https://github.com/soham-2305/cyber-nids-bda/blob/main/main.py"
click node_capture "https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/packet_capture.py"
click node_features "https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/feature_extractor.py"
click node_rules "https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/rule_detector.py"
click node_severity "https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/severity_engine.py"
click node_logger "https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/logger.py"
click node_logs "https://github.com/soham-2305/cyber-nids-bda/tree/main/logs"
click node_dashboard "https://github.com/soham-2305/cyber-nids-bda/blob/main/dashboard/app.py"
click node_dashboard_ui "https://github.com/soham-2305/cyber-nids-bda/blob/main/dashboard/templates/dashboard.html"
click node_raw_data "https://github.com/soham-2305/cyber-nids-bda/tree/main/data/raw"
click node_preprocess "https://github.com/soham-2305/cyber-nids-bda/blob/main/ml/preprocess_dataset.py"
click node_processed_data "https://github.com/soham-2305/cyber-nids-bda/tree/main/data/processed"
click node_spark "https://github.com/soham-2305/cyber-nids-bda/blob/main/spark/big_data_analysis.py"
click node_ml_workflows "https://github.com/soham-2305/cyber-nids-bda/tree/main/ml"
click node_trainer "https://github.com/soham-2305/cyber-nids-bda/blob/main/ml/train_model.py"
click node_model_artifacts "https://github.com/soham-2305/cyber-nids-bda/tree/main/models"
click node_simulator "https://github.com/soham-2305/cyber-nids-bda/blob/main/simulator/traffic_simulator.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_nids,node_capture,node_features,node_rules,node_severity,node_logger toneBlue
class node_logs,node_dashboard,node_dashboard_ui toneAmber
class node_raw_data,node_preprocess,node_processed_data,node_spark,node_results toneMint
class node_ml_workflows,node_trainer,node_model_artifacts toneRose
class node_simulator,node_operator,node_network toneIndigo
```

## Components

### Live Detection

- [NIDS orchestrator](https://github.com/soham-2305/cyber-nids-bda/blob/main/main.py): `main.py`
- [Packet capture](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/packet_capture.py): `detector/packet_capture.py`
- [Feature extraction](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/feature_extractor.py): `detector/feature_extractor.py`
- [Rule detection](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/rule_detector.py): `detector/rule_detector.py`
- [Severity mapping](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/severity_engine.py): `detector/severity_engine.py`
- [Alert logger](https://github.com/soham-2305/cyber-nids-bda/blob/main/detector/logger.py): `detector/logger.py`

### Alert Visibility

- [Alert CSV logs](https://github.com/soham-2305/cyber-nids-bda/tree/main/logs): `logs`
- [Dashboard and API](https://github.com/soham-2305/cyber-nids-bda/blob/main/dashboard/app.py): `dashboard/app.py`
- [Dashboard page](https://github.com/soham-2305/cyber-nids-bda/blob/main/dashboard/templates/dashboard.html): `dashboard/templates/dashboard.html`

### Dataset Analysis

- [Raw datasets](https://github.com/soham-2305/cyber-nids-bda/tree/main/data/raw): `data/raw`
- [Dataset preprocessing](https://github.com/soham-2305/cyber-nids-bda/blob/main/ml/preprocess_dataset.py): `ml/preprocess_dataset.py`
- [Processed dataset](https://github.com/soham-2305/cyber-nids-bda/tree/main/data/processed): `data/processed`
- [Spark analytics](https://github.com/soham-2305/cyber-nids-bda/blob/main/spark/big_data_analysis.py): `spark/big_data_analysis.py`
- **Analytics results**

### Machine Learning

- [ML dataset tools](https://github.com/soham-2305/cyber-nids-bda/tree/main/ml): `ml`
- [Model training](https://github.com/soham-2305/cyber-nids-bda/blob/main/ml/train_model.py): `ml/train_model.py`
- [Model artifacts](https://github.com/soham-2305/cyber-nids-bda/tree/main/models): `models`

### Controlled Demo

- [Traffic simulator](https://github.com/soham-2305/cyber-nids-bda/blob/main/simulator/traffic_simulator.py): `simulator/traffic_simulator.py`

### Other components

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

## Connections

- Operator → NIDS orchestrator: starts (evidence: `main.py`)
- NIDS orchestrator → Packet capture: starts capture (evidence: `main.py`)
- Network traffic → Packet capture: supplies packets (evidence: `detector/packet_capture.py`)
- Packet capture → NIDS orchestrator: calls callback (evidence: `main.py`)
- NIDS orchestrator → Feature extraction: extracts features (evidence: `main.py`)
- NIDS orchestrator → Rule detection: analyzes features (evidence: `main.py`)
- NIDS orchestrator → Severity mapping: assigns severity (evidence: `main.py`)
- NIDS orchestrator → Alert logger: logs alerts (evidence: `main.py`)
- Alert logger → Alert CSV logs: writes CSV (evidence: `detector/logger.py`)
- Dashboard and API → Alert CSV logs: reads latest CSV (evidence: `dashboard/app.py`)
- Operator → Dashboard and API: views (evidence: `dashboard/app.py`)
- Dashboard and API → Dashboard page: renders (evidence: `dashboard/app.py`)
- Raw datasets → Dataset preprocessing: supplies CSVs
- Dataset preprocessing → Processed dataset: writes cleaned data
- Processed dataset → Spark analytics: supplies dataset (evidence: `spark/big_data_analysis.py`)
- Spark analytics → Analytics results: saves analytics (evidence: `spark/big_data_analysis.py`)
- Processed dataset → Model training: supplies dataset (evidence: `ml/train_model.py`)
- Model training → Model artifacts: saves model and reports (evidence: `ml/train_model.py`)
- Processed dataset → ML dataset tools: dataset workflows
- Operator → Traffic simulator: runs demo (evidence: `simulator/traffic_simulator.py`)
- Traffic simulator → Network traffic: generates traffic
