# nhahub/nha-5-211 architecture

> Architecture diagram of the GitHub repository nhahub/nha-5-211, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nhahub/nha-5-211
- Repository: https://github.com/nhahub/nha-5-211

## Overview

SMART IDS v3 is a network intrusion detection and SOC dashboard: it combines supervised attack classification, benign-trained anomaly detection, explanations, and dry-run response. The principal analyst workflow enters through the Streamlit app, loads persisted data and detection artifacts, scores flows, and presents results across SOC views. Separate training and evaluation modules support leakage-controlled data preparation, model fitting, and benchmark protocols. Edges reflect README statements and source-index references; unsampled implementation details are not inferred.

Main entry points: [`dashboard/data_access.py`](https://github.com/nhahub/nha-5-211/blob/main/dashboard/data_access.py) (Dashboard Data Access), [`app.py`](https://github.com/nhahub/nha-5-211/blob/main/app.py) (Dashboard App), [`src/detection/inference.py`](https://github.com/nhahub/nha-5-211/blob/main/src/detection/inference.py) (Unified Detection), [`src/training/trainer.py`](https://github.com/nhahub/nha-5-211/blob/main/src/training/trainer.py) (Model Trainer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_soc["SOC Dashboard"]
  node_app["Dashboard App<br/>[app.py]"]
  node_data_access["Dashboard Data Access<br/>[data_access.py]"]
  node_overview["SOC Overview<br/>[overview.py]"]
  node_predict["Flow Prediction<br/>[predict_flow.py]"]
  node_explorer["Dataset Explorer"]
  node_performance["Model Performance"]
  node_explain_view["Explainability View<br/>[explainability.py]"]
  node_response_view["Active Response View<br/>[active_response.py]"]
  node_settings["System Settings<br/>[system_settings.py]"]
end

subgraph group_data["Data Pipeline"]
  node_loader["Dataset Loader<br/>[loader.py]"]
  node_cleaner["Traffic Cleaning<br/>[cleaner.py]"]
  node_preprocessing["Leakage-Safe Preprocessing<br/>[preprocessing.py]"]
  node_features["Feature Engineering"]
end

subgraph group_detection["Detection &amp; Response"]
  node_inference["Unified Detection<br/>[inference.py]"]
  node_anomaly["Anomaly Detection"]
  node_threat["Threat Scoring<br/>[threat_scoring.py]"]
  node_shap["SHAP Explainer<br/>[shap_explainer.py]"]
  node_response["Dry-Run Response<br/>[response_engine.py]"]
end

subgraph group_ml["Models &amp; Evaluation"]
  node_trainer["Model Trainer<br/>[trainer.py]"]
  node_supervised["Supervised Classifiers<br/>[xgboost_model.py]"]
  node_ensemble["Hybrid Ensemble<br/>[ensemble.py]"]
  node_autoencoder["Benign Autoencoder<br/>[autoencoder.py]"]
  node_evaluation["Evaluation Protocols<br/>[protocols.py]"]
  node_registry[("Artifact Registry<br/>[model_registry.py]")]
end

node_analyst(("SOC Analyst"))

node_analyst -->|"opens"| node_app
node_app -->|"routes to"| node_overview
node_app -->|"routes to"| node_predict
node_app -->|"routes to"| node_explorer
node_app -->|"routes to"| node_performance
node_app -->|"routes to"| node_explain_view
node_app -->|"routes to"| node_response_view
node_app -->|"routes to"| node_settings
node_overview -->|"loads dashboard data"| node_data_access
node_predict -->|"requests predictions"| node_data_access
node_explorer -->|"loads dataset data"| node_data_access
node_performance -->|"loads metrics"| node_data_access
node_explain_view -->|"loads explanations"| node_data_access
node_response_view -->|"loads response data"| node_data_access
node_settings -->|"loads settings data"| node_data_access
node_data_access -->|"creates inference engine"| node_inference
node_data_access -->|"loads artifacts"| node_registry
node_data_access -->|"loads dataset"| node_loader
node_loader -->|"cleans traffic"| node_cleaner
node_preprocessing -->|"loads source data"| node_loader
node_preprocessing -->|"cleans before splitting"| node_cleaner
node_preprocessing -->|"transforms features"| node_features
node_trainer -->|"prepares splits"| node_preprocessing
node_trainer -->|"trains classifiers"| node_supervised
node_trainer -->|"trains anomaly model"| node_autoencoder
node_trainer -->|"evaluates fusion"| node_ensemble
node_trainer -->|"runs protocols"| node_evaluation
node_trainer -->|"persists artifacts"| node_registry
node_inference -->|"validates features"| node_features
node_inference -->|"combines predictions"| node_ensemble
node_inference -->|"detects novelty"| node_anomaly
node_inference -->|"requests explanations"| node_shap
node_inference -->|"invokes response"| node_response
node_anomaly -->|"scores reconstruction"| node_autoencoder
node_response -->|"uses threat levels"| node_threat
node_inference -.->|"scores threats"| node_threat
node_inference -.->|"predicts classes"| node_supervised

click node_app "https://github.com/nhahub/nha-5-211/blob/main/app.py"
click node_data_access "https://github.com/nhahub/nha-5-211/blob/main/dashboard/data_access.py"
click node_overview "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/overview.py"
click node_predict "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/predict_flow.py"
click node_explorer "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/dataset_explorer.py"
click node_performance "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/model_performance.py"
click node_explain_view "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/explainability.py"
click node_response_view "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/active_response.py"
click node_settings "https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/system_settings.py"
click node_loader "https://github.com/nhahub/nha-5-211/blob/main/src/data/loader.py"
click node_cleaner "https://github.com/nhahub/nha-5-211/blob/main/src/data/cleaner.py"
click node_preprocessing "https://github.com/nhahub/nha-5-211/blob/main/src/data/preprocessing.py"
click node_features "https://github.com/nhahub/nha-5-211/blob/main/src/data/feature_engineering.py"
click node_trainer "https://github.com/nhahub/nha-5-211/blob/main/src/training/trainer.py"
click node_supervised "https://github.com/nhahub/nha-5-211/blob/main/src/models/xgboost_model.py"
click node_ensemble "https://github.com/nhahub/nha-5-211/blob/main/src/models/ensemble.py"
click node_autoencoder "https://github.com/nhahub/nha-5-211/blob/main/src/models/autoencoder.py"
click node_evaluation "https://github.com/nhahub/nha-5-211/blob/main/src/evaluation/protocols.py"
click node_inference "https://github.com/nhahub/nha-5-211/blob/main/src/detection/inference.py"
click node_anomaly "https://github.com/nhahub/nha-5-211/blob/main/src/detection/anomaly_detection.py"
click node_threat "https://github.com/nhahub/nha-5-211/blob/main/src/detection/threat_scoring.py"
click node_shap "https://github.com/nhahub/nha-5-211/blob/main/src/explainability/shap_explainer.py"
click node_response "https://github.com/nhahub/nha-5-211/blob/main/src/response/response_engine.py"
click node_registry "https://github.com/nhahub/nha-5-211/blob/main/src/utils/model_registry.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_app,node_data_access,node_overview,node_predict,node_explorer,node_performance,node_explain_view,node_response_view,node_settings toneBlue
class node_loader,node_cleaner,node_preprocessing,node_features toneAmber
class node_inference,node_anomaly,node_threat,node_shap,node_response toneMint
class node_trainer,node_supervised,node_ensemble,node_autoencoder,node_evaluation,node_registry toneRose
class node_analyst toneIndigo
```

## Components

### SOC Dashboard

- [Dashboard App](https://github.com/nhahub/nha-5-211/blob/main/app.py): `app.py`
- [Dashboard Data Access](https://github.com/nhahub/nha-5-211/blob/main/dashboard/data_access.py): `dashboard/data_access.py`
- [SOC Overview](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/overview.py): `dashboard/pages/overview.py`
- [Flow Prediction](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/predict_flow.py): `dashboard/pages/predict_flow.py`
- [Dataset Explorer](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/dataset_explorer.py): `dashboard/pages/dataset_explorer.py`
- [Model Performance](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/model_performance.py): `dashboard/pages/model_performance.py`
- [Explainability View](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/explainability.py): `dashboard/pages/explainability.py`
- [Active Response View](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/active_response.py): `dashboard/pages/active_response.py`
- [System Settings](https://github.com/nhahub/nha-5-211/blob/main/dashboard/pages/system_settings.py): `dashboard/pages/system_settings.py`

### Data Pipeline

- [Dataset Loader](https://github.com/nhahub/nha-5-211/blob/main/src/data/loader.py): `src/data/loader.py`
- [Traffic Cleaning](https://github.com/nhahub/nha-5-211/blob/main/src/data/cleaner.py): `src/data/cleaner.py`
- [Leakage-Safe Preprocessing](https://github.com/nhahub/nha-5-211/blob/main/src/data/preprocessing.py): `src/data/preprocessing.py`
- [Feature Engineering](https://github.com/nhahub/nha-5-211/blob/main/src/data/feature_engineering.py): `src/data/feature_engineering.py`

### Detection & Response

- [Unified Detection](https://github.com/nhahub/nha-5-211/blob/main/src/detection/inference.py): `src/detection/inference.py`
- [Anomaly Detection](https://github.com/nhahub/nha-5-211/blob/main/src/detection/anomaly_detection.py): `src/detection/anomaly_detection.py`
- [Threat Scoring](https://github.com/nhahub/nha-5-211/blob/main/src/detection/threat_scoring.py): `src/detection/threat_scoring.py`
- [SHAP Explainer](https://github.com/nhahub/nha-5-211/blob/main/src/explainability/shap_explainer.py): `src/explainability/shap_explainer.py`
- [Dry-Run Response](https://github.com/nhahub/nha-5-211/blob/main/src/response/response_engine.py): `src/response/response_engine.py`

### Models & Evaluation

- [Model Trainer](https://github.com/nhahub/nha-5-211/blob/main/src/training/trainer.py): `src/training/trainer.py`
- [Supervised Classifiers](https://github.com/nhahub/nha-5-211/blob/main/src/models/xgboost_model.py): `src/models/xgboost_model.py`
- [Hybrid Ensemble](https://github.com/nhahub/nha-5-211/blob/main/src/models/ensemble.py): `src/models/ensemble.py`
- [Benign Autoencoder](https://github.com/nhahub/nha-5-211/blob/main/src/models/autoencoder.py): `src/models/autoencoder.py`
- [Evaluation Protocols](https://github.com/nhahub/nha-5-211/blob/main/src/evaluation/protocols.py): `src/evaluation/protocols.py`
- [Artifact Registry](https://github.com/nhahub/nha-5-211/blob/main/src/utils/model_registry.py): `src/utils/model_registry.py`

### Other components

- **SOC Analyst**

## Connections

- SOC Analyst → Dashboard App: opens
- Dashboard App → SOC Overview: routes to (evidence: `app.py`)
- Dashboard App → Flow Prediction: routes to (evidence: `app.py`)
- Dashboard App → Dataset Explorer: routes to (evidence: `app.py`)
- Dashboard App → Model Performance: routes to (evidence: `app.py`)
- Dashboard App → Explainability View: routes to (evidence: `app.py`)
- Dashboard App → Active Response View: routes to (evidence: `app.py`)
- Dashboard App → System Settings: routes to (evidence: `app.py`)
- SOC Overview → Dashboard Data Access: loads dashboard data (evidence: `dashboard/pages/overview.py`)
- Flow Prediction → Dashboard Data Access: requests predictions (evidence: `dashboard/pages/predict_flow.py`)
- Dataset Explorer → Dashboard Data Access: loads dataset data (evidence: `dashboard/pages/dataset_explorer.py`)
- Model Performance → Dashboard Data Access: loads metrics (evidence: `dashboard/pages/model_performance.py`)
- Explainability View → Dashboard Data Access: loads explanations (evidence: `dashboard/pages/explainability.py`)
- Active Response View → Dashboard Data Access: loads response data (evidence: `dashboard/pages/active_response.py`)
- System Settings → Dashboard Data Access: loads settings data (evidence: `dashboard/pages/system_settings.py`)
- Dashboard Data Access → Unified Detection: creates inference engine (evidence: `dashboard/data_access.py`)
- Dashboard Data Access → Artifact Registry: loads artifacts (evidence: `dashboard/data_access.py`)
- Dashboard Data Access → Dataset Loader: loads dataset (evidence: `dashboard/data_access.py`)
- Dataset Loader → Traffic Cleaning: cleans traffic (evidence: `src/data/loader.py`)
- Leakage-Safe Preprocessing → Dataset Loader: loads source data (evidence: `src/data/preprocessing.py`)
- Leakage-Safe Preprocessing → Traffic Cleaning: cleans before splitting (evidence: `src/data/preprocessing.py`)
- Leakage-Safe Preprocessing → Feature Engineering: transforms features (evidence: `src/data/preprocessing.py`)
- Model Trainer → Leakage-Safe Preprocessing: prepares splits (evidence: `src/training/trainer.py`)
- Model Trainer → Supervised Classifiers: trains classifiers (evidence: `src/training/trainer.py`)
- Model Trainer → Benign Autoencoder: trains anomaly model (evidence: `src/training/trainer.py`)
- Model Trainer → Hybrid Ensemble: evaluates fusion (evidence: `src/training/trainer.py`)
- Model Trainer → Evaluation Protocols: runs protocols (evidence: `src/training/trainer.py`)
- Model Trainer → Artifact Registry: persists artifacts (evidence: `src/training/trainer.py`)
- Unified Detection → Feature Engineering: validates features (evidence: `src/detection/inference.py`)
- Unified Detection → Hybrid Ensemble: combines predictions (evidence: `src/detection/inference.py`)
- Unified Detection → Anomaly Detection: detects novelty (evidence: `src/detection/inference.py`)
- Unified Detection → SHAP Explainer: requests explanations (evidence: `src/detection/inference.py`)
- Unified Detection → Dry-Run Response: invokes response (evidence: `src/detection/inference.py`)
- Anomaly Detection → Benign Autoencoder: scores reconstruction (evidence: `src/detection/anomaly_detection.py`)
- Dry-Run Response → Threat Scoring: uses threat levels (evidence: `src/response/response_engine.py`)
- Unified Detection → Threat Scoring: scores threats (evidence: `src/detection/inference.py`)
- Unified Detection → Supervised Classifiers: predicts classes
