# devolearn/devograph architecture

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

- Interactive diagram: https://gitdiagram.com/devolearn/devograph
- Repository: https://github.com/devolearn/devograph

## Overview

##### Project Type and Purpose
- This is a research-oriented, full-stack computational project with several experimental pipelines. Its aim is to construct and analyze graphs (and even hypergraphs) that model cell development using temporal/directed GNNs.
- The README highlights different contributions that include constructing temporal graphs using KNN, re-implementing directed GNN models, image processing for cell tracking (Stage 1), and applying Topological Data Analysis (TDA, Stages 2 and 3). The project also branches out into hypergraph analyses (HyperDevoGraph) and diverse visualization outputs.

##### Analyzing the File Tree
- Several top-level directories (like Growing-GNN, HyperDevoGraph, devograph, stage_1, stage_2, stage_3) indicate that the project is organized into different experimental modules/pipelines.
- The “devograph” module is noteworthy, because it includes:
– /datasets: for constructing temporal graphs (e.g., via KNN and mother-daughter relationships as described in the README).
– /models: with implementations of a directed GNN (ct.py) and other models (gcn.py).
– /pipelines and /utils: that assemble and support the core methods.
- The “stage_” directories indicate different phases of processing:
– Stage 1 focuses on image processing and segmentation (cell tracking, mask segmentation, etc.).
– Stage 2 emphasizes applications of TDA using KMapper.
– Stage 3 contains further TDA efforts (lower star filtration, persistent homology).
- Other directories (Growing-GNN and HyperDevoGraph) also contain notebooks, scripts, and data related to alternative graph construction methods and hypergraph experiments.

a. Main Components:
- Data Collection & Preprocessing:
– Raw Data Storage: “data” directory (including MATLAB files, CSVs, videos, images, Excel files).
– Image Processing & Segmentation: Stage 1 (Cell Tracking Challenge and R-CNN Mask Segmentation components).
- Graph Construction and Transformation:
– Growing-GNN: Scripts like “graph.py”, “graph_nca.py” for constructing temporal graphs.
– devograph/datasets: Implements both the KNN-based temporal graph construction and directed graphs (datasets.py and datasets1.py).
- Model Building and Inference:
– GNN Models: Located in devograph/models (directed GNN in ct.py and conventional GCN).
– Pipeline Orchestration: devograph/pipelines which integrate data and model components.
- Postprocessing and Analysis:
– TDA Modules: Stage 2 (K-Mapper, output HTML visualizations) and Stage 3 (persistent homology and filtration notebooks).
– Hypergraph Analysis: HyperDevoGraph including notebooks (analysis_scripts), processed data, and visualizations.
- Visualization & Reporting:
– Visual outputs embedded in directories such as HyperDevoGraph/visualizations, and various notebooks in stage directories.
– Miscellaneous documentation and PDF (project design outlines, e.g., GSoC 2022 PDF).
- External Integration:
– APIs, dependency and environment management (requirements.txt, environment.yml in TDA folder) that support deployment and reproducibility.

b. Relationships and Interactions:
- A clear data flow that begins with raw data ingestion (images, CSV, MATLAB files) then proceeds through preprocessing modules (Stage 1) and graph construction (Growing-GNN, devograph/datasets).
- Graph construction modules to the GNN models (both the directed and GCN paths).
- Separate branches for analysis where the outputs of the models feed into TDA pipelines (Stage 2 and Stage 3) and hypergraph processing (HyperDevoGraph).

c. Architectural Patterns and Technologies:
- Abstraction of core logic in graph construction and GNN models – this modularity allows for swapping and testing different approaches.
- Use of notebook-based pipelines (e.g., .ipynb files) for prototyping and analysis.
- Language and framework indicators: Python scripts, use of environment/configuration files (requirements.txt, environment.yml), and the use of third-party frameworks for image processing and graph analysis (although not all are explicitly named, they can be inferred from file names and dependency lists).

- For a full-stack application, separate the backend processing (data ingestion, graph construction, GNN training) from the analysis/visualization layer.

