# devu-62442/gramac-a-graph-based-malware-classification-mechanism architecture

> Architecture diagram of the GitHub repository devu-62442/gramac-a-graph-based-malware-classification-mechanism, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism
- Repository: https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism

## Overview

##### Project type and purpose
- This is a standalone Python‐based CLI tool for offline graph‐based malware classification.
- It loads call‐graph files (.gml), compares them to a labeled dataset of Android malware families, and outputs the family name or “UNKNOWN/GOODWARE.”

##### File structure
- Top‐level script:
- MalwareFamily_Classifier.py – the entry point and orchestrator.
- Dataset folder:
- Contains .gml call-graph files for known malware families.
- Dataset/README.md explaining dataset structure.
- Configuration and CI:
- .github/workflows/codeql-analysis.yml for automated code scanning.
- _config.yml for site/theme config (likely for GitHub Pages docs).
- img folder:
- Documentation images and logos.
- README.md:
- Describes usage, dependencies (networkx, matplotlib, Python), and high‐level workflow.

##### README for additional insights
- Core library: networkx for graph creation and comparison.
- Data flow: input GML → graph parsing → sensitive API signature matching → graph similarity → classification result → CLI output.

##### Main components and interactions
a. Components
- CLI Interface
- Input Loader (GML reader)
- Graph Processor (networkx)
- Signature Extractor (sensitive API set)
- Graph Comparator / Classifier
- Dataset Repository (.gml files on disk)
- Output Module (console logger)
- External Services: none (local tool)
- CI Pipeline (GitHub Actions, CodeQL)
b. Relationships & data flow
1. User invokes MalwareFamily_Classifier.py via CLI.
2. CLI Interface parses arguments: path to target GML, dataset path.
3. Input Loader reads target .gml and dataset .gml files.
4. Graph Processor builds NetworkX graphs.
5. Signature Extractor identifies sensitive API nodes in each graph.
6. Classifier computes similarity metrics between target and dataset graphs.
7. Decision logic assigns malware family or “UNKNOWN.”
8. Output Module writes result to console.
9. CI Pipeline (GitHub Actions) runs static analysis on commits.
c. Architectural patterns & principles
- Modular pipeline: each stage (load, process, classify, output) is a separate logical unit.
- Single responsibility: script orchestrates but delegates graph logic to networkx and classifier functions.
- Data‐driven: behavior driven by dataset directory contents.
d. Key technologies
- Python 3.x
- NetworkX (graph structures & algorithms)
- Matplotlib (optional for graph visualization)
- GitHub Actions / CodeQL for CI

##### Detailed but not over-engineered
- Break the pipeline into as many discrete stages as makes sense for readability.
- File/system I/O, library calls, and CI integration.
- Avoid mixing implementation details (e.g., exact function names)—focus on logical components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Pipeline
    subgraph "Core Pipeline"
        CLI["CLI Interface"]:::pipeline
        Loader["Input Loader"]:::pipeline
        Processor["Graph Processor"]:::pipeline
        Extractor["Signature Extractor"]:::pipeline
        Classifier["Graph Comparator / Classifier"]:::pipeline
        Output["Output Module"]:::pipeline
    end

    %% Data Store
    Dataset["Dataset Repository"]:::data

    %% Library
    Lib["NetworkX Library"]:::library

    %% Documentation
    subgraph "Documentation & Assets"
        Readme["README.md"]:::docs
        DatasetReadme["Dataset/README.md"]:::docs
        Config["_config.yml"]:::docs
        Img["img/"]:::docs
    end

    %% CI Pipeline
    subgraph "CI Pipeline"
        CI["GitHub Actions & CodeQL"]:::ci
    end

    %% Data Flow
    CLI -->|"parse args"| Loader
    Loader -->|"reads .gml files"| Dataset
    Loader -->|"outputs raw graph data"| Processor
    Processor -->|"builds NetworkX Graph"| Lib
    Lib -->|"returns graph object"| Processor
    Processor -->|"passes graph"| Extractor
    Extractor -->|"identifies API signatures"| Classifier
    Classifier -->|"computes similarity scores"| Classifier
    Classifier -->|"decision logic"| Output
    Output -->|"prints family/UNKNOWN"| CLI

    CI -->|"runs on push"| CLI

    %% Click Events
    click CLI "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Loader "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Processor "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Extractor "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Classifier "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Output "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/MalwareFamily_Classifier.py"
    click Dataset "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/tree/master/Dataset/"
    click Readme "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/README.md"
    click DatasetReadme "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/Dataset/README.md"
    click Config "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/_config.yml"
    click Img "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/tree/master/img/"
    click CI "https://github.com/devu-62442/gramac-a-graph-based-malware-classification-mechanism/blob/master/.github/workflows/codeql-analysis.yml"

    %% Styles
    classDef pipeline fill:#D6EAF8,stroke:#1B4F72,color:#1B2631;
    classDef data fill:#D5F5E3,stroke:#196F3D,color:#145A32;
    classDef library fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef docs fill:#F2F3F4,stroke:#7B7D7D,color:#424949;
    classDef ci fill:#FADBD8,stroke:#943126,color:#641E16;
```
