# vishnugovindu23-cmd/cloud-anomaly-detection architecture

> Architecture diagram of the GitHub repository vishnugovindu23-cmd/cloud-anomaly-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vishnugovindu23-cmd/cloud-anomaly-detection
- Repository: https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection

## Overview

This is a command-line AWS behavioural anomaly detector. The main workflow loads CloudTrail and VPC Flow Logs, builds identity-hour and host-hour features against a clean training baseline, scores them with a hybrid detector, groups alerts into incidents, detects periodic beacons, and writes reports and exports. The CLI also offers synthetic attack-data generation and ground-truth evaluation. Relationships are based on the sampled CLI calls, source excerpts, and README workflow; unsampled implementation details are not inferred.

Main entry points: [`cli.py`](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/cli.py) (Detection runner), [`model.py`](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py) (CloudTrail detector), [`beacon.py`](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/beacon.py) (Beacon detector), [`incidents.py`](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/incidents.py) (Incident grouping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Log ingestion"]
  node_ct_loader["CloudTrail parser<br/>[loaders.py]"]
  node_flow_loader["Flow log parser<br/>[loaders.py]"]
end

subgraph group_analysis["Behaviour analysis"]
  node_identity_features["Identity-hour features<br/>[features.py]"]
  node_host_features["Host-hour features<br/>[features.py]"]
  node_ct_detector["CloudTrail detector<br/>[model.py]"]
  node_flow_detector["Flow detector<br/>[model.py]"]
  node_beacon_detector["Beacon detector<br/>[beacon.py]"]
end

subgraph group_triage["Alert triage"]
  node_hourly_alerts["Hourly alerts<br/>[model.py]"]
  node_mitre_mapping["ATT&amp;CK mapping<br/>[mitre.py]"]
  node_incident_grouping["Incident grouping<br/>[incidents.py]"]
  node_evaluation["Ground-truth evaluation<br/>[incidents.py]"]
end

subgraph group_interface["CLI and outputs"]
  node_cli_runner["Detection runner<br/>[cli.py]"]
  node_reporting["Markdown and chart<br/>[report.py]"]
  node_output_files["Reports and CSVs"]
end

subgraph group_simulation["Synthetic data"]
  node_generator["Attack-data generator<br/>[generate.py]"]
  node_synthetic_data["Synthetic logs and labels"]
end

node_operator(("Operator"))
node_cloudtrail_logs["CloudTrail logs"]
node_flow_logs["VPC Flow Logs"]

node_operator -->|"runs"| node_cli_runner
node_cloudtrail_logs -->|"parsed by"| node_ct_loader
node_flow_logs -->|"parsed by"| node_flow_loader
node_cli_runner -->|"loads"| node_ct_loader
node_cli_runner -->|"loads"| node_flow_loader
node_cli_runner -->|"builds features"| node_identity_features
node_cli_runner -->|"builds features"| node_host_features
node_cli_runner -->|"fits and scores"| node_ct_detector
node_cli_runner -->|"fits and scores"| node_flow_detector
node_identity_features -->|"feature data"| node_ct_detector
node_host_features -->|"feature data"| node_flow_detector
node_ct_detector -->|"produces"| node_hourly_alerts
node_flow_detector -->|"produces"| node_hourly_alerts
node_ct_detector -->|"maps reasons"| node_mitre_mapping
node_flow_detector -->|"maps reasons"| node_mitre_mapping
node_cli_runner -->|"groups alerts"| node_incident_grouping
node_hourly_alerts -->|"grouped into"| node_incident_grouping
node_cli_runner -->|"detects beacons"| node_beacon_detector
node_flow_loader -->|"flow records"| node_beacon_detector
node_cli_runner -->|"evaluates results"| node_evaluation
node_incident_grouping -->|"incident results"| node_evaluation
node_beacon_detector -->|"beacon results"| node_evaluation
node_cli_runner -->|"renders outputs"| node_reporting
node_incident_grouping -->|"incident data"| node_reporting
node_beacon_detector -->|"beacon data"| node_reporting
node_reporting -->|"writes report and chart"| node_output_files
node_operator -->|"generates demo data"| node_generator
node_generator -->|"creates logs and labels"| node_synthetic_data
node_synthetic_data -->|"demo input"| node_cli_runner

click node_ct_loader "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/loaders.py"
click node_flow_loader "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/loaders.py"
click node_identity_features "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/features.py"
click node_host_features "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/features.py"
click node_ct_detector "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py"
click node_flow_detector "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py"
click node_beacon_detector "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/beacon.py"
click node_hourly_alerts "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py"
click node_mitre_mapping "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/mitre.py"
click node_incident_grouping "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/incidents.py"
click node_evaluation "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/incidents.py"
click node_cli_runner "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/cli.py"
click node_reporting "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/report.py"
click node_generator "https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/generate.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_ct_loader,node_flow_loader toneBlue
class node_identity_features,node_host_features,node_ct_detector,node_flow_detector,node_beacon_detector toneAmber
class node_hourly_alerts,node_mitre_mapping,node_incident_grouping,node_evaluation toneMint
class node_cli_runner,node_reporting,node_output_files toneRose
class node_generator,node_synthetic_data,node_operator,node_cloudtrail_logs,node_flow_logs toneIndigo
```

## Components

### Log ingestion

- [CloudTrail parser](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/loaders.py): `loaders.py`
- [Flow log parser](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/loaders.py): `loaders.py`

### Behaviour analysis

- [Identity-hour features](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/features.py): `features.py`
- [Host-hour features](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/features.py): `features.py`
- [CloudTrail detector](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py): `model.py`
- [Flow detector](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py): `model.py`
- [Beacon detector](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/beacon.py): `beacon.py`

### Alert triage

- [Hourly alerts](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/model.py): `model.py`
- [ATT&CK mapping](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/mitre.py): `mitre.py`
- [Incident grouping](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/incidents.py): `incidents.py`
- [Ground-truth evaluation](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/incidents.py): `incidents.py`

### CLI and outputs

- [Detection runner](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/cli.py): `cli.py`
- [Markdown and chart](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/report.py): `report.py`
- **Reports and CSVs**

### Synthetic data

- [Attack-data generator](https://github.com/vishnugovindu23-cmd/cloud-anomaly-detection/blob/main/generate.py): `generate.py`
- **Synthetic logs and labels**

### Other components

- **Operator**
- **CloudTrail logs**
- **VPC Flow Logs**

## Connections

- Operator → Detection runner: runs (evidence: `README.md`)
- CloudTrail logs → CloudTrail parser: parsed by (evidence: `loaders.py`)
- VPC Flow Logs → Flow log parser: parsed by (evidence: `loaders.py`)
- Detection runner → CloudTrail parser: loads (evidence: `cli.py`)
- Detection runner → Flow log parser: loads (evidence: `cli.py`)
- Detection runner → Identity-hour features: builds features (evidence: `cli.py`)
- Detection runner → Host-hour features: builds features (evidence: `cli.py`)
- Detection runner → CloudTrail detector: fits and scores (evidence: `cli.py`)
- Detection runner → Flow detector: fits and scores (evidence: `cli.py`)
- Identity-hour features → CloudTrail detector: feature data (evidence: `cli.py`)
- Host-hour features → Flow detector: feature data (evidence: `cli.py`)
- CloudTrail detector → Hourly alerts: produces (evidence: `model.py`)
- Flow detector → Hourly alerts: produces (evidence: `model.py`)
- CloudTrail detector → ATT&CK mapping: maps reasons (evidence: `model.py`)
- Flow detector → ATT&CK mapping: maps reasons (evidence: `model.py`)
- Detection runner → Incident grouping: groups alerts (evidence: `cli.py`)
- Hourly alerts → Incident grouping: grouped into (evidence: `cli.py`)
- Detection runner → Beacon detector: detects beacons (evidence: `cli.py`)
- Flow log parser → Beacon detector: flow records (evidence: `cli.py`)
- Detection runner → Ground-truth evaluation: evaluates results (evidence: `cli.py`)
- Incident grouping → Ground-truth evaluation: incident results (evidence: `incidents.py`)
- Beacon detector → Ground-truth evaluation: beacon results (evidence: `incidents.py`)
- Detection runner → Markdown and chart: renders outputs (evidence: `cli.py`)
- Incident grouping → Markdown and chart: incident data
- Beacon detector → Markdown and chart: beacon data
- Markdown and chart → Reports and CSVs: writes report and chart
- Operator → Attack-data generator: generates demo data (evidence: `README.md`)
- Attack-data generator → Synthetic logs and labels: creates logs and labels (evidence: `generate.py`)
- Synthetic logs and labels → Detection runner: demo input (evidence: `cli.py`)
