# karan27q/ids architecture

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

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

## Overview

This is an intrusion-detection application with local and remote dashboards, live packet capture, an inference API, and optional PostgreSQL incident logging. The main workflow captures traffic or accepts feature rows, extracts or aligns features, scores them with anomaly-detection and attack-classification models, and presents results; API alerts can also be persisted. The graph preserves documented CSV evaluation and streaming utilities. Some dashboard internals and deployment integrations are unsampled, so only README-supported relationships are shown for those capabilities.

Main entry points: [`app.py`](https://github.com/karan27q/ids/blob/main/app.py) (SOC dashboard), [`engine.py`](https://github.com/karan27q/ids/blob/main/engine.py) (Feature processing and scoring), [`api.py`](https://github.com/karan27q/ids/blob/main/api.py) (Inference API), [`sniffer.py`](https://github.com/karan27q/ids/blob/main/sniffer.py) (Packet capture and flow features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Traffic and inputs"]
  node_flow_capture["Packet capture and flow features<br/>[sniffer.py]"]
  node_csv_data["Uploaded or processed CSV"]
  node_stream_eval["Streaming and model evaluation<br/>[utils.py]"]
end

subgraph group_detection["Detection runtime"]
  node_engine["Feature processing and scoring<br/>[engine.py]"]
  node_model_assets["Detection models and scaler"]
end

subgraph group_interfaces["User interfaces"]
  node_local_dashboard["SOC dashboard<br/>[app.py]"]
  node_remote_dashboard["Remote dashboard"]
  node_api["Inference API<br/>[api.py]"]
end

subgraph group_persistence["Incident storage"]
  node_incident_db[("Incident persistence<br/>[db.py]")]
end

node_operator(("Analyst or caller"))
node_network(("Live network traffic"))

node_operator -->|"uses"| node_local_dashboard
node_operator -->|"uses"| node_remote_dashboard
node_operator -->|"submits features"| node_api
node_network -->|"supplies packets"| node_flow_capture
node_local_dashboard -->|"starts capture"| node_flow_capture
node_flow_capture -->|"feeds flow features"| node_engine
node_local_dashboard -->|"runs inference"| node_engine
node_local_dashboard -->|"loads and saves"| node_csv_data
node_local_dashboard -->|"uses utilities"| node_stream_eval
node_stream_eval -.->|"evaluates models"| node_engine
node_api -->|"scores features"| node_engine
node_engine -->|"loads models"| node_model_assets
node_api -->|"writes alerts"| node_incident_db
node_remote_dashboard -->|"requests predictions"| node_api

click node_local_dashboard "https://github.com/karan27q/ids/blob/main/app.py"
click node_remote_dashboard "https://github.com/karan27q/ids/blob/main/dashboard_remote.py"
click node_flow_capture "https://github.com/karan27q/ids/blob/main/sniffer.py"
click node_csv_data "https://github.com/karan27q/ids/blob/main/processed_cybersecurity_attacks.csv"
click node_stream_eval "https://github.com/karan27q/ids/blob/main/src/utils.py"
click node_api "https://github.com/karan27q/ids/blob/main/api.py"
click node_engine "https://github.com/karan27q/ids/blob/main/engine.py"
click node_model_assets "https://github.com/karan27q/ids/blob/main/attack_classifier.h5"
click node_incident_db "https://github.com/karan27q/ids/blob/main/db.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_flow_capture,node_csv_data,node_stream_eval toneBlue
class node_engine,node_model_assets toneAmber
class node_local_dashboard,node_remote_dashboard,node_api toneMint
class node_incident_db toneRose
class node_operator,node_network toneIndigo
```

## Components

### Traffic and inputs

- [Packet capture and flow features](https://github.com/karan27q/ids/blob/main/sniffer.py): `sniffer.py`
- [Uploaded or processed CSV](https://github.com/karan27q/ids/blob/main/processed_cybersecurity_attacks.csv): `processed_cybersecurity_attacks.csv`
- [Streaming and model evaluation](https://github.com/karan27q/ids/blob/main/src/utils.py): `src/utils.py`

### Detection runtime

- [Feature processing and scoring](https://github.com/karan27q/ids/blob/main/engine.py): `engine.py`
- [Detection models and scaler](https://github.com/karan27q/ids/blob/main/attack_classifier.h5): `attack_classifier.h5`

### User interfaces

- [SOC dashboard](https://github.com/karan27q/ids/blob/main/app.py): `app.py`
- [Remote dashboard](https://github.com/karan27q/ids/blob/main/dashboard_remote.py): `dashboard_remote.py`
- [Inference API](https://github.com/karan27q/ids/blob/main/api.py): `api.py`

### Incident storage

- [Incident persistence](https://github.com/karan27q/ids/blob/main/db.py): `db.py`

### Other components

- **Analyst or caller**
- **Live network traffic**

## Connections

- Analyst or caller → SOC dashboard: uses (evidence: `README.md`)
- Analyst or caller → Remote dashboard: uses (evidence: `README.md`)
- Analyst or caller → Inference API: submits features (evidence: `api.py`)
- Live network traffic → Packet capture and flow features: supplies packets (evidence: `README.md`)
- SOC dashboard → Packet capture and flow features: starts capture (evidence: `app.py`)
- Packet capture and flow features → Feature processing and scoring: feeds flow features (evidence: `sniffer.py`)
- SOC dashboard → Feature processing and scoring: runs inference (evidence: `app.py`)
- SOC dashboard → Uploaded or processed CSV: loads and saves (evidence: `app.py`)
- SOC dashboard → Streaming and model evaluation: uses utilities (evidence: `app.py`)
- Streaming and model evaluation → Feature processing and scoring: evaluates models
- Inference API → Feature processing and scoring: scores features (evidence: `api.py`)
- Feature processing and scoring → Detection models and scaler: loads models (evidence: `engine.py`)
- Inference API → Incident persistence: writes alerts (evidence: `api.py`)
- Remote dashboard → Inference API: requests predictions (evidence: `dashboard_remote.py`)
