# manoharnaidu/flag-reproduce architecture

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

- Interactive diagram: https://gitdiagram.com/manoharnaidu/flag-reproduce
- Repository: https://github.com/manoharnaidu/flag-reproduce

## Overview

FLAG Reproduction Benchmark is a research benchmark for fraud-detection GNNs, comparing FLAG variants and seven baselines under shared datasets, splits, metrics, and seeds. Its main workflow prepares graph/subgraph and text features, runs configured experiments, then records results for analysis. The graph includes dataset ingestion, semantic and Markov-diffusion sampling, GPU-only LLM enhancement, model/training/evaluation layers, and text-augmented dataset support. Several edges reflect imports or calls listed in the SOURCE INDEX; unsampled subsystems and reporting links are not connected speculatively.

Main entry points: [`src/flagbench/experiments/runner.py`](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/experiments/runner.py) (Experiment runner), [`src/flagbench/sampling/cli.py`](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/cli.py) (Sampling configuration), [`scripts/train/run.py`](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/train/run.py) (Training entrypoint), [`scripts/llm/generate_text.py`](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/llm/generate_text.py) (LLM text generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_glbench["GLBench datasets<br/>[glbench.py]"]
  node_download["Dataset download<br/>[glbench.py]"]
  node_subgraphs["Subgraph preparation"]
  node_fraud_schema["Fraud dataset schema<br/>[base.py]"]
  node_amazon_data["Amazon text data<br/>[amazon.py]"]
  node_yelp_data["YelpChi text data<br/>[yelpchi.py]"]
  node_amazon_video["Amazon Video graph"]
end

subgraph group_features["Text and sampling"]
  node_sampler_config["Sampling configuration<br/>[cli.py]"]
  node_semantic["Semantic sampling<br/>[semantic.py]"]
  node_diffusion["Markov diffusion"]
  node_llm_generate["LLM text generation<br/>[generate_text.py]"]
  node_llm_enhance["LLM enhancement<br/>[enhance.py]"]
  node_llm_encode["LLM encoding<br/>[encode_llm_text.py]"]
end

subgraph group_runtime["Experiment runtime"]
  node_registry["Experiment registry<br/>[registry.py]"]
  node_backbone["GNN backbones<br/>[backbone.py]"]
  node_trainer["Model training<br/>[trainer.py]"]
  node_runner["Experiment runner<br/>[runner.py]"]
  node_train_cli["Training entrypoint<br/>[run.py]"]
  node_device["Device selection<br/>[device.py]"]
end

subgraph group_analysis["Results and extensions"]
  node_metrics["Classification metrics<br/>[classification.py]"]
  node_results["Result records<br/>[results.py]"]
  node_main_report["Run reporting"]
end

node_researcher(("Benchmark user"))

node_researcher -.->|"prepares data"| node_download
node_download -->|"downloads dataset"| node_glbench
node_glbench -.->|"provides graph"| node_subgraphs
node_researcher -.->|"prepares benchmark"| node_subgraphs
node_subgraphs -->|"configures sampling"| node_sampler_config
node_sampler_config -->|"builds sampler"| node_semantic
node_sampler_config -->|"selects strategy"| node_diffusion
node_diffusion -->|"reuses selection"| node_semantic
node_researcher -.->|"requests text"| node_llm_generate
node_llm_generate -->|"generates text"| node_llm_enhance
node_llm_generate -->|"uses config"| node_sampler_config
node_llm_encode -->|"uses enhancement"| node_llm_enhance
node_llm_encode -->|"shares config"| node_sampler_config
node_amazon_data -->|"uses schema"| node_fraud_schema
node_yelp_data -.->|"uses schema"| node_fraud_schema
node_amazon_video -->|"uses dataset logic"| node_amazon_data
node_researcher -.->|"runs experiments"| node_train_cli
node_train_cli -->|"runs experiment"| node_runner
node_train_cli -->|"validates choices"| node_registry
node_train_cli -->|"uses trainer"| node_trainer
node_train_cli -->|"configures sampling"| node_sampler_config
node_runner -->|"resolves models"| node_registry
node_runner -->|"builds backbone"| node_backbone
node_runner -->|"trains model"| node_trainer
node_runner -->|"evaluates predictions"| node_metrics
node_runner -->|"saves results"| node_results
node_runner -->|"selects device"| node_device
node_results -->|"summarizes metrics"| node_metrics
node_researcher -.->|"reviews findings"| node_main_report

click node_glbench "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/datasets/glbench.py"
click node_download "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/download/glbench.py"
click node_subgraphs "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/preprocess/sample_subgraphs.py"
click node_fraud_schema "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/base.py"
click node_amazon_data "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/amazon.py"
click node_yelp_data "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/yelpchi.py"
click node_sampler_config "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/cli.py"
click node_semantic "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/semantic.py"
click node_diffusion "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/markov_diffusion.py"
click node_llm_generate "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/llm/generate_text.py"
click node_llm_enhance "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/llm/enhance.py"
click node_llm_encode "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/preprocess/encode_llm_text.py"
click node_registry "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/registry/registry.py"
click node_backbone "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/adapters/backbone.py"
click node_trainer "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/training/trainer.py"
click node_runner "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/experiments/runner.py"
click node_train_cli "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/train/run.py"
click node_device "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/utils/device.py"
click node_metrics "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/metrics/classification.py"
click node_results "https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/experiments/results.py"
click node_main_report "https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/analyze/build_main_run_report.py"
click node_amazon_video "https://github.com/manoharnaidu/flag-reproduce/blob/master/experiments/amazon_video/build_amazon_video.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_glbench,node_download,node_subgraphs,node_fraud_schema,node_amazon_data,node_yelp_data,node_amazon_video,node_researcher toneBlue
class node_sampler_config,node_semantic,node_diffusion,node_llm_generate,node_llm_enhance,node_llm_encode toneAmber
class node_registry,node_backbone,node_trainer,node_runner,node_train_cli,node_device toneMint
class node_metrics,node_results,node_main_report toneRose
```

## Components

### Data preparation

- [GLBench datasets](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/datasets/glbench.py): `src/flagbench/datasets/glbench.py`
- [Dataset download](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/download/glbench.py): `scripts/download/glbench.py`
- [Subgraph preparation](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/preprocess/sample_subgraphs.py): `scripts/preprocess/sample_subgraphs.py`
- [Fraud dataset schema](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/base.py): `src/flagbench/fraud_text/base.py`
- [Amazon text data](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/amazon.py): `src/flagbench/fraud_text/amazon.py`
- [YelpChi text data](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/fraud_text/yelpchi.py): `src/flagbench/fraud_text/yelpchi.py`
- [Amazon Video graph](https://github.com/manoharnaidu/flag-reproduce/blob/master/experiments/amazon_video/build_amazon_video.py): `experiments/amazon_video/build_amazon_video.py`

### Text and sampling

- [Sampling configuration](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/cli.py): `src/flagbench/sampling/cli.py`
- [Semantic sampling](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/semantic.py): `src/flagbench/sampling/semantic.py`
- [Markov diffusion](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/sampling/markov_diffusion.py): `src/flagbench/sampling/markov_diffusion.py`
- [LLM text generation](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/llm/generate_text.py): `scripts/llm/generate_text.py`
- [LLM enhancement](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/llm/enhance.py): `src/flagbench/llm/enhance.py`
- [LLM encoding](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/preprocess/encode_llm_text.py): `scripts/preprocess/encode_llm_text.py`

### Experiment runtime

- [Experiment registry](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/registry/registry.py): `src/flagbench/registry/registry.py`
- [GNN backbones](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/adapters/backbone.py): `src/flagbench/adapters/backbone.py`
- [Model training](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/training/trainer.py): `src/flagbench/training/trainer.py`
- [Experiment runner](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/experiments/runner.py): `src/flagbench/experiments/runner.py`
- [Training entrypoint](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/train/run.py): `scripts/train/run.py`
- [Device selection](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/utils/device.py): `src/flagbench/utils/device.py`

### Results and extensions

- [Classification metrics](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/metrics/classification.py): `src/flagbench/metrics/classification.py`
- [Result records](https://github.com/manoharnaidu/flag-reproduce/blob/master/src/flagbench/experiments/results.py): `src/flagbench/experiments/results.py`
- [Run reporting](https://github.com/manoharnaidu/flag-reproduce/blob/master/scripts/analyze/build_main_run_report.py): `scripts/analyze/build_main_run_report.py`

### Other components

- **Benchmark user**

## Connections

- Benchmark user → Dataset download: prepares data (evidence: `README.md`)
- Dataset download → GLBench datasets: downloads dataset (evidence: `scripts/download/glbench.py`)
- GLBench datasets → Subgraph preparation: provides graph (evidence: `scripts/preprocess/sample_subgraphs.py`)
- Benchmark user → Subgraph preparation: prepares benchmark (evidence: `README.md`)
- Subgraph preparation → Sampling configuration: configures sampling (evidence: `scripts/preprocess/sample_subgraphs.py`)
- Sampling configuration → Semantic sampling: builds sampler (evidence: `src/flagbench/sampling/cli.py`)
- Sampling configuration → Markov diffusion: selects strategy (evidence: `src/flagbench/sampling/cli.py`)
- Markov diffusion → Semantic sampling: reuses selection (evidence: `src/flagbench/sampling/markov_diffusion.py`)
- Benchmark user → LLM text generation: requests text (evidence: `README.md`)
- LLM text generation → LLM enhancement: generates text (evidence: `scripts/llm/generate_text.py`)
- LLM text generation → Sampling configuration: uses config (evidence: `scripts/llm/generate_text.py`)
- LLM encoding → LLM enhancement: uses enhancement (evidence: `scripts/preprocess/encode_llm_text.py`)
- LLM encoding → Sampling configuration: shares config (evidence: `scripts/preprocess/encode_llm_text.py`)
- Amazon text data → Fraud dataset schema: uses schema (evidence: `src/flagbench/fraud_text/amazon.py`)
- YelpChi text data → Fraud dataset schema: uses schema
- Amazon Video graph → Amazon text data: uses dataset logic (evidence: `experiments/amazon_video/build_amazon_video.py`)
- Benchmark user → Training entrypoint: runs experiments (evidence: `README.md`)
- Training entrypoint → Experiment runner: runs experiment (evidence: `scripts/train/run.py`)
- Training entrypoint → Experiment registry: validates choices (evidence: `scripts/train/run.py`)
- Training entrypoint → Model training: uses trainer (evidence: `scripts/train/run.py`)
- Training entrypoint → Sampling configuration: configures sampling (evidence: `scripts/train/run.py`)
- Experiment runner → Experiment registry: resolves models (evidence: `src/flagbench/experiments/runner.py`)
- Experiment runner → GNN backbones: builds backbone (evidence: `src/flagbench/experiments/runner.py`)
- Experiment runner → Model training: trains model (evidence: `src/flagbench/experiments/runner.py`)
- Experiment runner → Classification metrics: evaluates predictions (evidence: `src/flagbench/experiments/runner.py`)
- Experiment runner → Result records: saves results (evidence: `src/flagbench/experiments/runner.py`)
- Experiment runner → Device selection: selects device (evidence: `src/flagbench/experiments/runner.py`)
- Result records → Classification metrics: summarizes metrics (evidence: `src/flagbench/experiments/results.py`)
- Benchmark user → Run reporting: reviews findings (evidence: `README.md`)
