# shenwanxiang/acanet architecture

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

- Interactive diagram: https://gitdiagram.com/shenwanxiang/acanet
- Repository: https://github.com/shenwanxiang/acanet

## Overview

##### Project type and purpose
- This is a Python-based open-source machine learning library (“clsar”) for molecular activity prediction, implementing a custom “Activity-Cliff-Aware” loss (ACA-Loss) and a graph-neural-network model (ACANet). It provides both PyTorch and TensorFlow backends, a scikit-learn–style API, command-line entrypoints, and hyperparameter-tuning routines.

##### File structure
- Top-level packaging/configuration:
- setup.py, MANIFEST.in, requirements.txt, README.md, .github/CI workflows
- Core library module “clsar/”:
- dataset/data.py – data-loading and preprocessing
- feature/featurizer.py – graph conversion and featurization
- model/
– model.py: GNN architecture
– loss.py, loss_tf.py: ACA-Loss implementations (PyTorch & TF)
– train.py: training loop, backprop orchestration
– saver.py: checkpointing and model I/O
- main.py: high-level ACANet class, CLI & API façade
- “experiment/” tree: notebooks, scripts, and results for benchmarking (not part of the runtime library)

##### README for additional insights
- It describes two main functionalities:
a) ACALoss: enhances metric learning in latent space + regression
b) ACANet: wraps dataset loading, loss hyperparameter tuning (opt_cliff_by_cv, opt_alpha_by_cv), cross-validation, fit, predict
- It shows dependency on external datasets (MPCD) and that the model interfaces like scikit-learn

##### Diagramming recommendations
- Use clear, concise labels for each module (e.g., “data.py: Data Loader”, “model.py: GNN”)
- Blue for Data/Feature
- Orange for Model/Loss
- Purple for Training/Saving
- Yellow for API/CLI
- Gray for External dependencies & CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies
    subgraph "External & CI/CD"
        direction TB
        README["README.md"]:::external
        Setup["setup.py"]:::external
        Req["requirements.txt"]:::external
        Manifest["MANIFEST.in"]:::external
        CI[".github/workflows/python-publish.yml"]:::external
    end

    ExtData(["MPCD Dataset"]):::external

    %% Data & Feature Layer
    subgraph "Data & Feature Layer"
        direction TB
        DataLoader["data.py: Data Loader"]:::dataFeature
        Featurizer["featurizer.py: Graph Featurizer"]:::dataFeature
    end

    %% Model & Loss Layer
    subgraph "Model & Loss Layer"
        direction TB
        GNNModel["model.py: GNN Architecture"]:::modelLoss
        PyTorchLoss["loss.py: ACA-Loss (PyTorch)"]:::modelLoss
        TFLoss["loss_tf.py: ACA-Loss (TensorFlow)"]:::modelLoss
    end

    %% Training & Saving
    subgraph "Training & Saving"
        direction TB
        Trainer["train.py: Training Engine"]:::trainSave
        Saver["saver.py: Checkpoint & I/O"]:::trainSave
    end

    %% API & CLI Facade
    subgraph "API & CLI Facade"
        direction TB
        ACANet["main.py: ACANet (fit/predict/CLI)"]:::api
    end

    %% Data Flow
    ExtData --> DataLoader
    DataLoader --> Featurizer
    Featurizer --> GNNModel
    GNNModel --> PyTorchLoss
    GNNModel --> TFLoss
    PyTorchLoss --> Trainer
    TFLoss --> Trainer
    Trainer --> Saver

    %% API Orchestration
    ACANet --> DataLoader
    ACANet --> Featurizer
    ACANet --> Trainer
    ACANet --> Saver

    %% CI/CD & Packaging support main.py
    Setup --> ACANet
    Req --> ACANet
    Manifest --> ACANet
    CI --> ACANet
    README --> ACANet

    %% Click Events
    click DataLoader "https://github.com/shenwanxiang/acanet/blob/main/clsar/dataset/data.py"
    click Featurizer "https://github.com/shenwanxiang/acanet/blob/main/clsar/feature/featurizer.py"
    click GNNModel "https://github.com/shenwanxiang/acanet/blob/main/clsar/model/model.py"
    click PyTorchLoss "https://github.com/shenwanxiang/acanet/blob/main/clsar/model/loss.py"
    click TFLoss "https://github.com/shenwanxiang/acanet/blob/main/clsar/model/loss_tf.py"
    click Trainer "https://github.com/shenwanxiang/acanet/blob/main/clsar/model/train.py"
    click Saver "https://github.com/shenwanxiang/acanet/blob/main/clsar/model/saver.py"
    click ACANet "https://github.com/shenwanxiang/acanet/blob/main/clsar/main.py"
    click Setup "https://github.com/shenwanxiang/acanet/blob/main/setup.py"
    click Req "https://github.com/shenwanxiang/acanet/blob/main/requirements.txt"
    click Manifest "https://github.com/shenwanxiang/acanet/blob/main/MANIFEST.in"
    click README "https://github.com/shenwanxiang/acanet/blob/main/README.md"
    click CI "https://github.com/shenwanxiang/acanet/blob/main/.github/workflows/python-publish.yml"

    %% Styles
    classDef dataFeature fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef modelLoss fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef trainSave fill:#e6ccff,stroke:#333,stroke-width:1px
    classDef api fill:#fff2b3,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
```