##### Final Recommendations
- Keep the level of detail high by mapping out as many components as possible based on the file structure, but group similar experimental pipelines where appropriate.
- That any external libraries or frameworks (implied by the requirements files) are noted if they are central to data processing or model training.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Collection & Preprocessing
    DataCollection("Data Collection & Preprocessing"):::storage

    %% Stage 1: Image Processing & Segmentation
    subgraph "Stage 1: Image Processing & Segmentation"
        CTC("Cell Tracking Challenge"):::processing
        RCNN("R-CNN Mask Segmentation"):::processing
    end

    ProcessedData("Processed Data"):::processing

    %% Data flows from raw data to Stage 1 processing
    DataCollection --> CTC
    DataCollection --> RCNN
    CTC --> ProcessedData
    RCNN --> ProcessedData

    %% Graph Construction
    subgraph "Graph Construction"
        %% Temporal Graph Construction (Growing-GNN)
        subgraph "Temporal Graph Construction (Growing-GNN)"
            GG1("graph.py"):::processing
            GG2("graph_nca.py"):::processing
        end
        TempOut("Temporal Graph Output"):::processing

        %% Graph Construction via Datasets (devograph)
        subgraph "Graph Construction via Datasets (devograph)"
            DevData1("datasets.py"):::processing
            DevData2("datasets1.py"):::processing
        end
        DataOut("Datasets Graph Output"):::processing
    end

    %% Feeding processed data into graph construction branches
    ProcessedData --> GG1
    ProcessedData --> DevData1
    GG1 --> TempOut
    GG2 --> TempOut
    DevData1 --> DataOut
    DevData2 --> DataOut

    %% Merging Graph Construction outputs
    subgraph "Graph Output"
        GraphOut("Combined Graph Data"):::processing
    end
    TempOut --> GraphOut
    DataOut --> GraphOut

    %% GNN Model Implementations
    subgraph "GNN Model Implementations"
        GNN_Dir("Directed GNN (ct.py)"):::processing
        GNN_GCN("GCN (gcn.py)"):::processing
    end
    GraphOut --> GNN_Dir
    GraphOut --> GNN_GCN

    %% Pipeline Orchestration
    Pipeline("Pipeline Orchestration"):::orchestration
    GNN_Dir --> Pipeline
    GNN_GCN --> Pipeline

    %% Analysis & Visualization
    subgraph "Analysis & Visualization"
        TDA2("TDA Analysis (Stage 2)"):::analysis
        TDA3("TDA Analysis (Stage 3)"):::analysis
        Hyper("Hypergraph Analysis & Visualization"):::analysis
    end
    Pipeline --> TDA2
    Pipeline --> TDA3
    Pipeline --> Hyper

    %% External Integration & Environment Management
    subgraph "External Integration & Env Management"
        RootReq("Root requirements.txt"):::external
        GGReq("Growing-GNN requirements.txt"):::external
        CTCReq("Cell Tracking Challenge requirements.txt"):::external
        TDAEnv("Stage 3 TDA environment.yml"):::external
    end
    Pipeline --> RootReq
    Pipeline --> GGReq
    Pipeline --> CTCReq
    Pipeline --> TDAEnv

    %% Click Events
    click DataCollection "https://github.com/devolearn/devograph/tree/main/data/"
    click CTC "https://github.com/devolearn/devograph/tree/main/stage_1/Cell Tracking Challenge"
    click RCNN "https://github.com/devolearn/devograph/tree/main/stage_1/R-CNN Mask Segmentation"
    click GG1 "https://github.com/devolearn/devograph/blob/main/Growing-GNN/graph.py"
    click GG2 "https://github.com/devolearn/devograph/blob/main/Growing-GNN/graph_nca.py"
    click DevData1 "https://github.com/devolearn/devograph/blob/main/devograph/datasets/datasets.py"
    click DevData2 "https://github.com/devolearn/devograph/blob/main/devograph/datasets/datasets1.py"
    click GNN_Dir "https://github.com/devolearn/devograph/blob/main/devograph/models/ct.py"
    click GNN_GCN "https://github.com/devolearn/devograph/blob/main/devograph/models/gcn.py"
    click Pipeline "https://github.com/devolearn/devograph/blob/main/devograph/pipelines/pipelines.py"
    click TDA2 "https://github.com/devolearn/devograph/tree/main/stage_2/TDA_using_K-Mapper/"
    click TDA3 "https://github.com/devolearn/devograph/tree/main/stage_3/TDA/"
    click Hyper "https://github.com/devolearn/devograph/tree/main/HyperDevoGraph/analysis_scripts/"
    click RootReq "https://github.com/devolearn/devograph/blob/main/requirements.txt"
    click GGReq "https://github.com/devolearn/devograph/blob/main/Growing-GNN/requirements.txt"
    click CTCReq "https://github.com/devolearn/devograph/blob/main/stage_1/Cell Tracking Challenge/requirements.txt"
    click TDAEnv "https://github.com/devolearn/devograph/blob/main/stage_3/TDA/environment.yml"

    %% Styling Classes
    classDef storage fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef processing fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef orchestration fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef analysis fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
```
