# wizzy-balzz/ai-project architecture

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

- Interactive diagram: https://gitdiagram.com/wizzy-balzz/ai-project
- Repository: https://github.com/wizzy-balzz/ai-project

## Overview

This is a defensive cybersecurity research dashboard for predicting and explaining likely attack paths in synthetic network scenarios. The principal workflow generates or stores a topology, converts it to a directed graph, extracts GNN features, predicts node risk, enumerates and ranks candidate paths, then exposes explanations and mitigation simulations through a FastAPI service and interactive frontend. The backend graph service is the application orchestration layer between persisted scenarios and analysis. Several model and UI relationships are documented rather than shown in sampled source, so those edges are cited to the README or marked unverified.

Main entry points: [`backend/app/services/graph_service.py`](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/services/graph_service.py) (Graph Service), [`frontend/src/store/scenarioStore.ts`](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/store/scenarioStore.ts) (Scenario State), [`backend/ml/dataset.py`](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/dataset.py) (GNN Dataset Pipeline), [`backend/ml/path_generator.py`](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/path_generator.py) (Path Generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_topology["Topology and Features"]
  node_synthetic["Synthetic Topologies<br/>[synthetic_data.py]"]
  node_domain["Network Data Models<br/>[data_models.py]"]
  node_builder["Directed Graph Builder<br/>[graph_builder.py]"]
  node_features["Feature Extractor"]
  node_dataset["GNN Dataset Pipeline<br/>[dataset.py]"]
end

subgraph group_prediction["Prediction and Risk"]
  node_gnn["GraphSAGE Model<br/>[model.py]"]
  node_trainer["Model Training<br/>[trainer.py]"]
  node_evaluator["Model Evaluation<br/>[evaluator.py]"]
  node_pathmodels["Path Models<br/>[path_models.py]"]
  node_pathgen["Path Generator<br/>[path_generator.py]"]
  node_risk["Risk Scorer<br/>[risk_scorer.py]"]
  node_explainer["XAI and Mitigations<br/>[explainer.py]"]
end

subgraph group_service["Application Service"]
  node_database[("Scenario Database<br/>[database.py]")]
  node_models["Scenario Records<br/>[scenario.py]"]
  node_graphservice["Graph Service<br/>[graph_service.py]"]
  node_api["REST API<br/>[router.py]"]
  node_app["FastAPI Application<br/>[main.py]"]
end

subgraph group_dashboard["Defense Dashboard"]
  node_client["API Client<br/>[client.ts]"]
  node_scenario_store["Scenario State<br/>[scenarioStore.ts]"]
  node_graph_store["Graph State<br/>[graphStore.ts]"]
  node_inspector["Node Inspector"]
  node_simulator["What-if Simulator"]
  node_xai_view["XAI Views"]
end

node_operator(("Defender"))

node_synthetic -->|"creates records"| node_domain
node_builder -->|"consumes topology"| node_domain
node_dataset -->|"builds graph"| node_builder
node_dataset -->|"extracts features"| node_features
node_dataset -->|"converts topology"| node_domain
node_trainer -.->|"trains on"| node_dataset
node_trainer -.->|"trains"| node_gnn
node_evaluator -.->|"evaluates"| node_gnn
node_pathgen -->|"prepares inference data"| node_dataset
node_pathgen -->|"infers probabilities"| node_gnn
node_pathgen -->|"builds candidates"| node_pathmodels
node_risk -.->|"scores paths"| node_pathmodels
node_explainer -.->|"explains paths"| node_pathmodels
node_graphservice -->|"constructs graph"| node_builder
node_graphservice -->|"maps topology"| node_domain
node_graphservice -->|"generates paths"| node_pathgen
node_graphservice -->|"ranks paths"| node_risk
node_graphservice -->|"creates explanations"| node_explainer
node_graphservice -.->|"persists results"| node_database
node_graphservice -->|"uses scenario records"| node_models
node_app -->|"initializes tables"| node_database
node_app -->|"mounts routes"| node_api
node_api -.->|"dispatches analysis"| node_graphservice
node_operator -.->|"selects scenario"| node_scenario_store
node_scenario_store -->|"requests API"| node_client
node_client -.->|"sends HTTP requests"| node_app
node_scenario_store -.->|"updates graph state"| node_graph_store
node_graph_store -->|"supplies node data"| node_inspector
node_scenario_store -->|"supplies scenario state"| node_inspector
node_scenario_store -.->|"drives simulations"| node_simulator
node_scenario_store -.->|"supplies path results"| node_xai_view

click node_synthetic "https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/synthetic_data.py"
click node_domain "https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/data_models.py"
click node_builder "https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/graph_builder.py"
click node_features "https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/feature_extractor.py"
click node_dataset "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/dataset.py"
click node_gnn "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/model.py"
click node_trainer "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/trainer.py"
click node_evaluator "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/evaluator.py"
click node_pathmodels "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/path_models.py"
click node_pathgen "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/path_generator.py"
click node_risk "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/risk_scorer.py"
click node_explainer "https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/explainer.py"
click node_database "https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/database.py"
click node_models "https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/models/scenario.py"
click node_graphservice "https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/services/graph_service.py"
click node_api "https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/api/router.py"
click node_app "https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/main.py"
click node_client "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/api/client.ts"
click node_scenario_store "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/store/scenarioStore.ts"
click node_graph_store "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/store/graphStore.ts"
click node_inspector "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/inspector/NodeInspectorView.tsx"
click node_simulator "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/simulation/WhatIfSimulatorPanel.tsx"
click node_xai_view "https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/xai/KillChainNarrativeView.tsx"

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_synthetic,node_domain,node_builder,node_features,node_dataset toneBlue
class node_gnn,node_trainer,node_evaluator,node_pathmodels,node_pathgen,node_risk,node_explainer toneAmber
class node_database,node_models,node_graphservice,node_api,node_app toneMint
class node_client,node_scenario_store,node_graph_store,node_inspector,node_simulator,node_xai_view toneRose
class node_operator toneIndigo
```

## Components

### Topology and Features

- [Synthetic Topologies](https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/synthetic_data.py): `backend/core/synthetic_data.py`
- [Network Data Models](https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/data_models.py): `backend/core/data_models.py`
- [Directed Graph Builder](https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/graph_builder.py): `backend/core/graph_builder.py`
- [Feature Extractor](https://github.com/wizzy-balzz/ai-project/blob/main/backend/core/feature_extractor.py): `backend/core/feature_extractor.py`
- [GNN Dataset Pipeline](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/dataset.py): `backend/ml/dataset.py`

### Prediction and Risk

- [GraphSAGE Model](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/model.py): `backend/ml/model.py`
- [Model Training](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/trainer.py): `backend/ml/trainer.py`
- [Model Evaluation](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/evaluator.py): `backend/ml/evaluator.py`
- [Path Models](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/path_models.py): `backend/ml/path_models.py`
- [Path Generator](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/path_generator.py): `backend/ml/path_generator.py`
- [Risk Scorer](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/risk_scorer.py): `backend/ml/risk_scorer.py`
- [XAI and Mitigations](https://github.com/wizzy-balzz/ai-project/blob/main/backend/ml/explainer.py): `backend/ml/explainer.py`

### Application Service

- [Scenario Database](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/database.py): `backend/app/database.py`
- [Scenario Records](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/models/scenario.py): `backend/app/models/scenario.py`
- [Graph Service](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/services/graph_service.py): `backend/app/services/graph_service.py`
- [REST API](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [FastAPI Application](https://github.com/wizzy-balzz/ai-project/blob/main/backend/app/main.py): `backend/app/main.py`

### Defense Dashboard

- [API Client](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Scenario State](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/store/scenarioStore.ts): `frontend/src/store/scenarioStore.ts`
- [Graph State](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/store/graphStore.ts): `frontend/src/store/graphStore.ts`
- [Node Inspector](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/inspector/NodeInspectorView.tsx): `frontend/src/components/inspector/NodeInspectorView.tsx`
- [What-if Simulator](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/simulation/WhatIfSimulatorPanel.tsx): `frontend/src/components/simulation/WhatIfSimulatorPanel.tsx`
- [XAI Views](https://github.com/wizzy-balzz/ai-project/blob/main/frontend/src/components/xai/KillChainNarrativeView.tsx): `frontend/src/components/xai/KillChainNarrativeView.tsx`

### Other components

- **Defender**

## Connections

- Synthetic Topologies → Network Data Models: creates records (evidence: `backend/core/synthetic_data.py`)
- Directed Graph Builder → Network Data Models: consumes topology (evidence: `backend/core/graph_builder.py`)
- GNN Dataset Pipeline → Directed Graph Builder: builds graph (evidence: `backend/ml/dataset.py`)
- GNN Dataset Pipeline → Feature Extractor: extracts features (evidence: `backend/ml/dataset.py`)
- GNN Dataset Pipeline → Network Data Models: converts topology (evidence: `backend/ml/dataset.py`)
- Model Training → GNN Dataset Pipeline: trains on (evidence: `README.md`)
- Model Training → GraphSAGE Model: trains (evidence: `README.md`)
- Model Evaluation → GraphSAGE Model: evaluates (evidence: `README.md`)
- Path Generator → GNN Dataset Pipeline: prepares inference data (evidence: `backend/ml/path_generator.py`)
- Path Generator → GraphSAGE Model: infers probabilities (evidence: `backend/ml/path_generator.py`)
- Path Generator → Path Models: builds candidates (evidence: `backend/ml/path_generator.py`)
- Risk Scorer → Path Models: scores paths (evidence: `README.md`)
- XAI and Mitigations → Path Models: explains paths (evidence: `README.md`)
- Graph Service → Directed Graph Builder: constructs graph (evidence: `backend/app/services/graph_service.py`)
- Graph Service → Network Data Models: maps topology (evidence: `backend/app/services/graph_service.py`)
- Graph Service → Path Generator: generates paths (evidence: `backend/app/services/graph_service.py`)
- Graph Service → Risk Scorer: ranks paths (evidence: `backend/app/services/graph_service.py`)
- Graph Service → XAI and Mitigations: creates explanations (evidence: `backend/app/services/graph_service.py`)
- Graph Service → Scenario Database: persists results
- Graph Service → Scenario Records: uses scenario records (evidence: `backend/app/services/graph_service.py`)
- FastAPI Application → Scenario Database: initializes tables (evidence: `backend/app/main.py`)
- FastAPI Application → REST API: mounts routes (evidence: `backend/app/main.py`)
- REST API → Graph Service: dispatches analysis
- Defender → Scenario State: selects scenario
- Scenario State → API Client: requests API (evidence: `frontend/src/store/scenarioStore.ts`)
- API Client → FastAPI Application: sends HTTP requests
- Scenario State → Graph State: updates graph state
- Graph State → Node Inspector: supplies node data (evidence: `frontend/src/components/inspector/NodeInspectorView.tsx`)
- Scenario State → Node Inspector: supplies scenario state (evidence: `frontend/src/components/inspector/NodeInspectorView.tsx`)
- Scenario State → What-if Simulator: drives simulations
- Scenario State → XAI Views: supplies path results
