# mylonasc/tf_gnns architecture

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

- Interactive diagram: https://gitdiagram.com/mylonasc/tf_gnns
- Repository: https://github.com/mylonasc/tf_gnns

## Overview

##### Project Type and Purpose
- The project is an open-source library designed for constructing graph neural networks (GNNs) using TensorFlow 2.x and Keras.
- Its design is inspired by the DeepMind graph_nets library but leverages Keras for easier model composition and improved performance.
- It supports arbitrary node/edge/global attributes, offers convenience functions for MLP construction, and aims to simplify the implementation of GNN architectures.

##### Analyzing the File Structure
- Top-Level Files and Directories:
- Dockerfile and requirements.txt are used for deployment and dependency management.
- The README and LICENSE provide project documentation and licensing info.
- The notebooks directory contains demonstrative Jupyter notebooks, showcasing usage examples (like basic functionality and a list sorting example).
- The core library code is found under the tf_gnns directory, with submodules for assets, utility functions, graph operations, and model definitions.
- Within tf_gnns:
- datastructures.py: Likely defines the key graph data structures and representations.
- graphnet_utils.py: Contains helper functions for preparing and manipulating graphs.
- The lib subdirectory (with gt_ops.py): Implements lower-level operations which might include customized TensorFlow graph transformations or utility operations.
- The models directory (including graphnet.py): Houses the model layers and architecture logic, encapsulating the message-passing functionality.
- utils.py and utils_train.py: Provide utilities for general tasks and training workflow support.
- The assets inside tf_gnns/assets (html_css and related files) could be part of a frontend module for interactive visualization or debugging interfaces.

- Main Components:
- Library Core:
- Model Definitions:
- Training and Utility Modules:
- Assets and Visualization:
- Examples/Usage:
- Deployment and Documentation:

- Interactions and Relationships:
- Link the training utilities with the model definitions (and possibly the general utilities) to show how the training process is managed.
- Notebooks and documentation with the main library as illustrative usage references.

- Architectural Patterns and Design Principles:
- Modular Design: The code organization clearly separates data structures, low-level operations, model definitions, and utility functions, which emphasizes reusability and clear separation of concerns.

- Relevant Technologies and Frameworks:
- TensorFlow (version 2.x) & Keras: Core to building and training the graph neural networks.
- (Planned) tensorflow_probability: Mention future support or paths where probabilistic components might be integrated.
- Docker: For containerized deployment and dependency management.
- Python notebooks: To demonstrate usage and validations of the library’s components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "TensorFlow and Keras Framework"
        subgraph "Core Modules"
            DS["Data Structures"]:::core
            GUF["Graph Utility Functions"]:::core
            LLO["Low-Level Graph Operations"]:::core
            GN["GraphNet Model"]:::core
        end
        subgraph "Utilities"
            GU["General Utilities"]:::utilities
            TU["Training Utilities"]:::utilities
        end
    end

    subgraph "External Components"
        AV["Assets/Visualization"]:::external
        NB["Notebooks"]:::external
        DEP["Deployment & Dependencies"]:::external
        DOC["Documentation"]:::external
    end

    %% Data flow arrows within the Framework
    DS -->|"feeds_data"| GN
    GUF -->|"prepares_data"| GN
    LLO -->|"custom_ops"| GN
    GN -->|"triggers_training"| TU
    GU -->|"supports_training"| TU

    %% External components interactions
    DEP -->|"sets_environment"| DS
    DOC -->|"provides_context"| GN
    NB -->|"demonstrates_usage"| GN
    AV -->|"visualizes"| GN

    %% Additional interactions from external to utilities
    NB -->|"usage_example"| TU

    %% Click Events
    click DS "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/datastructures.py"
    click GUF "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/graphnet_utils.py"
    click LLO "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/lib/gt_ops.py"
    click GN "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/models/graphnet.py"
    click GU "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/utils.py"
    click TU "https://github.com/mylonasc/tf_gnns/blob/main/tf_gnns/utils_train.py"
    click AV "https://github.com/mylonasc/tf_gnns/tree/main/tf_gnns/assets/html_css"
    click NB "https://github.com/mylonasc/tf_gnns/tree/main/notebooks"
    click DEP "https://github.com/mylonasc/tf_gnns/blob/main/Dockerfile and requirements.txt"
    click DOC "https://github.com/mylonasc/tf_gnns/tree/main/doc"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef utilities fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px;
```
