# chaudharybishal091/ids architecture

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

- Interactive diagram: https://gitdiagram.com/chaudharybishal091/ids
- Repository: https://github.com/chaudharybishal091/ids

## Overview

This is a machine-learning network intrusion detection system. Its principal workflow turns prepared traffic data into trained models, then accepts live or batch flows through the API, classifies attacks, persists predictions and alerts, and presents results in a dashboard. A Zeek watcher bridges live Zeek logs to the API; optional response actions and WhatsApp alerts extend detection. The graph includes documented capabilities and source-index relationships; some unsampled API integrations are connected only where the index names the dependency, so their exact call behavior is not established here.

Main entry points: [`src/api/app.py`](https://github.com/chaudharybishal091/ids/blob/main/src/api/app.py) (Prediction API), [`main.py`](https://github.com/chaudharybishal091/ids/blob/main/main.py) (CLI entry point), [`src/models/train.py`](https://github.com/chaudharybishal091/ids/blob/main/src/models/train.py) (Training workflow), [`src/data_Pipelines/real_dataset_prep.py`](https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/real_dataset_prep.py) (Public dataset prep)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_sample_data["Sample data generator"]
  node_dataset_prep["Public dataset prep"]
  node_zeek_pipeline["Zeek log parser<br/>[zeek_pipeline.py]"]
  node_data_pipeline["Preprocessing<br/>[data_pipeline.py]"]
end

subgraph group_ml["Model training"]
  node_trainer["Training workflow<br/>[train.py]"]
  node_models["ML models<br/>[models.py]"]
end

subgraph group_live["Live detection"]
  node_cli["CLI entry point<br/>[main.py]"]
  node_zeek_watcher["Zeek log watcher<br/>[zeek_watcher.py]"]
  node_api["Prediction API<br/>[app.py]"]
  node_correlation["Flow correlation"]
  node_labels["Label normalization<br/>[labels.py]"]
end

subgraph group_ops["Response and persistence"]
  node_response["Response actions<br/>[response_engine.py]"]
  node_whatsapp["WhatsApp alerts<br/>[whatsapp_alert.py]"]
  node_store[("SQLite persistence<br/>[sqlite_store.py]")]
end

subgraph group_ui["Monitoring"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_replay["Dataset replay<br/>[dataset_replay.py]"]
end

node_operator(("Operator"))
node_traffic_data["Traffic datasets"]
node_zeek_sensor(("Zeek sensor"))
node_api_clients(("API clients"))
node_twilio["Twilio WhatsApp"]

node_operator -->|"runs commands"| node_cli
node_traffic_data -->|"supplies CSVs"| node_dataset_prep
node_traffic_data -->|"supplies data"| node_data_pipeline
node_operator -->|"generates samples"| node_sample_data
node_cli -->|"dispatches"| node_sample_data
node_cli -->|"dispatches"| node_dataset_prep
node_dataset_prep -->|"normalizes labels"| node_labels
node_operator -->|"trains model"| node_trainer
node_trainer -->|"prepares data"| node_data_pipeline
node_trainer -->|"trains models"| node_models
node_zeek_sensor -->|"writes conn.log"| node_zeek_watcher
node_operator -->|"starts bridge"| node_zeek_watcher
node_zeek_watcher -->|"forwards flows"| node_api
node_zeek_pipeline -->|"converts Zeek flows"| node_api
node_api_clients -->|"submits flows"| node_api
node_api -->|"predicts with"| node_models
node_api -->|"transforms flows"| node_data_pipeline
node_api -->|"correlates detections"| node_correlation
node_api -->|"normalizes results"| node_labels
node_api -->|"persists results"| node_store
node_api -->|"requests response"| node_response
node_api -->|"sends alerts"| node_whatsapp
node_whatsapp -.->|"delivers messages"| node_twilio
node_operator -->|"views monitoring"| node_dashboard
node_dashboard -->|"reads snapshots"| node_store
node_operator -->|"replays dataset"| node_replay
node_replay -->|"posts batches"| node_api
node_cli -->|"dispatches"| node_replay

click node_sample_data "https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/generate_sample_data.py"
click node_dataset_prep "https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/real_dataset_prep.py"
click node_zeek_pipeline "https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/zeek_pipeline.py"
click node_data_pipeline "https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/data_pipeline.py"
click node_trainer "https://github.com/chaudharybishal091/ids/blob/main/src/models/train.py"
click node_models "https://github.com/chaudharybishal091/ids/blob/main/src/models/models.py"
click node_cli "https://github.com/chaudharybishal091/ids/blob/main/main.py"
click node_zeek_watcher "https://github.com/chaudharybishal091/ids/blob/main/src/real_time/zeek_watcher.py"
click node_api "https://github.com/chaudharybishal091/ids/blob/main/src/api/app.py"
click node_correlation "https://github.com/chaudharybishal091/ids/blob/main/src/utils/flow_correlation.py"
click node_labels "https://github.com/chaudharybishal091/ids/blob/main/src/utils/labels.py"
click node_response "https://github.com/chaudharybishal091/ids/blob/main/src/utils/response_engine.py"
click node_whatsapp "https://github.com/chaudharybishal091/ids/blob/main/src/utils/whatsapp_alert.py"
click node_store "https://github.com/chaudharybishal091/ids/blob/main/src/utils/sqlite_store.py"
click node_dashboard "https://github.com/chaudharybishal091/ids/blob/main/src/visualization/dashboard.py"
click node_replay "https://github.com/chaudharybishal091/ids/blob/main/src/verification/dataset_replay.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_sample_data,node_dataset_prep,node_zeek_pipeline,node_data_pipeline,node_api_clients toneBlue
class node_trainer,node_models toneAmber
class node_cli,node_zeek_watcher,node_api,node_correlation,node_labels toneMint
class node_response,node_whatsapp,node_store toneRose
class node_dashboard,node_replay,node_operator,node_traffic_data,node_zeek_sensor,node_twilio toneIndigo
```

## Components

### Data preparation

- [Sample data generator](https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/generate_sample_data.py): `src/data_Pipelines/generate_sample_data.py`
- [Public dataset prep](https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/real_dataset_prep.py): `src/data_Pipelines/real_dataset_prep.py`
- [Zeek log parser](https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/zeek_pipeline.py): `src/data_Pipelines/zeek_pipeline.py`
- [Preprocessing](https://github.com/chaudharybishal091/ids/blob/main/src/data_Pipelines/data_pipeline.py): `src/data_Pipelines/data_pipeline.py`

### Model training

- [Training workflow](https://github.com/chaudharybishal091/ids/blob/main/src/models/train.py): `src/models/train.py`
- [ML models](https://github.com/chaudharybishal091/ids/blob/main/src/models/models.py): `src/models/models.py`

### Live detection

- [CLI entry point](https://github.com/chaudharybishal091/ids/blob/main/main.py): `main.py`
- [Zeek log watcher](https://github.com/chaudharybishal091/ids/blob/main/src/real_time/zeek_watcher.py): `src/real_time/zeek_watcher.py`
- [Prediction API](https://github.com/chaudharybishal091/ids/blob/main/src/api/app.py): `src/api/app.py`
- [Flow correlation](https://github.com/chaudharybishal091/ids/blob/main/src/utils/flow_correlation.py): `src/utils/flow_correlation.py`
- [Label normalization](https://github.com/chaudharybishal091/ids/blob/main/src/utils/labels.py): `src/utils/labels.py`

### Response and persistence

- [Response actions](https://github.com/chaudharybishal091/ids/blob/main/src/utils/response_engine.py): `src/utils/response_engine.py`
- [WhatsApp alerts](https://github.com/chaudharybishal091/ids/blob/main/src/utils/whatsapp_alert.py): `src/utils/whatsapp_alert.py`
- [SQLite persistence](https://github.com/chaudharybishal091/ids/blob/main/src/utils/sqlite_store.py): `src/utils/sqlite_store.py`

### Monitoring

- [Dashboard](https://github.com/chaudharybishal091/ids/blob/main/src/visualization/dashboard.py): `src/visualization/dashboard.py`
- [Dataset replay](https://github.com/chaudharybishal091/ids/blob/main/src/verification/dataset_replay.py): `src/verification/dataset_replay.py`

### Other components

- **Operator**
- **Traffic datasets**
- **Zeek sensor**
- **API clients**
- **Twilio WhatsApp**

## Connections

- Operator → CLI entry point: runs commands (evidence: `README.md`)
- Traffic datasets → Public dataset prep: supplies CSVs (evidence: `README.md`)
- Traffic datasets → Preprocessing: supplies data (evidence: `README.md`)
- Operator → Sample data generator: generates samples (evidence: `README.md`)
- CLI entry point → Sample data generator: dispatches (evidence: `main.py`)
- CLI entry point → Public dataset prep: dispatches (evidence: `main.py`)
- Public dataset prep → Label normalization: normalizes labels (evidence: `src/data_Pipelines/real_dataset_prep.py`)
- Operator → Training workflow: trains model (evidence: `README.md`)
- Training workflow → Preprocessing: prepares data (evidence: `src/models/train.py`)
- Training workflow → ML models: trains models (evidence: `src/models/train.py`)
- Zeek sensor → Zeek log watcher: writes conn.log (evidence: `README.md`)
- Operator → Zeek log watcher: starts bridge (evidence: `README.md`)
- Zeek log watcher → Prediction API: forwards flows (evidence: `src/real_time/zeek_watcher.py`)
- Zeek log parser → Prediction API: converts Zeek flows (evidence: `src/api/app.py`)
- API clients → Prediction API: submits flows (evidence: `README.md`)
- Prediction API → ML models: predicts with (evidence: `src/api/app.py`)
- Prediction API → Preprocessing: transforms flows (evidence: `src/api/app.py`)
- Prediction API → Flow correlation: correlates detections (evidence: `src/api/app.py`)
- Prediction API → Label normalization: normalizes results (evidence: `src/api/app.py`)
- Prediction API → SQLite persistence: persists results (evidence: `src/api/app.py`)
- Prediction API → Response actions: requests response (evidence: `src/api/app.py`)
- Prediction API → WhatsApp alerts: sends alerts (evidence: `src/api/app.py`)
- WhatsApp alerts → Twilio WhatsApp: delivers messages
- Operator → Dashboard: views monitoring (evidence: `README.md`)
- Dashboard → SQLite persistence: reads snapshots (evidence: `src/visualization/dashboard.py`)
- Operator → Dataset replay: replays dataset (evidence: `README.md`)
- Dataset replay → Prediction API: posts batches (evidence: `src/verification/dataset_replay.py`)
- CLI entry point → Dataset replay: dispatches (evidence: `main.py`)
