# abraham08-wq/xai-amlbench architecture

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

- Interactive diagram: https://gitdiagram.com/abraham08-wq/xai-amlbench
- Repository: https://github.com/abraham08-wq/xai-amlbench

## Overview

XAI-AMLBench combines a reproducible AML benchmark with a compliance-officer console. Its principal workflow generates synthetic transaction graphs, engineers account features, trains and evaluates graph detectors, serves account scores and explanations, then turns explanation evidence into validated SAR narratives. The repository also includes live-graph ingestion and calibration components, plus a web console and gateway. Relationships below follow explicit README descriptions and indexed imports; unsampled subsystem wiring is omitted where it cannot be verified.

Main entry points: [`gnn_aml_core/main.py`](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/main.py) (Scoring and explain API), [`gnn_aml_core/train.py`](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/train.py) (GNN training), [`xai_explainer/main.py`](https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/main.py) (Narrative API), [`gnn_aml_core/features.py`](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/features.py) (Feature engineering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Graph data"]
  node_generator["Synthetic graph generator<br/>[graph_generator.py]"]
  node_exporters["Graph exporters<br/>[exporters.py]"]
  node_features["Feature engineering<br/>[features.py]"]
  node_livegraph["Live graph<br/>[livegraph.py]"]
  node_kafka["Kafka ingestion<br/>[kafka_ingest.py]"]
end

subgraph group_models["Detection models"]
  node_trainer["GNN training<br/>[train.py]"]
  node_models_impl["GATv2 and RGCN<br/>[models.py]"]
  node_baselines["Baseline detectors<br/>[baselines.py]"]
  node_evaluation["Model evaluation<br/>[evaluation.py]"]
  node_calibration["Score calibration<br/>[calibration.py]"]
  node_scoring_api["Scoring and explain API<br/>[main.py]"]
end

subgraph group_explain["Explanation and audit"]
  node_extractor["Explanation extractor<br/>[extractor.py]"]
  node_narrative_api["Narrative API<br/>[main.py]"]
  node_sar["SAR fact and narrative builder<br/>[sar_generator.py]"]
  node_audit[("Audit log<br/>[audit_log.py]")]
end

subgraph group_app["Analyst application"]
  node_frontend["Analyst console<br/>[page.tsx]"]
  node_gateway["Application gateway<br/>[main.py]"]
end

node_analyst(("Compliance analyst"))

node_analyst -->|"uses console"| node_frontend
node_frontend -->|"requests services"| node_gateway
node_generator -->|"exports graphs"| node_exporters
node_generator -->|"supplies graph data"| node_features
node_features -->|"builds training inputs"| node_trainer
node_trainer -->|"trains detectors"| node_models_impl
node_trainer -->|"compares against"| node_baselines
node_trainer -->|"evaluates results"| node_evaluation
node_trainer -->|"calibrates scores"| node_calibration
node_features -->|"builds graph features"| node_livegraph
node_kafka -.->|"ingests transactions"| node_livegraph
node_scoring_api -->|"runs inference"| node_models_impl
node_scoring_api -->|"uses graph features"| node_features
node_scoring_api -->|"calibrates scores"| node_calibration
node_narrative_api -->|"requests explanations"| node_scoring_api
node_narrative_api -->|"builds validated narrative"| node_sar
node_narrative_api -.->|"records audit evidence"| node_audit
node_gateway -.->|"routes scoring"| node_scoring_api
node_gateway -.->|"routes narratives"| node_narrative_api
node_frontend -->|"requests explanations"| node_scoring_api

click node_generator "https://github.com/abraham08-wq/xai-amlbench/blob/main/aml_synth/graph_generator.py"
click node_exporters "https://github.com/abraham08-wq/xai-amlbench/blob/main/aml_synth/exporters.py"
click node_features "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/features.py"
click node_livegraph "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/livegraph.py"
click node_kafka "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/kafka_ingest.py"
click node_trainer "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/train.py"
click node_models_impl "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/models.py"
click node_baselines "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/baselines.py"
click node_evaluation "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/evaluation.py"
click node_calibration "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/calibration.py"
click node_scoring_api "https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/main.py"
click node_extractor "https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/extractor.py"
click node_narrative_api "https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/main.py"
click node_sar "https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/sar_generator.py"
click node_audit "https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/audit_log.py"
click node_frontend "https://github.com/abraham08-wq/xai-amlbench/blob/main/frontend/src/app/page.tsx"
click node_gateway "https://github.com/abraham08-wq/xai-amlbench/blob/main/backend/main.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_generator,node_exporters,node_features,node_livegraph,node_kafka toneBlue
class node_trainer,node_models_impl,node_baselines,node_evaluation,node_calibration,node_scoring_api toneAmber
class node_extractor,node_narrative_api,node_sar,node_audit toneMint
class node_frontend,node_gateway toneRose
class node_analyst toneIndigo
```

## Components

### Graph data

- [Synthetic graph generator](https://github.com/abraham08-wq/xai-amlbench/blob/main/aml_synth/graph_generator.py): `aml_synth/graph_generator.py`
- [Graph exporters](https://github.com/abraham08-wq/xai-amlbench/blob/main/aml_synth/exporters.py): `aml_synth/exporters.py`
- [Feature engineering](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/features.py): `gnn_aml_core/features.py`
- [Live graph](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/livegraph.py): `gnn_aml_core/livegraph.py`
- [Kafka ingestion](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/kafka_ingest.py): `gnn_aml_core/kafka_ingest.py`

### Detection models

- [GNN training](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/train.py): `gnn_aml_core/train.py`
- [GATv2 and RGCN](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/models.py): `gnn_aml_core/models.py`
- [Baseline detectors](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/baselines.py): `gnn_aml_core/baselines.py`
- [Model evaluation](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/evaluation.py): `gnn_aml_core/evaluation.py`
- [Score calibration](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/calibration.py): `gnn_aml_core/calibration.py`
- [Scoring and explain API](https://github.com/abraham08-wq/xai-amlbench/blob/main/gnn_aml_core/main.py): `gnn_aml_core/main.py`

### Explanation and audit

- [Explanation extractor](https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/extractor.py): `xai_explainer/extractor.py`
- [Narrative API](https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/main.py): `xai_explainer/main.py`
- [SAR fact and narrative builder](https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/sar_generator.py): `xai_explainer/sar_generator.py`
- [Audit log](https://github.com/abraham08-wq/xai-amlbench/blob/main/xai_explainer/audit_log.py): `xai_explainer/audit_log.py`

### Analyst application

- [Analyst console](https://github.com/abraham08-wq/xai-amlbench/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Application gateway](https://github.com/abraham08-wq/xai-amlbench/blob/main/backend/main.py): `backend/main.py`

### Other components

- **Compliance analyst**

## Connections

- Compliance analyst → Analyst console: uses console (evidence: `README.md`)
- Analyst console → Application gateway: requests services (evidence: `README.md`)
- Synthetic graph generator → Graph exporters: exports graphs (evidence: `aml_synth/graph_generator.py`)
- Synthetic graph generator → Feature engineering: supplies graph data (evidence: `README.md`)
- Feature engineering → GNN training: builds training inputs (evidence: `gnn_aml_core/train.py`)
- GNN training → GATv2 and RGCN: trains detectors (evidence: `gnn_aml_core/train.py`)
- GNN training → Baseline detectors: compares against (evidence: `gnn_aml_core/train.py`)
- GNN training → Model evaluation: evaluates results (evidence: `gnn_aml_core/train.py`)
- GNN training → Score calibration: calibrates scores (evidence: `gnn_aml_core/train.py`)
- Feature engineering → Live graph: builds graph features (evidence: `gnn_aml_core/livegraph.py`)
- Kafka ingestion → Live graph: ingests transactions
- Scoring and explain API → GATv2 and RGCN: runs inference (evidence: `gnn_aml_core/main.py`)
- Scoring and explain API → Feature engineering: uses graph features (evidence: `gnn_aml_core/main.py`)
- Scoring and explain API → Score calibration: calibrates scores (evidence: `gnn_aml_core/main.py`)
- Narrative API → Scoring and explain API: requests explanations (evidence: `xai_explainer/main.py`)
- Narrative API → SAR fact and narrative builder: builds validated narrative (evidence: `xai_explainer/main.py`)
- Narrative API → Audit log: records audit evidence
- Application gateway → Scoring and explain API: routes scoring (evidence: `README.md`)
- Application gateway → Narrative API: routes narratives (evidence: `README.md`)
- Analyst console → Scoring and explain API: requests explanations (evidence: `frontend/src/app/page.tsx`)
