# karuna-ss/blacktrace architecture

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

- Interactive diagram: https://gitdiagram.com/karuna-ss/blacktrace
- Repository: https://github.com/karuna-ss/blacktrace

## Overview

BlackTrace is a host-based intrusion detection system: it captures network traffic, turns packet windows into features, scores them with an Isolation Forest, and exposes results to a monitoring dashboard. A separate training path fits and saves the model from a balanced CSV dataset. The dashboard polls the latest inference and presents threat status, trends, and attacker-IP information. Evidence is limited to the supplied excerpts and source index; the README is empty, so undocumented capabilities and unshown connections are omitted.

Main entry points: [`Backend/Intrusion/sliding_window/feature_extraction.py`](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Intrusion/sliding_window/feature_extraction.py) (Packet capture and windows), [`Backend/app.py`](https://github.com/karuna-ss/blacktrace/blob/main/Backend/app.py) (Inference API), [`Backend/Detection/model_training.py`](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Detection/model_training.py) (Model training), [`Backend/models/IsoForest.pkl`](https://github.com/karuna-ss/blacktrace/blob/main/Backend/models/IsoForest.pkl) (Isolation Forest model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Traffic capture"]
  node_extractor["Packet capture and windows"]
  node_decoder["Packet decoding<br/>[packets.py]"]
  node_traffic_csv[("Traffic feature CSV<br/>[Intrusion.csv]")]
end

subgraph group_analysis["Detection and training"]
  node_training_csv[("Balanced training data")]
  node_trainer["Model training<br/>[model_training.py]"]
  node_model[("Isolation Forest model<br/>[IsoForest.pkl]")]
  node_inference_module["Inference runner<br/>[model_inference.py]"]
end

subgraph group_service["Inference service"]
  node_api["Inference API<br/>[app.py]"]
end

subgraph group_ui["Monitoring interface"]
  node_dashboard["Threat monitoring dashboard<br/>[dashboard.js]"]
end

node_network(("Network traffic"))
node_analyst(("Security analyst"))

node_network -->|"supplies traffic"| node_extractor
node_extractor -->|"decodes packets"| node_decoder
node_extractor -->|"writes features"| node_traffic_csv
node_training_csv -->|"provides samples"| node_trainer
node_trainer -->|"saves model"| node_model
node_model -->|"loads model"| node_api
node_extractor -->|"provides latest features"| node_api
node_api -->|"serves latest inference"| node_dashboard
node_analyst -.->|"monitors alerts"| node_dashboard

click node_extractor "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Intrusion/sliding_window/feature_extraction.py"
click node_decoder "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Intrusion/scapy/packets.py"
click node_traffic_csv "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Data/Intrusion.csv"
click node_training_csv "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Data/Intrusion_fixed_balanced.csv"
click node_trainer "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Detection/model_training.py"
click node_model "https://github.com/karuna-ss/blacktrace/blob/main/Backend/models/IsoForest.pkl"
click node_api "https://github.com/karuna-ss/blacktrace/blob/main/Backend/app.py"
click node_inference_module "https://github.com/karuna-ss/blacktrace/blob/main/Backend/Detection/model_inference.py"
click node_dashboard "https://github.com/karuna-ss/blacktrace/blob/main/Frontend/js/dashboard.js"

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_extractor,node_decoder,node_traffic_csv toneBlue
class node_training_csv,node_trainer,node_model,node_inference_module toneAmber
class node_api toneMint
class node_dashboard toneRose
class node_network,node_analyst toneIndigo
```

## Components

### Traffic capture

- [Packet capture and windows](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Intrusion/sliding_window/feature_extraction.py): `Backend/Intrusion/sliding_window/feature_extraction.py`
- [Packet decoding](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Intrusion/scapy/packets.py): `Backend/Intrusion/scapy/packets.py`
- [Traffic feature CSV](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Data/Intrusion.csv): `Backend/Data/Intrusion.csv`

### Detection and training

- [Balanced training data](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Data/Intrusion_fixed_balanced.csv): `Backend/Data/Intrusion_fixed_balanced.csv`
- [Model training](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Detection/model_training.py): `Backend/Detection/model_training.py`
- [Isolation Forest model](https://github.com/karuna-ss/blacktrace/blob/main/Backend/models/IsoForest.pkl): `Backend/models/IsoForest.pkl`
- [Inference runner](https://github.com/karuna-ss/blacktrace/blob/main/Backend/Detection/model_inference.py): `Backend/Detection/model_inference.py`

### Inference service

- [Inference API](https://github.com/karuna-ss/blacktrace/blob/main/Backend/app.py): `Backend/app.py`

### Monitoring interface

- [Threat monitoring dashboard](https://github.com/karuna-ss/blacktrace/blob/main/Frontend/js/dashboard.js): `Frontend/js/dashboard.js`

### Other components

- **Network traffic**
- **Security analyst**

## Connections

- Network traffic → Packet capture and windows: supplies traffic (evidence: `Backend/Intrusion/sliding_window/feature_extraction.py`)
- Packet capture and windows → Packet decoding: decodes packets (evidence: `Backend/Intrusion/sliding_window/feature_extraction.py`)
- Packet capture and windows → Traffic feature CSV: writes features (evidence: `Backend/Intrusion/sliding_window/feature_extraction.py`)
- Balanced training data → Model training: provides samples (evidence: `Backend/Detection/model_training.py`)
- Model training → Isolation Forest model: saves model (evidence: `Backend/Detection/model_training.py`)
- Isolation Forest model → Inference API: loads model (evidence: `Backend/app.py`)
- Packet capture and windows → Inference API: provides latest features (evidence: `Backend/app.py`)
- Inference API → Threat monitoring dashboard: serves latest inference (evidence: `Frontend/js/dashboard.js`)
- Security analyst → Threat monitoring dashboard: monitors alerts
