# anonymbordo/3d-graph-bleeding-detection- architecture

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

- Interactive diagram: https://gitdiagram.com/anonymbordo/3d-graph-bleeding-detection-
- Repository: https://github.com/anonymbordo/3d-graph-bleeding-detection-
- Video tour (about a minute): https://gitdiagram.com/anonymbordo/3d-graph-bleeding-detection-/video

## Overview

This repository is a Streamlit demo for 3D graph-based bleeding-risk detection from abdominal CT scans. A user selects a demo patient; the app loads the trained model and patient data, derives organ features and a spatial graph, runs multi-label inference, then presents risk results as CT overlays, a 3D graph, and detail tables. The graph separates data preparation, model loading/inference, and presentation. The source excerpts show the main runtime calls; unsampled training and dataset-generation behavior is not mapped.

Main entry points: [`app.py`](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/app.py) (Streamlit patient demo), [`inference.py`](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py) (Patient inference), [`model_def.py`](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_def.py) (Model and metadata loader), [`visualize.py`](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py) (CT overlay viewer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Demo presentation"]
  node_app["Streamlit patient demo<br/>[app.py]"]
  node_details["Risk and label details<br/>[app.py]"]
end

subgraph group_preparation["Patient preparation"]
  node_patientdata[("CT, masks, labels")]
  node_patientload["Patient data loader<br/>[inference.py]"]
  node_features["Organ features<br/>[inference.py]"]
  node_graphbuild["Spatial graph builder<br/>[inference.py]"]
end

subgraph group_model["Model and inference"]
  node_predict["Patient inference<br/>[inference.py]"]
  node_model_loader["Model and metadata loader<br/>[model_def.py]"]
  node_checkpoint["Trained weights<br/>[model.pt]"]
  node_metadata["Model metadata"]
  node_gnn["Bleeding GNN<br/>[model_def.py]"]
end

subgraph group_visuals["Risk visualization"]
  node_ctview["CT overlay viewer<br/>[visualize.py]"]
  node_graphview["3D graph viewer<br/>[visualize.py]"]
  node_riskmap["Organ risk mapping<br/>[visualize.py]"]
end

node_user(("Clinician / demo user"))

node_user -->|"selects patient"| node_app
node_app -->|"loads model"| node_model_loader
node_model_loader -->|"loads weights"| node_checkpoint
node_model_loader -->|"reads metadata"| node_metadata
node_model_loader -->|"constructs"| node_gnn
node_app -->|"requests prediction"| node_predict
node_predict -->|"loads patient"| node_patientload
node_patientload -->|"reads CT and labels"| node_patientdata
node_predict -->|"extracts features"| node_features
node_predict -->|"builds graph"| node_graphbuild
node_predict -->|"runs inference"| node_gnn
node_predict -->|"returns predictions"| node_app
node_app -->|"renders CT overlay"| node_ctview
node_app -->|"renders 3D graph"| node_graphview
node_app -->|"shows result details"| node_details
node_ctview -->|"maps organ risk"| node_riskmap
node_graphview -->|"maps organ risk"| node_riskmap

click node_app "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/app.py"
click node_details "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/app.py"
click node_ctview "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py"
click node_graphview "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py"
click node_patientdata "https://github.com/anonymbordo/3d-graph-bleeding-detection-/tree/main/demo_package"
click node_patientload "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py"
click node_features "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py"
click node_graphbuild "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py"
click node_predict "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py"
click node_model_loader "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_def.py"
click node_checkpoint "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model.pt"
click node_metadata "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_metadata.json"
click node_gnn "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_def.py"
click node_riskmap "https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.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_app,node_details,node_user toneBlue
class node_patientdata,node_patientload,node_features,node_graphbuild toneAmber
class node_predict,node_model_loader,node_checkpoint,node_metadata,node_gnn toneMint
class node_ctview,node_graphview,node_riskmap toneRose
```

## Components

### Demo presentation

- [Streamlit patient demo](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/app.py): `app.py`
- [Risk and label details](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/app.py): `app.py`

### Patient preparation

- [CT, masks, labels](https://github.com/anonymbordo/3d-graph-bleeding-detection-/tree/main/demo_package): `demo_package`
- [Patient data loader](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py): `inference.py`
- [Organ features](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py): `inference.py`
- [Spatial graph builder](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py): `inference.py`

### Model and inference

- [Patient inference](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/inference.py): `inference.py`
- [Model and metadata loader](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_def.py): `model_def.py`
- [Trained weights](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model.pt): `model.pt`
- [Model metadata](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_metadata.json): `model_metadata.json`
- [Bleeding GNN](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/model_def.py): `model_def.py`

### Risk visualization

- [CT overlay viewer](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py): `visualize.py`
- [3D graph viewer](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py): `visualize.py`
- [Organ risk mapping](https://github.com/anonymbordo/3d-graph-bleeding-detection-/blob/main/visualize.py): `visualize.py`

### Other components

- **Clinician / demo user**

## Connections

- Clinician / demo user → Streamlit patient demo: selects patient (evidence: `app.py`)
- Streamlit patient demo → Model and metadata loader: loads model (evidence: `app.py`)
- Model and metadata loader → Trained weights: loads weights (evidence: `model_def.py`)
- Model and metadata loader → Model metadata: reads metadata (evidence: `model_def.py`)
- Model and metadata loader → Bleeding GNN: constructs (evidence: `model_def.py`)
- Streamlit patient demo → Patient inference: requests prediction (evidence: `app.py`)
- Patient inference → Patient data loader: loads patient (evidence: `inference.py`)
- Patient data loader → CT, masks, labels: reads CT and labels (evidence: `inference.py`)
- Patient inference → Organ features: extracts features (evidence: `inference.py`)
- Patient inference → Spatial graph builder: builds graph (evidence: `inference.py`)
- Patient inference → Bleeding GNN: runs inference (evidence: `inference.py`)
- Patient inference → Streamlit patient demo: returns predictions (evidence: `app.py`)
- Streamlit patient demo → CT overlay viewer: renders CT overlay (evidence: `app.py`)
- Streamlit patient demo → 3D graph viewer: renders 3D graph (evidence: `app.py`)
- Streamlit patient demo → Risk and label details: shows result details (evidence: `app.py`)
- CT overlay viewer → Organ risk mapping: maps organ risk (evidence: `visualize.py`)
- 3D graph viewer → Organ risk mapping: maps organ risk (evidence: `visualize.py`)
