# pranavi0525/ai_defence_sys architecture

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

- Interactive diagram: https://gitdiagram.com/pranavi0525/ai_defence_sys
- Repository: https://github.com/pranavi0525/ai_defence_sys

## Overview

AI Defence System combines synthetic payment-attack generation with a layered fraud-risk workflow: observable traces feed behavioral and calibrated tabular scoring, optional graph and novelty signals, risk fusion, operational decisions, and explanations. Miss analysis and adaptive retraining support evaluation and iteration; a FastAPI service exposes scoring, reports, and pipeline jobs. The README documents several capabilities whose implementation was not sampled, so those branches are shown at the documented subsystem level; edges are limited to documented or indexed relationships.

Main entry points: [`decision_policy.py`](https://github.com/pranavi0525/ai_defence_sys/blob/main/decision_policy.py) (Decision Policy), [`blue_team_pipeline.py`](https://github.com/pranavi0525/ai_defence_sys/blob/main/blue_team_pipeline.py) (Behavioral + XGBoost), [`src/red_team/attacks/signature_library.py`](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/attacks/signature_library.py) (Attack Scenarios), [`src/red_team/world/state.py`](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/world/state.py) (Payment World)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Red Team Simulation"]
  node_world["Payment World<br/>[state.py]"]
  node_attack["Attack Scenarios"]
  node_mule["Mule Orchestration"]
end

subgraph group_data["Trace Data"]
  node_schemas["Payment Schemas<br/>[entities.py]"]
  node_event["Event Stream<br/>[events.py]"]
  node_observable["Observable Traces<br/>[observable.py]"]
  node_groundtruth["Ground Truth<br/>[ground_truth.py]"]
  node_preprocess["Trace Preparation<br/>[preprocessing.py]"]
  node_registry[("Model Registry<br/>[registry.py]")]
end

subgraph group_detection["Risk Detection"]
  node_blue["Behavioral + XGBoost"]
  node_graphcascade["Graph Escalation"]
  node_gcn["Graph Detector<br/>[gcn.py]"]
  node_autoencoder["Novelty Detection<br/>[autoencoder.py]"]
  node_fusion["Risk Fusion<br/>[risk_fusion.py]"]
  node_metadata["Artifact Metadata"]
end

subgraph group_operations["Decision Operations"]
  node_policy["Decision Policy<br/>[decision_policy.py]"]
  node_explain["Explanations<br/>[explainability.py]"]
  node_misses[("Miss Collection<br/>[miss_collector.py]")]
  node_hard["Hard Examples"]
  node_feedback["Adaptive Retraining"]
  node_evaluation["Evaluation"]
end

subgraph group_service["API Service"]
  node_api["HTTP API<br/>[app.py]"]
  node_inference["Online Inference<br/>[inference.py]"]
  node_runner["Pipeline Jobs<br/>[pipeline_runner.py]"]
  node_reports["Reports<br/>[reports.py]"]
end

node_actor(("Risk Operator"))

node_world -->|"uses entities"| node_schemas
node_world -->|"records events"| node_event
node_attack -->|"simulates in"| node_world
node_attack -->|"emits events"| node_event
node_attack -->|"produces traces"| node_observable
node_attack -->|"records labels"| node_groundtruth
node_mule -->|"uses state"| node_world
node_mule -->|"dispatches"| node_attack
node_mule -->|"produces traces"| node_observable
node_event -->|"embeds entities"| node_schemas
node_observable -->|"converts events"| node_event
node_preprocess -->|"uses population"| node_registry
node_blue -->|"consumes traces"| node_observable
node_blue -->|"loads corpus"| node_world
node_graphcascade -->|"extends cascade"| node_blue
node_graphcascade -->|"uses detector"| node_gcn
node_fusion -->|"combines score"| node_blue
node_fusion -->|"combines signal"| node_gcn
node_fusion -->|"combines signal"| node_autoencoder
node_policy -->|"loads cascade"| node_graphcascade
node_policy -->|"uses fused score"| node_fusion
node_policy -->|"reads provenance"| node_metadata
node_evaluation -->|"evaluates"| node_blue
node_evaluation -->|"evaluates"| node_graphcascade
node_evaluation -->|"evaluates"| node_policy
node_api -->|"routes scoring"| node_inference
node_api -->|"serves reports"| node_reports
node_api -->|"starts jobs"| node_runner
node_inference -->|"loads pipeline"| node_blue
node_runner -->|"runs stages"| node_blue
node_runner -->|"runs stages"| node_graphcascade
node_actor -.->|"requests scoring"| node_api
node_policy -.->|"explained by"| node_explain
node_policy -.->|"misses collected"| node_misses
node_misses -.->|"guides analysis"| node_hard
node_hard -.->|"informs retraining"| node_feedback
node_feedback -.->|"reevaluated by"| node_evaluation
node_policy -.->|"returns action"| node_actor

click node_world "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/world/state.py"
click node_attack "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/attacks/signature_library.py"
click node_mule "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/attacks/mule_network_orchestrator.py"
click node_schemas "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/entities.py"
click node_event "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/events.py"
click node_observable "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/observable.py"
click node_groundtruth "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/ground_truth.py"
click node_preprocess "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/data/preprocessing.py"
click node_registry "https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/registry/registry.py"
click node_blue "https://github.com/pranavi0525/ai_defence_sys/blob/main/blue_team_pipeline.py"
click node_graphcascade "https://github.com/pranavi0525/ai_defence_sys/blob/main/cascade_with_graph.py"
click node_gcn "https://github.com/pranavi0525/ai_defence_sys/blob/main/gcn.py"
click node_autoencoder "https://github.com/pranavi0525/ai_defence_sys/blob/main/autoencoder.py"
click node_fusion "https://github.com/pranavi0525/ai_defence_sys/blob/main/risk_fusion.py"
click node_metadata "https://github.com/pranavi0525/ai_defence_sys/blob/main/artifact_metadata.py"
click node_policy "https://github.com/pranavi0525/ai_defence_sys/blob/main/decision_policy.py"
click node_explain "https://github.com/pranavi0525/ai_defence_sys/blob/main/explainability.py"
click node_misses "https://github.com/pranavi0525/ai_defence_sys/blob/main/miss_collector.py"
click node_hard "https://github.com/pranavi0525/ai_defence_sys/blob/main/hard_example_generator.py"
click node_feedback "https://github.com/pranavi0525/ai_defence_sys/blob/main/adaptive_feedback_loop.py"
click node_evaluation "https://github.com/pranavi0525/ai_defence_sys/blob/main/evaluation_harness.py"
click node_api "https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/app.py"
click node_inference "https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/inference.py"
click node_runner "https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/pipeline_runner.py"
click node_reports "https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/reports.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_world,node_attack,node_mule toneBlue
class node_schemas,node_event,node_observable,node_groundtruth,node_preprocess,node_registry toneAmber
class node_blue,node_graphcascade,node_gcn,node_autoencoder,node_fusion,node_metadata toneMint
class node_policy,node_explain,node_misses,node_hard,node_feedback,node_evaluation toneRose
class node_api,node_inference,node_runner,node_reports,node_actor toneIndigo
```

## Components

### Red Team Simulation

- [Payment World](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/world/state.py): `src/red_team/world/state.py`
- [Attack Scenarios](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/attacks/signature_library.py): `src/red_team/attacks/signature_library.py`
- [Mule Orchestration](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/attacks/mule_network_orchestrator.py): `src/red_team/attacks/mule_network_orchestrator.py`

### Trace Data

- [Payment Schemas](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/entities.py): `src/red_team/schemas/entities.py`
- [Event Stream](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/events.py): `src/red_team/schemas/events.py`
- [Observable Traces](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/observable.py): `src/red_team/schemas/observable.py`
- [Ground Truth](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/schemas/ground_truth.py): `src/red_team/schemas/ground_truth.py`
- [Trace Preparation](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/data/preprocessing.py): `src/red_team/data/preprocessing.py`
- [Model Registry](https://github.com/pranavi0525/ai_defence_sys/blob/main/src/red_team/registry/registry.py): `src/red_team/registry/registry.py`

### Risk Detection

- [Behavioral + XGBoost](https://github.com/pranavi0525/ai_defence_sys/blob/main/blue_team_pipeline.py): `blue_team_pipeline.py`
- [Graph Escalation](https://github.com/pranavi0525/ai_defence_sys/blob/main/cascade_with_graph.py): `cascade_with_graph.py`
- [Graph Detector](https://github.com/pranavi0525/ai_defence_sys/blob/main/gcn.py): `gcn.py`
- [Novelty Detection](https://github.com/pranavi0525/ai_defence_sys/blob/main/autoencoder.py): `autoencoder.py`
- [Risk Fusion](https://github.com/pranavi0525/ai_defence_sys/blob/main/risk_fusion.py): `risk_fusion.py`
- [Artifact Metadata](https://github.com/pranavi0525/ai_defence_sys/blob/main/artifact_metadata.py): `artifact_metadata.py`

### Decision Operations

- [Decision Policy](https://github.com/pranavi0525/ai_defence_sys/blob/main/decision_policy.py): `decision_policy.py`
- [Explanations](https://github.com/pranavi0525/ai_defence_sys/blob/main/explainability.py): `explainability.py`
- [Miss Collection](https://github.com/pranavi0525/ai_defence_sys/blob/main/miss_collector.py): `miss_collector.py`
- [Hard Examples](https://github.com/pranavi0525/ai_defence_sys/blob/main/hard_example_generator.py): `hard_example_generator.py`
- [Adaptive Retraining](https://github.com/pranavi0525/ai_defence_sys/blob/main/adaptive_feedback_loop.py): `adaptive_feedback_loop.py`
- [Evaluation](https://github.com/pranavi0525/ai_defence_sys/blob/main/evaluation_harness.py): `evaluation_harness.py`

### API Service

- [HTTP API](https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/app.py): `web_prototype/api/app.py`
- [Online Inference](https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/inference.py): `web_prototype/api/inference.py`
- [Pipeline Jobs](https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/pipeline_runner.py): `web_prototype/api/pipeline_runner.py`
- [Reports](https://github.com/pranavi0525/ai_defence_sys/blob/main/web_prototype/api/reports.py): `web_prototype/api/reports.py`

### Other components

- **Risk Operator**

## Connections

- Payment World → Payment Schemas: uses entities (evidence: `src/red_team/world/state.py`)
- Payment World → Event Stream: records events (evidence: `src/red_team/world/state.py`)
- Attack Scenarios → Payment World: simulates in (evidence: `src/red_team/attacks/simulator.py`)
- Attack Scenarios → Event Stream: emits events (evidence: `src/red_team/attacks/simulator.py`)
- Attack Scenarios → Observable Traces: produces traces (evidence: `src/red_team/attacks/simulator.py`)
- Attack Scenarios → Ground Truth: records labels (evidence: `src/red_team/attacks/simulator.py`)
- Mule Orchestration → Payment World: uses state (evidence: `src/red_team/attacks/mule_network_orchestrator.py`)
- Mule Orchestration → Attack Scenarios: dispatches (evidence: `src/red_team/attacks/mule_network_orchestrator.py`)
- Mule Orchestration → Observable Traces: produces traces (evidence: `src/red_team/attacks/mule_network_orchestrator.py`)
- Event Stream → Payment Schemas: embeds entities (evidence: `src/red_team/schemas/events.py`)
- Observable Traces → Event Stream: converts events (evidence: `src/red_team/schemas/observable.py`)
- Trace Preparation → Model Registry: uses population (evidence: `src/red_team/data/preprocessing.py`)
- Behavioral + XGBoost → Observable Traces: consumes traces (evidence: `blue_team_pipeline.py`)
- Behavioral + XGBoost → Payment World: loads corpus (evidence: `blue_team_pipeline.py`)
- Graph Escalation → Behavioral + XGBoost: extends cascade (evidence: `cascade_with_graph.py`)
- Graph Escalation → Graph Detector: uses detector (evidence: `cascade_with_graph.py`)
- Risk Fusion → Behavioral + XGBoost: combines score (evidence: `risk_fusion.py`)
- Risk Fusion → Graph Detector: combines signal (evidence: `risk_fusion.py`)
- Risk Fusion → Novelty Detection: combines signal (evidence: `risk_fusion.py`)
- Decision Policy → Graph Escalation: loads cascade (evidence: `decision_policy.py`)
- Decision Policy → Risk Fusion: uses fused score (evidence: `decision_policy.py`)
- Decision Policy → Artifact Metadata: reads provenance (evidence: `decision_policy.py`)
- Evaluation → Behavioral + XGBoost: evaluates (evidence: `evaluation_harness.py`)
- Evaluation → Graph Escalation: evaluates (evidence: `evaluation_harness.py`)
- Evaluation → Decision Policy: evaluates (evidence: `evaluation_harness.py`)
- HTTP API → Online Inference: routes scoring (evidence: `web_prototype/api/app.py`)
- HTTP API → Reports: serves reports (evidence: `web_prototype/api/app.py`)
- HTTP API → Pipeline Jobs: starts jobs (evidence: `web_prototype/api/app.py`)
- Online Inference → Behavioral + XGBoost: loads pipeline (evidence: `web_prototype/api/inference.py`)
- Pipeline Jobs → Behavioral + XGBoost: runs stages (evidence: `web_prototype/api/pipeline_runner.py`)
- Pipeline Jobs → Graph Escalation: runs stages (evidence: `web_prototype/api/pipeline_runner.py`)
- Risk Operator → HTTP API: requests scoring
- Decision Policy → Explanations: explained by
- Decision Policy → Miss Collection: misses collected
- Miss Collection → Hard Examples: guides analysis
- Hard Examples → Adaptive Retraining: informs retraining
- Adaptive Retraining → Evaluation: reevaluated by
- Decision Policy → Risk Operator: returns action
