# cgao-comp/gamc architecture

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

- Interactive diagram: https://gitdiagram.com/cgao-comp/gamc
- Repository: https://github.com/cgao-comp/gamc

## Overview

##### Project type and purpose
- GAMC is a machine-learning pipeline for unsupervised fake-news detection. It builds graph representations of news items, trains a graph autoencoder with masking and contrastive learning, and evaluates anomaly/fake-news scores.

##### File structure
- Top-level
- configs.yml: hyperparameters, model & dataset settings
- main_new.py (or main_graph.py): entry point that parses arguments, loads config, kicks off training/evaluation
- code/gamc package
- datasets/
– data_util.py: functions to load raw data, build DGL graphs
- models/
– edcoder.py: encoder + decoder logic for graph autoencoder
– gat.py, gin.py: Graph Attention Network & Graph Isomorphism Network backbones
– loss_func.py: masking / contrastive loss implementations
- evaluation.py: computes metrics / fake-news scores
- utils.py: logging, seed setting, helper routines

##### README for insights
- Dependencies: Python, PyTorch, DGL, PyYAML
- Invocation: python main_graph.py --dataset DATASETNAME --use_cfg
- External datasets hosted on Google Drive

##### Detail
- Break the pipeline into as many discrete steps as make sense (e.g., raw CSV loader, feature normalization, graph builder)
- Config parsing as its own component
- Both training and evaluation branches

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        Config["Configuration Loader (YAML parser)"]:::config
    end

    subgraph "Data Components"
        ExtData["External Dataset Storage"]:::external
        DataUtil["Dataset Loader & Graph Constructor"]:::data
    end

    subgraph "Model Components"
        GAT["GAT Backbone"]:::model
        GIN["GIN Backbone"]:::model
        Autoenc["Autoencoder (Encoder + Decoder)"]:::model
        Loss["Masking & Contrastive‐Learning Module"]:::model
    end

    subgraph "Pipeline"
        Train["Training Loop & Entry Point"]:::process
        Eval["Evaluation Module"]:::data
    end

    Util["Utilities (logging, seed setting, helpers)"]:::util
    Doc["Project Documentation & Instructions"]:::util

    Config -->|provides hyperparameters| DataUtil
    Config -->|provides hyperparameters| GAT
    Config -->|provides hyperparameters| GIN
    Config -->|provides hyperparameters| Autoenc

    ExtData -->|raw data| DataUtil
    DataUtil -->|DGL Graphs| Train

    GAT -->|forward| Train
    GIN -->|forward| Train
    Autoenc -->|encode/decode| Train
    Loss -->|compute losses| Train

    Train -->|model checkpoints & graphs| Eval
    Util ---|logs & monitoring| Train
    Util ---|logs & monitoring| Eval
    Doc ---|instructions| Config

    click Config "https://github.com/cgao-comp/gamc/blob/main/code/configs.yml"
    click DataUtil "https://github.com/cgao-comp/gamc/blob/main/code/gamc/datasets/data_util.py"
    click GAT "https://github.com/cgao-comp/gamc/blob/main/code/gamc/models/gat.py"
    click GIN "https://github.com/cgao-comp/gamc/blob/main/code/gamc/models/gin.py"
    click Autoenc "https://github.com/cgao-comp/gamc/blob/main/code/gamc/models/edcoder.py"
    click Loss "https://github.com/cgao-comp/gamc/blob/main/code/gamc/models/loss_func.py"
    click Train "https://github.com/cgao-comp/gamc/blob/main/code/main_new.py"
    click Eval "https://github.com/cgao-comp/gamc/blob/main/code/gamc/evaluation.py"
    click Util "https://github.com/cgao-comp/gamc/blob/main/code/gamc/utils.py"
    click Doc "https://github.com/cgao-comp/gamc/blob/main/README.md"

    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef model fill:#90EE90,stroke:#000,stroke-width:1px
    classDef util fill:#FFA500,stroke:#000,stroke-width:1px
    classDef config fill:#FFB347,stroke:#000,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef process fill:#98FB98,stroke:#000,stroke-width:1px
```
