# abdullahhussain706/ai-powered-nids architecture

> Architecture diagram of the GitHub repository abdullahhussain706/ai-powered-nids, 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/abdullahhussain706/ai-powered-nids
- Repository: https://github.com/abdullahhussain706/ai-powered-nids

## Overview

This is a desktop hybrid network intrusion detection system. Its main workflow captures live traffic into PCAPs, parses packets into bidirectional flows, derives detection features, runs signature, two-stage ML, and anomaly detectors, fuses corroborating alerts, and persists results for desktop review. The graph also preserves documented capture management, model training, audit logging, and dashboard, alert, log, and settings capabilities. Relationships use README workflow statements and SOURCE INDEX references; unsampled subsystem links are omitted where their wiring is not shown.

Main entry points: [`core/flow_builder.py`](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/flow_builder.py) (Flow builder), [`ui/main_window.py`](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/main_window.py) (Main window), [`core/packet_capture.py`](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/packet_capture.py) (Live capture), [`core/fusion_engine.py`](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/fusion_engine.py) (Alert fusion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and flows"]
  node_tshark["Live capture<br/>[packet_capture.py]"]
  node_pcap["PCAP storage"]
  node_parser["Packet parser<br/>[packet_parser.py]"]
  node_flows["Flow builder<br/>[flow_builder.py]"]
end

subgraph group_detection["Detection and fusion"]
  node_features["Flow features<br/>[feature_engine.py]"]
  node_cicids["CICIDS features"]
  node_signatures["Signature engine"]
  node_rules["JSON rules"]
  node_ml["Two-stage ML<br/>[model_pipeline.py]"]
  node_models["Trained models"]
  node_anomaly["Anomaly engine<br/>[anomaly_engine.py]"]
  node_fusion["Alert fusion<br/>[fusion_engine.py]"]
  node_training["ML training and evaluation<br/>[train_stage1.py]"]
end

subgraph group_persistence["Alert persistence"]
  node_alerts["Alert manager<br/>[alert_manager.py]"]
  node_database[("SQLite database<br/>[db_manager.py]")]
  node_audit["JSONL audit logs<br/>[logger.py]"]
end

subgraph group_desktop["Desktop application"]
  node_window["Main window<br/>[main_window.py]"]
  node_dashboard["Dashboard view<br/>[dashboard_view.py]"]
  node_alertview["Alerts view<br/>[alerts_view.py]"]
  node_logsview["Logs view<br/>[logs_view.py]"]
  node_settings["Settings view<br/>[settings_view.py]"]
end

node_operator(("Operator"))
node_entry["Runtime launcher<br/>[run.py]"]
node_interface(("Network interface"))

node_operator -->|"starts app"| node_entry
node_entry -->|"launches backend"| node_tshark
node_entry -->|"launches frontend"| node_window
node_interface -->|"supplies traffic"| node_tshark
node_tshark -->|"stores captures"| node_pcap
node_tshark -->|"parses captures"| node_parser
node_parser -->|"builds flows"| node_flows
node_flows -->|"extracts features"| node_features
node_flows -->|"extracts CICIDS features"| node_cicids
node_features -->|"runs rules"| node_signatures
node_rules -->|"configures detection"| node_signatures
node_flows -->|"classifies flows"| node_ml
node_ml -->|"loads models"| node_models
node_flows -->|"checks anomalies"| node_anomaly
node_anomaly -->|"extracts features"| node_cicids
node_signatures -->|"provides alerts"| node_fusion
node_ml -->|"provides alerts"| node_fusion
node_anomaly -->|"provides alerts"| node_fusion
node_training -->|"produces artifacts"| node_models
node_fusion -->|"forwards alerts"| node_alerts
node_alerts -->|"persists alerts"| node_database
node_alerts -->|"logs alerts"| node_audit
node_window -->|"shows dashboard"| node_dashboard
node_window -->|"shows alerts"| node_alertview
node_window -->|"shows logs"| node_logsview
node_window -->|"shows settings"| node_settings
node_pcap -->|"reports storage stats"| node_settings

click node_entry "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/run.py"
click node_tshark "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/packet_capture.py"
click node_pcap "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/services/pcap_storage_service.py"
click node_parser "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/packet_parser.py"
click node_flows "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/flow_builder.py"
click node_features "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/feature_engine.py"
click node_cicids "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/cicids_feature_engine.py"
click node_signatures "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/signature_engine.py"
click node_rules "https://github.com/abdullahhussain706/ai-powered-nids/tree/main/rule"
click node_ml "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ml/model_pipeline.py"
click node_models "https://github.com/abdullahhussain706/ai-powered-nids/tree/main/ml/models"
click node_anomaly "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/anomaly_engine.py"
click node_fusion "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/fusion_engine.py"
click node_training "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ml/train_stage1.py"
click node_alerts "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/alert_manager.py"
click node_database "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/database/db_manager.py"
click node_audit "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/utils/logger.py"
click node_window "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/main_window.py"
click node_dashboard "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/dashboard_view.py"
click node_alertview "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/alerts_view.py"
click node_logsview "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/logs_view.py"
click node_settings "https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/settings_view.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_tshark,node_pcap,node_parser,node_flows toneBlue
class node_features,node_cicids,node_signatures,node_rules,node_ml,node_models,node_anomaly,node_fusion,node_training toneAmber
class node_alerts,node_database,node_audit toneMint
class node_window,node_dashboard,node_alertview,node_logsview,node_settings toneRose
class node_operator,node_interface toneIndigo
class node_entry toneTeal
```

## Components

### Capture and flows

- [Live capture](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/packet_capture.py): `core/packet_capture.py`
- [PCAP storage](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/services/pcap_storage_service.py): `services/pcap_storage_service.py`
- [Packet parser](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/packet_parser.py): `core/packet_parser.py`
- [Flow builder](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/flow_builder.py): `core/flow_builder.py`

### Detection and fusion

- [Flow features](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/feature_engine.py): `core/feature_engine.py`
- [CICIDS features](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/cicids_feature_engine.py): `core/cicids_feature_engine.py`
- [Signature engine](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/signature_engine.py): `core/signature_engine.py`
- [JSON rules](https://github.com/abdullahhussain706/ai-powered-nids/tree/main/rule): `rule`
- [Two-stage ML](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ml/model_pipeline.py): `ml/model_pipeline.py`
- [Trained models](https://github.com/abdullahhussain706/ai-powered-nids/tree/main/ml/models): `ml/models`
- [Anomaly engine](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/anomaly_engine.py): `core/anomaly_engine.py`
- [Alert fusion](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/fusion_engine.py): `core/fusion_engine.py`
- [ML training and evaluation](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ml/train_stage1.py): `ml/train_stage1.py`

### Alert persistence

- [Alert manager](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/core/alert_manager.py): `core/alert_manager.py`
- [SQLite database](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/database/db_manager.py): `database/db_manager.py`
- [JSONL audit logs](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/utils/logger.py): `utils/logger.py`

### Desktop application

- [Main window](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/main_window.py): `ui/main_window.py`
- [Dashboard view](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/dashboard_view.py): `ui/dashboard_view.py`
- [Alerts view](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/alerts_view.py): `ui/alerts_view.py`
- [Logs view](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/logs_view.py): `ui/logs_view.py`
- [Settings view](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/ui/settings_view.py): `ui/settings_view.py`

### Other components

- **Operator**
- [Runtime launcher](https://github.com/abdullahhussain706/ai-powered-nids/blob/main/run.py): `run.py`
- **Network interface**

## Connections

- Operator → Runtime launcher: starts app (evidence: `README.md`)
- Runtime launcher → Live capture: launches backend (evidence: `README.md`)
- Runtime launcher → Main window: launches frontend (evidence: `README.md`)
- Network interface → Live capture: supplies traffic (evidence: `README.md`)
- Live capture → PCAP storage: stores captures (evidence: `README.md`)
- Live capture → Packet parser: parses captures (evidence: `README.md`)
- Packet parser → Flow builder: builds flows (evidence: `README.md`)
- Flow builder → Flow features: extracts features (evidence: `README.md`)
- Flow builder → CICIDS features: extracts CICIDS features (evidence: `README.md`)
- Flow features → Signature engine: runs rules (evidence: `core/feature_engine.py`)
- JSON rules → Signature engine: configures detection (evidence: `README.md`)
- Flow builder → Two-stage ML: classifies flows (evidence: `README.md`)
- Two-stage ML → Trained models: loads models (evidence: `README.md`)
- Flow builder → Anomaly engine: checks anomalies (evidence: `README.md`)
- Anomaly engine → CICIDS features: extracts features (evidence: `core/anomaly_engine.py`)
- Signature engine → Alert fusion: provides alerts (evidence: `README.md`)
- Two-stage ML → Alert fusion: provides alerts (evidence: `README.md`)
- Anomaly engine → Alert fusion: provides alerts (evidence: `README.md`)
- ML training and evaluation → Trained models: produces artifacts (evidence: `README.md`)
- Alert fusion → Alert manager: forwards alerts (evidence: `README.md`)
- Alert manager → SQLite database: persists alerts (evidence: `core/alert_manager.py`)
- Alert manager → JSONL audit logs: logs alerts (evidence: `README.md`)
- Main window → Dashboard view: shows dashboard (evidence: `ui/main_window.py`)
- Main window → Alerts view: shows alerts (evidence: `ui/main_window.py`)
- Main window → Logs view: shows logs (evidence: `ui/main_window.py`)
- Main window → Settings view: shows settings (evidence: `ui/main_window.py`)
- PCAP storage → Settings view: reports storage stats (evidence: `ui/settings_view.py`)
