# thisakg/praetorian architecture

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

- Interactive diagram: https://gitdiagram.com/thisakg/praetorian
- Repository: https://github.com/thisakg/praetorian

## Overview

Praetorian generates synthetic authentication events, splits and preprocesses them, trains an Isolation Forest, then scores and presents data in a Streamlit dashboard. The dashboard also supports evaluation, visualizations, and CSV export. Source excerpts confirm the generator, split, preprocessing, model, evaluation, and dashboard behavior; some training and data-stage links are documented only in the README.

Main entry points: [`app/dashboard.py`](https://github.com/thisakg/praetorian/blob/main/app/dashboard.py) (Streamlit dashboard), [`app/preprocess.py`](https://github.com/thisakg/praetorian/blob/main/app/preprocess.py) (Feature preprocessing), [`plots/evaluate.py`](https://github.com/thisakg/praetorian/blob/main/plots/evaluate.py) (Model evaluation), [`data/train_preprocessed.csv`](https://github.com/thisakg/praetorian/blob/main/data/train_preprocessed.csv) (Processed datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_generator["Synthetic logins<br/>[generate_data.py]"]
  node_rawdata["Login dataset"]
  node_splitter["Train-test split<br/>[split.py]"]
  node_splits["Train and test data<br/>[train.csv]"]
  node_preprocessor["Feature preprocessing<br/>[preprocess.py]"]
  node_scaler["Feature scaler<br/>[scaler.save]"]
  node_features["Processed datasets"]
end

subgraph group_detection["Detection pipeline"]
  node_trainer["Isolation Forest training<br/>[model.py]"]
  node_model["Trained model"]
end

subgraph group_dashboard["Dashboard experience"]
  node_dashboard["Streamlit dashboard<br/>[dashboard.py]"]
  node_scoring["Anomaly scoring<br/>[dashboard.py]"]
  node_presentation["Plots and CSV export<br/>[dashboard.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Model evaluation<br/>[evaluate.py]"]
  node_metrics["Evaluation plots and metrics"]
end

node_user(("Security analyst"))

node_generator -->|"writes events"| node_rawdata
node_rawdata -->|"reads dataset"| node_splitter
node_splitter -->|"writes splits"| node_splits
node_splits -->|"preprocesses"| node_preprocessor
node_preprocessor -->|"saves and loads"| node_scaler
node_preprocessor -->|"writes features"| node_features
node_features -->|"trains on"| node_trainer
node_trainer -->|"saves model"| node_model
node_user -->|"uses"| node_dashboard
node_dashboard -->|"preprocesses uploads"| node_preprocessor
node_dashboard -->|"loads sample data"| node_features
node_dashboard -->|"loads model"| node_model
node_dashboard -->|"runs analysis"| node_scoring
node_scoring -->|"presents results"| node_presentation
node_dashboard -->|"runs evaluation"| node_evaluator
node_evaluator -->|"loads model"| node_model
node_evaluator -->|"saves plots"| node_metrics

click node_generator "https://github.com/thisakg/praetorian/blob/main/src/data/generate_data.py"
click node_rawdata "https://github.com/thisakg/praetorian/blob/main/data/synthetic_logins.csv"
click node_splitter "https://github.com/thisakg/praetorian/blob/main/src/data/split.py"
click node_splits "https://github.com/thisakg/praetorian/blob/main/data/train.csv"
click node_preprocessor "https://github.com/thisakg/praetorian/blob/main/app/preprocess.py"
click node_scaler "https://github.com/thisakg/praetorian/blob/main/scaler.save"
click node_features "https://github.com/thisakg/praetorian/blob/main/data/train_preprocessed.csv"
click node_trainer "https://github.com/thisakg/praetorian/blob/main/app/model.py"
click node_model "https://github.com/thisakg/praetorian/blob/main/models/isolation_forest.pkl"
click node_dashboard "https://github.com/thisakg/praetorian/blob/main/app/dashboard.py"
click node_scoring "https://github.com/thisakg/praetorian/blob/main/app/dashboard.py"
click node_presentation "https://github.com/thisakg/praetorian/blob/main/app/dashboard.py"
click node_evaluator "https://github.com/thisakg/praetorian/blob/main/plots/evaluate.py"
click node_metrics "https://github.com/thisakg/praetorian/tree/main/plots"

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_generator,node_rawdata,node_splitter,node_splits,node_preprocessor,node_scaler,node_features toneBlue
class node_trainer,node_model toneAmber
class node_dashboard,node_scoring,node_presentation toneMint
class node_evaluator,node_metrics toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [Synthetic logins](https://github.com/thisakg/praetorian/blob/main/src/data/generate_data.py): `src/data/generate_data.py`
- [Login dataset](https://github.com/thisakg/praetorian/blob/main/data/synthetic_logins.csv): `data/synthetic_logins.csv`
- [Train-test split](https://github.com/thisakg/praetorian/blob/main/src/data/split.py): `src/data/split.py`
- [Train and test data](https://github.com/thisakg/praetorian/blob/main/data/train.csv): `data/train.csv`
- [Feature preprocessing](https://github.com/thisakg/praetorian/blob/main/app/preprocess.py): `app/preprocess.py`
- [Feature scaler](https://github.com/thisakg/praetorian/blob/main/scaler.save): `scaler.save`
- [Processed datasets](https://github.com/thisakg/praetorian/blob/main/data/train_preprocessed.csv): `data/train_preprocessed.csv`

### Detection pipeline

- [Isolation Forest training](https://github.com/thisakg/praetorian/blob/main/app/model.py): `app/model.py`
- [Trained model](https://github.com/thisakg/praetorian/blob/main/models/isolation_forest.pkl): `models/isolation_forest.pkl`

### Dashboard experience

- [Streamlit dashboard](https://github.com/thisakg/praetorian/blob/main/app/dashboard.py): `app/dashboard.py`
- [Anomaly scoring](https://github.com/thisakg/praetorian/blob/main/app/dashboard.py): `app/dashboard.py`
- [Plots and CSV export](https://github.com/thisakg/praetorian/blob/main/app/dashboard.py): `app/dashboard.py`

### Evaluation

- [Model evaluation](https://github.com/thisakg/praetorian/blob/main/plots/evaluate.py): `plots/evaluate.py`
- [Evaluation plots and metrics](https://github.com/thisakg/praetorian/tree/main/plots): `plots`

### Other components

- **Security analyst**

## Connections

- Synthetic logins → Login dataset: writes events (evidence: `src/data/generate_data.py`)
- Login dataset → Train-test split: reads dataset (evidence: `src/data/split.py`)
- Train-test split → Train and test data: writes splits (evidence: `src/data/split.py`)
- Train and test data → Feature preprocessing: preprocesses (evidence: `README.md`)
- Feature preprocessing → Feature scaler: saves and loads (evidence: `app/preprocess.py`)
- Feature preprocessing → Processed datasets: writes features (evidence: `app/preprocess.py`)
- Processed datasets → Isolation Forest training: trains on (evidence: `README.md`)
- Isolation Forest training → Trained model: saves model (evidence: `app/model.py`)
- Security analyst → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Feature preprocessing: preprocesses uploads (evidence: `app/dashboard.py`)
- Streamlit dashboard → Processed datasets: loads sample data (evidence: `app/dashboard.py`)
- Streamlit dashboard → Trained model: loads model (evidence: `app/dashboard.py`)
- Streamlit dashboard → Anomaly scoring: runs analysis (evidence: `app/dashboard.py`)
- Anomaly scoring → Plots and CSV export: presents results (evidence: `app/dashboard.py`)
- Streamlit dashboard → Model evaluation: runs evaluation (evidence: `app/dashboard.py`)
- Model evaluation → Trained model: loads model (evidence: `plots/evaluate.py`)
- Model evaluation → Evaluation plots and metrics: saves plots (evidence: `plots/evaluate.py`)
