# ianupk/idsgan architecture

> Architecture diagram of the GitHub repository ianupk/idsgan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ianupk/idsgan
- Repository: https://github.com/ianupk/idsgan

## Overview

IDSGAN’s main workflow turns NSL-KDD traffic into encoded records, trains black-box intrusion detectors, then trains a restricted-modification WGAN against their predictions to generate evasion examples. Evaluation measures detection and evasion rates across attack groups and IDS models; a separate baseline workflow compares other attacks. The graph also preserves dataset acquisition, feature policy, model persistence, and reporting. Relationships for unsampled modules are included only where the README or SOURCE INDEX supports them; the excerpts do not expose every runtime call or checkpoint detail.

Main entry points: [`src/data_preprocessing.py`](https://github.com/ianupk/idsgan/blob/main/src/data_preprocessing.py) (Preprocess and split), [`evaluate.py`](https://github.com/ianupk/idsgan/blob/main/evaluate.py) (Evaluate evasion), [`src/idsgan.py`](https://github.com/ianupk/idsgan/blob/main/src/idsgan.py) (IDSGAN trainer), [`train_idsgan.py`](https://github.com/ianupk/idsgan/blob/main/train_idsgan.py) (Train IDSGAN)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_download["Dataset download<br/>[download_data.py]"]
  node_preprocess["Preprocess and split"]
  node_features["Feature policy<br/>[feature_utils.py]"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_detectors["IDS models"]
  node_ids_training["Train IDS models<br/>[train_ids.py]"]
  node_ids_models["IDS model factory<br/>[ids_models.py]"]
  node_ids_store[("IDS checkpoints")]
end

subgraph group_attack["Adversarial generation"]
  node_gan_training["Train IDSGAN<br/>[train_idsgan.py]"]
  node_idsgan["IDSGAN trainer<br/>[idsgan.py]"]
  node_generator["Restricted generator<br/>[generator.py]"]
  node_critic["WGAN critic<br/>[discriminator.py]"]
  node_gan_store[("GAN checkpoints")]
end

subgraph group_analysis["Evaluation"]
  node_evaluation["Evaluate evasion<br/>[evaluate.py]"]
  node_metrics["DR and EIR metrics<br/>[metrics.py]"]
  node_figures["Result figures"]
  node_baselines["Baseline comparison<br/>[run_baselines.py]"]
end

node_dataset["NSL-KDD data"]

node_download -->|"downloads"| node_dataset
node_download -->|"uses paths"| node_config
node_preprocess -->|"loads records"| node_dataset
node_preprocess -->|"uses definitions"| node_features
node_preprocess -->|"uses paths"| node_config
node_ids_training -->|"prepares data"| node_preprocess
node_ids_training -->|"trains models"| node_ids_models
node_ids_training -->|"saves checkpoints"| node_ids_store
node_gan_training -->|"prepares data"| node_preprocess
node_gan_training -->|"loads IDS"| node_ids_models
node_gan_training -->|"loads checkpoints"| node_ids_store
node_gan_training -->|"starts training"| node_idsgan
node_gan_training -->|"saves checkpoints"| node_gan_store
node_idsgan -->|"generates records"| node_generator
node_idsgan -->|"scores records"| node_critic
node_idsgan -->|"gets masks"| node_features
node_idsgan -->|"queries predictions"| node_ids_models
node_generator -->|"uses feature indices"| node_features
node_evaluation -->|"prepares test data"| node_preprocess
node_evaluation -->|"loads generator"| node_idsgan
node_evaluation -->|"loads checkpoints"| node_gan_store
node_evaluation -->|"evaluates IDS"| node_ids_models
node_evaluation -->|"computes metrics"| node_metrics
node_evaluation -->|"produces plots"| node_figures
node_baselines -->|"prepares test data"| node_preprocess
node_baselines -->|"loads target IDS"| node_ids_models
node_baselines -->|"compares detection"| node_metrics

click node_download "https://github.com/ianupk/idsgan/blob/main/download_data.py"
click node_preprocess "https://github.com/ianupk/idsgan/blob/main/src/data_preprocessing.py"
click node_features "https://github.com/ianupk/idsgan/blob/main/src/feature_utils.py"
click node_config "https://github.com/ianupk/idsgan/blob/main/src/config.py"
click node_ids_training "https://github.com/ianupk/idsgan/blob/main/train_ids.py"
click node_ids_models "https://github.com/ianupk/idsgan/blob/main/src/ids_models.py"
click node_gan_training "https://github.com/ianupk/idsgan/blob/main/train_idsgan.py"
click node_idsgan "https://github.com/ianupk/idsgan/blob/main/src/idsgan.py"
click node_generator "https://github.com/ianupk/idsgan/blob/main/src/generator.py"
click node_critic "https://github.com/ianupk/idsgan/blob/main/src/discriminator.py"
click node_evaluation "https://github.com/ianupk/idsgan/blob/main/evaluate.py"
click node_metrics "https://github.com/ianupk/idsgan/blob/main/src/metrics.py"
click node_baselines "https://github.com/ianupk/idsgan/blob/main/run_baselines.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_download,node_preprocess,node_features,node_config toneBlue
class node_ids_training,node_ids_models,node_ids_store toneAmber
class node_gan_training,node_idsgan,node_generator,node_critic,node_gan_store toneMint
class node_evaluation,node_metrics,node_figures,node_baselines toneRose
class node_dataset toneIndigo
```

## Components

### Data preparation

- [Dataset download](https://github.com/ianupk/idsgan/blob/main/download_data.py): `download_data.py`
- [Preprocess and split](https://github.com/ianupk/idsgan/blob/main/src/data_preprocessing.py): `src/data_preprocessing.py`
- [Feature policy](https://github.com/ianupk/idsgan/blob/main/src/feature_utils.py): `src/feature_utils.py`
- [Configuration](https://github.com/ianupk/idsgan/blob/main/src/config.py): `src/config.py`

### IDS models

- [Train IDS models](https://github.com/ianupk/idsgan/blob/main/train_ids.py): `train_ids.py`
- [IDS model factory](https://github.com/ianupk/idsgan/blob/main/src/ids_models.py): `src/ids_models.py`
- **IDS checkpoints**

### Adversarial generation

- [Train IDSGAN](https://github.com/ianupk/idsgan/blob/main/train_idsgan.py): `train_idsgan.py`
- [IDSGAN trainer](https://github.com/ianupk/idsgan/blob/main/src/idsgan.py): `src/idsgan.py`
- [Restricted generator](https://github.com/ianupk/idsgan/blob/main/src/generator.py): `src/generator.py`
- [WGAN critic](https://github.com/ianupk/idsgan/blob/main/src/discriminator.py): `src/discriminator.py`
- **GAN checkpoints**

### Evaluation

- [Evaluate evasion](https://github.com/ianupk/idsgan/blob/main/evaluate.py): `evaluate.py`
- [DR and EIR metrics](https://github.com/ianupk/idsgan/blob/main/src/metrics.py): `src/metrics.py`
- **Result figures**
- [Baseline comparison](https://github.com/ianupk/idsgan/blob/main/run_baselines.py): `run_baselines.py`

### Other components

- **NSL-KDD data**

## Connections

- Dataset download → NSL-KDD data: downloads (evidence: `README.md`)
- Dataset download → Configuration: uses paths (evidence: `download_data.py`)
- Preprocess and split → NSL-KDD data: loads records (evidence: `README.md`)
- Preprocess and split → Feature policy: uses definitions (evidence: `src/data_preprocessing.py`)
- Preprocess and split → Configuration: uses paths (evidence: `src/data_preprocessing.py`)
- Train IDS models → Preprocess and split: prepares data (evidence: `train_ids.py`)
- Train IDS models → IDS model factory: trains models (evidence: `train_ids.py`)
- Train IDS models → IDS checkpoints: saves checkpoints (evidence: `README.md`)
- Train IDSGAN → Preprocess and split: prepares data (evidence: `train_idsgan.py`)
- Train IDSGAN → IDS model factory: loads IDS (evidence: `train_idsgan.py`)
- Train IDSGAN → IDS checkpoints: loads checkpoints (evidence: `README.md`)
- Train IDSGAN → IDSGAN trainer: starts training (evidence: `train_idsgan.py`)
- Train IDSGAN → GAN checkpoints: saves checkpoints (evidence: `README.md`)
- IDSGAN trainer → Restricted generator: generates records (evidence: `src/idsgan.py`)
- IDSGAN trainer → WGAN critic: scores records (evidence: `src/idsgan.py`)
- IDSGAN trainer → Feature policy: gets masks (evidence: `src/idsgan.py`)
- IDSGAN trainer → IDS model factory: queries predictions (evidence: `src/idsgan.py`)
- Restricted generator → Feature policy: uses feature indices (evidence: `src/generator.py`)
- Evaluate evasion → Preprocess and split: prepares test data (evidence: `evaluate.py`)
- Evaluate evasion → IDSGAN trainer: loads generator (evidence: `evaluate.py`)
- Evaluate evasion → GAN checkpoints: loads checkpoints (evidence: `README.md`)
- Evaluate evasion → IDS model factory: evaluates IDS (evidence: `evaluate.py`)
- Evaluate evasion → DR and EIR metrics: computes metrics (evidence: `evaluate.py`)
- Evaluate evasion → Result figures: produces plots (evidence: `README.md`)
- Baseline comparison → Preprocess and split: prepares test data (evidence: `run_baselines.py`)
- Baseline comparison → IDS model factory: loads target IDS (evidence: `run_baselines.py`)
- Baseline comparison → DR and EIR metrics: compares detection (evidence: `run_baselines.py`)
