# maher121/phd-blockchain-ai architecture

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

- Interactive diagram: https://gitdiagram.com/maher121/phd-blockchain-ai
- Repository: https://github.com/maher121/phd-blockchain-ai

## Overview

This is a research prototype for supply-chain anomaly detection, security evaluation, and blockchain integrity—not a production ledger service. The documented workflow begins with DataCo discovery and leakage-safe preparation, then supports anomaly modeling and controlled attack evaluation; later source-indexed modules add feature optimization, resource measurement, and order-chain construction/validation. The README excerpt documents V0.1–V0.4, while the source index shows later experimental stages. Some subsystem links are therefore documented capabilities rather than a single verified end-to-end runtime path.

Main entry points: [`src/pipeline_v02.py`](https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v02.py) (Data pipeline runner), [`src/pipeline_v06g.py`](https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v06g.py) (Robustness runner), [`src/security/ground_truth.py`](https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/ground_truth.py) (Attack ground truth), [`src/lightweight/models.py`](https://github.com/maher121/phd-blockchain-ai/blob/main/src/lightweight/models.py) (Anomaly models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset_discovery["Dataset discovery"]
  node_data_audit["Data audit<br/>[audit.py]"]
  node_dataco_pipeline["DataCo preprocessing<br/>[dataco_pipeline.py]"]
  node_feature_engineering["Feature engineering"]
  node_pipeline_v02["Data pipeline runner<br/>[pipeline_v02.py]"]
end

subgraph group_security_ai["Security and AI"]
  node_attack_data["Attack generation<br/>[experiment_data.py]"]
  node_ground_truth["Attack ground truth<br/>[ground_truth.py]"]
  node_anomaly_models["Anomaly models<br/>[models.py]"]
  node_ai_evaluation["Security evaluation<br/>[evaluation.py]"]
  node_baseline_evaluation["AI evaluation<br/>[evaluation.py]"]
end

subgraph group_research["Research experiments"]
  node_experiment_runner["Robustness runner<br/>[pipeline_v06g.py]"]
  node_feature_selection["Feature selection<br/>[methods.py]"]
  node_optimization["BPSO optimization<br/>[bpso.py]"]
  node_final_test["Final-test evaluation<br/>[pipeline_v10e.py]"]
end

subgraph group_ledger["Blockchain ledger"]
  node_order_mapping["Order-chain mapping<br/>[chain_builder.py]"]
  node_order_chain["Order chain<br/>[order_chain.py]"]
  node_block_validation["Block validation<br/>[validation.py]"]
end

subgraph group_resources["Resource analysis"]
  node_resource_measurement["Resource measurement<br/>[measurement.py]"]
  node_energy_estimation["Energy estimation<br/>[estimation.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs"| node_pipeline_v02
node_pipeline_v02 -->|"discovers data"| node_dataset_discovery
node_pipeline_v02 -->|"audits data"| node_data_audit
node_pipeline_v02 -->|"preprocesses splits"| node_dataco_pipeline
node_dataco_pipeline -->|"engineers features"| node_feature_engineering
node_experiment_runner -->|"prepares attacks"| node_attack_data
node_attack_data -->|"builds labels"| node_ground_truth
node_experiment_runner -->|"uses models"| node_anomaly_models
node_experiment_runner -->|"evaluates robustness"| node_ai_evaluation
node_ai_evaluation -->|"scores against"| node_ground_truth
node_baseline_evaluation -->|"uses detector"| node_anomaly_models
node_baseline_evaluation -->|"references labels"| node_ground_truth
node_optimization -->|"uses fitness"| node_feature_selection
node_final_test -->|"evaluates classifiers"| node_anomaly_models
node_order_mapping -->|"builds chains"| node_order_chain
node_order_mapping -->|"validates chain"| node_block_validation
node_resource_measurement -.->|"separates estimation"| node_energy_estimation

click node_dataset_discovery "https://github.com/maher121/phd-blockchain-ai/blob/main/src/data/dataset_discovery.py"
click node_data_audit "https://github.com/maher121/phd-blockchain-ai/blob/main/src/data/audit.py"
click node_dataco_pipeline "https://github.com/maher121/phd-blockchain-ai/blob/main/src/preprocessing/dataco_pipeline.py"
click node_feature_engineering "https://github.com/maher121/phd-blockchain-ai/blob/main/src/preprocessing/feature_engineering_v2.py"
click node_pipeline_v02 "https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v02.py"
click node_attack_data "https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/experiment_data.py"
click node_ground_truth "https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/ground_truth.py"
click node_anomaly_models "https://github.com/maher121/phd-blockchain-ai/blob/main/src/lightweight/models.py"
click node_ai_evaluation "https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/evaluation.py"
click node_baseline_evaluation "https://github.com/maher121/phd-blockchain-ai/blob/main/src/ai/evaluation.py"
click node_experiment_runner "https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v06g.py"
click node_feature_selection "https://github.com/maher121/phd-blockchain-ai/blob/main/src/feature_selection/methods.py"
click node_optimization "https://github.com/maher121/phd-blockchain-ai/blob/main/src/optimization/bpso.py"
click node_final_test "https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v10e.py"
click node_order_mapping "https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_mapping/chain_builder.py"
click node_order_chain "https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_engine/order_chain.py"
click node_block_validation "https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_engine/validation.py"
click node_resource_measurement "https://github.com/maher121/phd-blockchain-ai/blob/main/src/green/measurement.py"
click node_energy_estimation "https://github.com/maher121/phd-blockchain-ai/blob/main/src/energy/estimation.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_dataset_discovery,node_data_audit,node_dataco_pipeline,node_feature_engineering,node_pipeline_v02 toneBlue
class node_attack_data,node_ground_truth,node_anomaly_models,node_ai_evaluation,node_baseline_evaluation toneAmber
class node_experiment_runner,node_feature_selection,node_optimization,node_final_test toneMint
class node_order_mapping,node_order_chain,node_block_validation toneRose
class node_resource_measurement,node_energy_estimation,node_researcher toneIndigo
```

## Components

### Data preparation

- [Dataset discovery](https://github.com/maher121/phd-blockchain-ai/blob/main/src/data/dataset_discovery.py): `src/data/dataset_discovery.py`
- [Data audit](https://github.com/maher121/phd-blockchain-ai/blob/main/src/data/audit.py): `src/data/audit.py`
- [DataCo preprocessing](https://github.com/maher121/phd-blockchain-ai/blob/main/src/preprocessing/dataco_pipeline.py): `src/preprocessing/dataco_pipeline.py`
- [Feature engineering](https://github.com/maher121/phd-blockchain-ai/blob/main/src/preprocessing/feature_engineering_v2.py): `src/preprocessing/feature_engineering_v2.py`
- [Data pipeline runner](https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v02.py): `src/pipeline_v02.py`

### Security and AI

- [Attack generation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/experiment_data.py): `src/security/experiment_data.py`
- [Attack ground truth](https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/ground_truth.py): `src/security/ground_truth.py`
- [Anomaly models](https://github.com/maher121/phd-blockchain-ai/blob/main/src/lightweight/models.py): `src/lightweight/models.py`
- [Security evaluation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/security/evaluation.py): `src/security/evaluation.py`
- [AI evaluation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/ai/evaluation.py): `src/ai/evaluation.py`

### Research experiments

- [Robustness runner](https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v06g.py): `src/pipeline_v06g.py`
- [Feature selection](https://github.com/maher121/phd-blockchain-ai/blob/main/src/feature_selection/methods.py): `src/feature_selection/methods.py`
- [BPSO optimization](https://github.com/maher121/phd-blockchain-ai/blob/main/src/optimization/bpso.py): `src/optimization/bpso.py`
- [Final-test evaluation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/pipeline_v10e.py): `src/pipeline_v10e.py`

### Blockchain ledger

- [Order-chain mapping](https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_mapping/chain_builder.py): `src/blockchain_mapping/chain_builder.py`
- [Order chain](https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_engine/order_chain.py): `src/blockchain_engine/order_chain.py`
- [Block validation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/blockchain_engine/validation.py): `src/blockchain_engine/validation.py`

### Resource analysis

- [Resource measurement](https://github.com/maher121/phd-blockchain-ai/blob/main/src/green/measurement.py): `src/green/measurement.py`
- [Energy estimation](https://github.com/maher121/phd-blockchain-ai/blob/main/src/energy/estimation.py): `src/energy/estimation.py`

### Other components

- **Researcher**

## Connections

- Researcher → Data pipeline runner: runs
- Data pipeline runner → Dataset discovery: discovers data
- Data pipeline runner → Data audit: audits data
- Data pipeline runner → DataCo preprocessing: preprocesses splits
- DataCo preprocessing → Feature engineering: engineers features (evidence: `src/preprocessing/dataco_pipeline.py`)
- Robustness runner → Attack generation: prepares attacks (evidence: `src/pipeline_v06g.py`)
- Attack generation → Attack ground truth: builds labels (evidence: `src/security/experiment_data.py`)
- Robustness runner → Anomaly models: uses models (evidence: `src/pipeline_v06g.py`)
- Robustness runner → Security evaluation: evaluates robustness (evidence: `src/pipeline_v06g.py`)
- Security evaluation → Attack ground truth: scores against (evidence: `src/security/evaluation.py`)
- AI evaluation → Anomaly models: uses detector (evidence: `src/ai/evaluation.py`)
- AI evaluation → Attack ground truth: references labels (evidence: `src/ai/evaluation.py`)
- BPSO optimization → Feature selection: uses fitness
- Final-test evaluation → Anomaly models: evaluates classifiers (evidence: `src/pipeline_v10e.py`)
- Order-chain mapping → Order chain: builds chains (evidence: `src/blockchain_mapping/chain_builder.py`)
- Order-chain mapping → Block validation: validates chain (evidence: `src/blockchain_mapping/chain_builder.py`)
- Resource measurement → Energy estimation: separates estimation
