# tony-y/cgnn architecture

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

- Interactive diagram: https://gitdiagram.com/tony-y/cgnn
- Repository: https://github.com/tony-y/cgnn

## Overview

##### Main Components

a) Data Processing Layer
- Input Processing
- Crystal Structure Data
- Target Values (CSV)
- Graph Data Generation
- Data Splitting (train/val/test)

b) Core CGNN Architecture
- Node Feature Processing
- Graph Convolution Layers
- Fully Connected Layers
- Output Layer

c) Training/Prediction Pipeline
- Model Training System
- Validation System
- Testing/Prediction System

d) Utilities and Tools
- Visualization Tools
- Performance Metrics
- Data Management

##### Component Relationships

- Data flow from raw input through processing to training
- Model architecture flow
- Training/validation/testing pipeline
- Output generation and visualization

##### Specific Implementation Details

**[Data Sources] → [Data Processing] → [CGNN Core] → [Output/Predictions]**
- ↓               ↓                    ↓              ↓
**[File Formats]  [Processing Tools]   [Model Layers]  [Visualization]**

- Blue: Data processing components (data_utils.py)
- Green: Core model components (models.py, layers.py)
- Orange: Training/prediction pipeline (cgnn.py)
- Purple: Utility tools (tools directory)

##### Detailed Component Breakdown

Data Processing (src/data_utils.py):
**[Crystal Structure] → [Graph Generation] → [Node Vectors]**
- ↓                    ↓                  ↓
**[targets.csv] → [graph_data.npz] → [config.json]**

Model Architecture (src/models.py, src/layers.py):
**[Node Features] → [Graph Convolution] → [Hidden Layers] → [Output]**
- ↓                  ↓                   ↓              ↓
**[n_node_feat]    [n_conv layers]     [n_hidden_feat]  [Predictions]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Data_Sources
        CS[Crystal Structure]
        TV[Target Values]
    end

    subgraph Data_Processing
        DP["Data Processing"]:::data_processing
        GG["Graph Generation"]:::data_processing
        NV["Node Vectors"]:::data_processing
        PBC["Periodic Boundary"]:::tools
    end

    subgraph CGNN_Core
        NF["Node Features"]:::model
        GC["Graph Convolution"]:::model
        HL["Hidden Layers"]:::model
        OL["Output Layer"]:::model
    end

    subgraph Training_Pipeline
        TS["Training System"]:::training
        VS["Validation System"]:::training
        PS["Prediction System"]:::training
    end

    subgraph Tools_Utilities
        VM["Visualization Metrics"]:::tools
        PM["Performance Metrics"]:::tools
        VC["Volume Calculator"]:::tools
    end

    subgraph Example_Applications
        BG["Band Gap Prediction"]:::examples
        FE["Formation Energy"]:::examples
        MP["Magnetism Prediction"]:::examples
        VP["Volume Prediction"]:::examples
    end

    CS --> DP
    TV --> DP
    DP --> GG
    GG --> NV
    PBC --> GG
    NV --> NF
    NF --> GC
    GC --> HL
    HL --> OL
    OL --> TS
    TS --> VS
    VS --> PS
    PS --> VM
    PS --> PM
    PS --> Example_Applications
    VC --> VP

    classDef data_processing fill:#3498db
    classDef model fill:#2ecc71
    classDef training fill:#e67e22
    classDef tools fill:#9b59b6
    classDef examples fill:#95a5a6

    click DP "https://github.com/Tony-Y/cgnn/blob/master/src/data_utils.py"
    click GC "https://github.com/Tony-Y/cgnn/blob/master/src/layers.py"
    click NF "https://github.com/Tony-Y/cgnn/blob/master/src/models.py"
    click HL "https://github.com/Tony-Y/cgnn/blob/master/src/models.py"
    click OL "https://github.com/Tony-Y/cgnn/blob/master/src/models.py"
    click TS "https://github.com/Tony-Y/cgnn/blob/master/src/cgnn.py"
    click PBC "https://github.com/Tony-Y/cgnn/blob/master/tools/pbc.py"
    click VM "https://github.com/Tony-Y/cgnn/blob/master/tools/plot_history.py"
    click VC "https://github.com/Tony-Y/cgnn/blob/master/tools/volume.py"
    click BG "https://github.com/Tony-Y/cgnn/tree/master/examples/oqmd_bg_noEdgeNet"
    click FE "https://github.com/Tony-Y/cgnn/tree/master/examples/oqmd_fe_complete"
    click MP "https://github.com/Tony-Y/cgnn/tree/master/examples/oqmd_mag_noEdgeNet"
    click VP "https://github.com/Tony-Y/cgnn/tree/master/examples/oqmd_vol_noEdgeNet"
```
