# nitish419/ai-cybersecurity-threat-detection architecture

> Architecture diagram of the GitHub repository nitish419/ai-cybersecurity-threat-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nitish419/ai-cybersecurity-threat-detection
- Repository: https://github.com/nitish419/ai-cybersecurity-threat-detection

## Overview

This repository is a synthetic network-threat detection demo with a Streamlit SOC dashboard and a separate looping traffic simulator. The main workflow generates flow data, preprocesses and splits it, trains supervised and anomaly-detection models, evaluates them, and writes SOC alerts and a confusion-matrix image for the dashboard. The README describes the two detection approaches and automated response playbooks. The sampled sniffer simulates traffic rather than capturing packets; no connection from its output to the dashboard or detection pipeline is shown.

Main entry points: [`app.py`](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/app.py) (SOC Dashboard), [`main.py`](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py) (SOC Alert Generation), [`live_sniffer.py`](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/live_sniffer.py) (Live Traffic Simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["SOC Interface"]
  node_dashboard["SOC Dashboard<br/>[app.py]"]
  node_split["Train-Test Split<br/>[app.py]"]
end

subgraph group_detection["Detection Pipeline"]
  node_pipeline["Pipeline Setup<br/>[main.py]"]
  node_generator["Synthetic Flow Generator<br/>[main.py]"]
  node_preprocess["Preprocessing<br/>[main.py]"]
  node_training["Model Training<br/>[main.py]"]
  node_randomforest["Random Forest<br/>[main.py]"]
  node_isolationforest["Isolation Forest<br/>[main.py]"]
  node_evaluation["Model Evaluation<br/>[main.py]"]
  node_alerts["SOC Alert Generation<br/>[main.py]"]
  node_alertfile["Alert CSV<br/>[main.py]"]
  node_matrix["Confusion Matrix Image<br/>[main.py]"]
end

subgraph group_simulation["Traffic Simulation"]
  node_live_simulator["Live Traffic Simulator<br/>[live_sniffer.py]"]
  node_livefile["Live Traffic CSV<br/>[live_sniffer.py]"]
end

node_operator(("Operator"))

node_operator -->|"starts scan"| node_dashboard
node_dashboard -->|"initializes"| node_pipeline
node_dashboard -->|"requests flows"| node_generator
node_generator -->|"returns flows"| node_preprocess
node_dashboard -->|"preprocesses flows"| node_preprocess
node_dashboard -->|"splits data"| node_split
node_dashboard -->|"trains models"| node_training
node_training -->|"fits classifier"| node_randomforest
node_training -->|"fits detector"| node_isolationforest
node_dashboard -->|"evaluates models"| node_evaluation
node_evaluation -->|"saves image"| node_matrix
node_dashboard -->|"generates alerts"| node_alerts
node_alerts -->|"predicts threats"| node_randomforest
node_alerts -->|"detects anomalies"| node_isolationforest
node_alerts -->|"writes alerts"| node_alertfile
node_dashboard -->|"reads alerts"| node_alertfile
node_dashboard -->|"loads image"| node_matrix
node_live_simulator -->|"writes batches"| node_livefile

click node_dashboard "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/app.py"
click node_pipeline "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_generator "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_preprocess "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_split "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/app.py"
click node_training "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_randomforest "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_isolationforest "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_evaluation "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_alerts "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_alertfile "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_matrix "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py"
click node_live_simulator "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/live_sniffer.py"
click node_livefile "https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/live_sniffer.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_dashboard,node_split toneBlue
class node_pipeline,node_generator,node_preprocess,node_training,node_randomforest,node_isolationforest,node_evaluation,node_alerts,node_alertfile,node_matrix toneAmber
class node_live_simulator,node_livefile toneMint
class node_operator toneIndigo
```

## Components

### SOC Interface

- [SOC Dashboard](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/app.py): `app.py`
- [Train-Test Split](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/app.py): `app.py`

### Detection Pipeline

- [Pipeline Setup](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Synthetic Flow Generator](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Preprocessing](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Model Training](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Random Forest](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Isolation Forest](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Model Evaluation](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [SOC Alert Generation](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Alert CSV](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`
- [Confusion Matrix Image](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/main.py): `main.py`

### Traffic Simulation

- [Live Traffic Simulator](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/live_sniffer.py): `live_sniffer.py`
- [Live Traffic CSV](https://github.com/nitish419/ai-cybersecurity-threat-detection/blob/main/live_sniffer.py): `live_sniffer.py`

### Other components

- **Operator**

## Connections

- Operator → SOC Dashboard: starts scan (evidence: `app.py`)
- SOC Dashboard → Pipeline Setup: initializes (evidence: `app.py`)
- SOC Dashboard → Synthetic Flow Generator: requests flows (evidence: `app.py`)
- Synthetic Flow Generator → Preprocessing: returns flows (evidence: `app.py`)
- SOC Dashboard → Preprocessing: preprocesses flows (evidence: `app.py`)
- SOC Dashboard → Train-Test Split: splits data (evidence: `app.py`)
- SOC Dashboard → Model Training: trains models (evidence: `app.py`)
- Model Training → Random Forest: fits classifier (evidence: `main.py`)
- Model Training → Isolation Forest: fits detector (evidence: `main.py`)
- SOC Dashboard → Model Evaluation: evaluates models (evidence: `app.py`)
- Model Evaluation → Confusion Matrix Image: saves image (evidence: `main.py`)
- SOC Dashboard → SOC Alert Generation: generates alerts (evidence: `app.py`)
- SOC Alert Generation → Random Forest: predicts threats (evidence: `main.py`)
- SOC Alert Generation → Isolation Forest: detects anomalies (evidence: `main.py`)
- SOC Alert Generation → Alert CSV: writes alerts (evidence: `main.py`)
- SOC Dashboard → Alert CSV: reads alerts (evidence: `app.py`)
- SOC Dashboard → Confusion Matrix Image: loads image (evidence: `app.py`)
- Live Traffic Simulator → Live Traffic CSV: writes batches (evidence: `live_sniffer.py`)
