# akshayetukuri/ai-ids-capstone architecture

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

- Interactive diagram: https://gitdiagram.com/akshayetukuri/ai-ids-capstone
- Repository: https://github.com/akshayetukuri/ai-ids-capstone

## Overview

AI-IDS is a CICIDS2017 intrusion-detection research pipeline comparing a leakage-conscious Random Forest baseline with a chunk-sequence transformer, then analyzing transformer attention. Its documented workflow runs from dataset preparation through training and interpretation; `predict.py` also provides binary inference using the saved Random Forest. Some stages are documented but their source was not sampled, so their exact internal behavior and wiring are not inferred.

Main entry points: [`predict.py`](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/predict.py) (Predict flow labels), [`baseline_dedup.py`](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/baseline_dedup.py) (Deduplicate and train RF), [`merge_data.py`](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/merge_data.py) (Merge daily flows), [`clean_data.py`](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/clean_data.py) (Clean flow data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Flow data preparation"]
  node_merge["Merge daily flows<br/>[merge_data.py]"]
  node_clean["Clean flow data<br/>[clean_data.py]"]
  node_infinity["Drop infinities<br/>[fix_infinity.py]"]
  node_dedupdata["Deduplicated flows"]
  node_sample["Stratified sample<br/>[make_sample.py]"]
  node_sampledata["150K flow sample"]
end

subgraph group_models["Model training"]
  node_dedup["Deduplicate and train RF<br/>[baseline_dedup.py]"]
  node_transformer["Train sequence transformer"]
  node_transformermodel["Transformer weights"]
  node_rfmodel["Random Forest model"]
end

subgraph group_interpret["Interpretation"]
  node_attention["Analyze attention"]
  node_attentionout["Attention by label"]
end

subgraph group_inference["Flow inference"]
  node_predict["Predict flow labels<br/>[predict.py]"]
  node_predictions["Predictions CSV"]
end

node_dataset(("CICIDS2017 CSVs"))
node_user(("Analyst"))
node_newflows(("New flow records"))

node_dataset -->|"loads CSVs"| node_merge
node_merge -->|"combined data"| node_clean
node_clean -->|"cleaned data"| node_infinity
node_infinity -->|"clean flows"| node_dedup
node_dedup -->|"writes dataset"| node_dedupdata
node_dedup -->|"saves model"| node_rfmodel
node_dedupdata -->|"samples flows"| node_sample
node_sample -->|"writes sample"| node_sampledata
node_sampledata -->|"loads sample"| node_transformer
node_transformer -->|"saves weights"| node_transformermodel
node_sampledata -->|"loads sample"| node_attention
node_attention -->|"writes analysis"| node_attentionout
node_user -->|"requests inference"| node_predict
node_newflows -->|"supplies records"| node_predict
node_rfmodel -->|"loads model"| node_predict
node_predict -->|"writes results"| node_predictions

click node_merge "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/merge_data.py"
click node_clean "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/clean_data.py"
click node_infinity "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/fix_infinity.py"
click node_dedup "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/baseline_dedup.py"
click node_sample "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/make_sample.py"
click node_transformer "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/train_transformer.py"
click node_attention "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/attention_analysis.py"
click node_predict "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/predict.py"
click node_rfmodel "https://github.com/akshayetukuri/ai-ids-capstone/blob/main/rf_binary_baseline_dedup.joblib"

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_merge,node_clean,node_infinity,node_dedupdata,node_sample,node_sampledata toneBlue
class node_dedup,node_transformer,node_transformermodel,node_rfmodel toneAmber
class node_attention,node_attentionout toneMint
class node_predict,node_predictions toneRose
class node_dataset,node_user,node_newflows toneIndigo
```

## Components

### Flow data preparation

- [Merge daily flows](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/merge_data.py): `merge_data.py`
- [Clean flow data](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/clean_data.py): `clean_data.py`
- [Drop infinities](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/fix_infinity.py): `fix_infinity.py`
- **Deduplicated flows**
- [Stratified sample](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/make_sample.py): `make_sample.py`
- **150K flow sample**

### Model training

- [Deduplicate and train RF](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/baseline_dedup.py): `baseline_dedup.py`
- [Train sequence transformer](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/train_transformer.py): `train_transformer.py`
- **Transformer weights**
- [Random Forest model](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/rf_binary_baseline_dedup.joblib): `rf_binary_baseline_dedup.joblib`

### Interpretation

- [Analyze attention](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/attention_analysis.py): `attention_analysis.py`
- **Attention by label**

### Flow inference

- [Predict flow labels](https://github.com/akshayetukuri/ai-ids-capstone/blob/main/predict.py): `predict.py`
- **Predictions CSV**

### Other components

- **CICIDS2017 CSVs**
- **Analyst**
- **New flow records**

## Connections

- CICIDS2017 CSVs → Merge daily flows: loads CSVs
- Merge daily flows → Clean flow data: combined data
- Clean flow data → Drop infinities: cleaned data
- Drop infinities → Deduplicate and train RF: clean flows
- Deduplicate and train RF → Deduplicated flows: writes dataset
- Deduplicate and train RF → Random Forest model: saves model
- Deduplicated flows → Stratified sample: samples flows
- Stratified sample → 150K flow sample: writes sample
- 150K flow sample → Train sequence transformer: loads sample
- Train sequence transformer → Transformer weights: saves weights
- 150K flow sample → Analyze attention: loads sample
- Analyze attention → Attention by label: writes analysis
- Analyst → Predict flow labels: requests inference
- New flow records → Predict flow labels: supplies records
- Random Forest model → Predict flow labels: loads model
- Predict flow labels → Predictions CSV: writes results
