# labrijisaad/git-clustering architecture

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

- Interactive diagram: https://gitdiagram.com/labrijisaad/git-clustering
- Repository: https://github.com/labrijisaad/git-clustering

## Overview

##### Project type and purpose
- This is a Python-based, full-stack library/package that implements and repackages the GIT (Graph of Intensity Topology) clustering algorithm.
- It provides:
- Core clustering logic (`src/git_cluster/…`)
- Data ingestion modules (`src/dataloaders/…`)
- Utility routines for measurement and plotting (`src/utils/…`)
- Jupyter notebooks for quick start and benchmarks
- CI/CD via GitHub Actions and packaging via PyPI/TestPyPI

##### File structure
- Top-level:
- `.github/workflows`: CI jobs for code quality and package testing
- `src/`: library code split into three subpackages:
– `dataloaders`: real & toy dataset loaders
– `git_cluster`: core algorithm modules (detect_local_mode, kde, topo_graph, git.py)
– `utils`: measures, plotting helpers
- `datasets/`: raw datasets (real & toy) used in notebooks
- `notebooks/`: interactive demos & benchmarks
- `tests/`: unit tests and test notebooks
- Packaging/config: `pyproject.toml`, `requirements.txt`, `Makefile`

##### README for additional insights
- Confirms it’s a re-packaged GIT clustering algorithm with:
- Quick start usage
- Benchmark notebooks
- Published to TestPyPI
- Dependencies: `gdown`, standard Python ML stack

##### Main components and their interactions
a. Components
1. External data sources (Toy & Real datasets + gdown download)
2. Data loader layer (`Toy_DataLoader`, `Real_DataLoader`, `MNIST loader`)
3. Core GIT algorithm (`kde`, `topo_graph`, `detect_local_mode`, `git.py`)
4. Utilities (`measures.py`, `plot_tools.py`)
5. Notebooks & CLI (user-facing entry points)
6. CI/CD pipelines (GitHub Actions)
7. Packaging & Distribution (PyPI/TestPyPI)
8. Version control (GitHub repo)
b. Relationships
- Data flows from datasets → dataloaders → GIT core → utils → output (plots, metrics)
- Notebooks import from `git_cluster`, `dataloaders`, `utils`
- CI pipelines run tests (unit tests, notebooks) and publish to TestPyPI
c. Architectural patterns
- Layered architecture: Data ingestion → Processing → Utilities → Presentation
- Modular packaging: separate Python subpackages for clear concerns
- CI/CD integration ensures quality gates and automated publishing
d. Key technologies
- Python 3, Jupyter notebooks
- Git & GitHub Actions
- PyPI/TestPyPI packaging (`pyproject.toml`, `wheel`)
- Common ML/data libs (NumPy, SciPy, Matplotlib, etc.)

##### Detailed breakdown to capture essentials
- Layer 1 (Data): Toy & Real dataset storage or remote download
- Layer 2 (Ingestion): `src/dataloaders`
- Layer 3 (Processing): `src/git_cluster` modules, flow from density estimation → topology graph → mode detection → cluster assignment
- Layer 4 (Utilities): metric calculation, plotting
- Layer 5 (Presentation): Jupyter notebooks, sample scripts
- Cross-cutting: Version control (GitHub), CI/CD workflows, Packaging/Distribution

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    subgraph "Data Layer"
        Datasets["External Data Sources"]:::external
    end

    %% Ingestion Layer
    subgraph "Ingestion Layer"
        ToyLoader["Toy DataLoader"]:::library
        RealLoader["Real DataLoader"]:::library
        MNISTLoader["MNIST DataLoader"]:::library
    end

    %% Processing Layer
    subgraph "Processing Layer"
        KDE["Density Estimation (kde.py)"]:::library
        TopoGraph["Topology Graph (topo_graph.py)"]:::library
        DetectMode["Local Mode Detection (detect_local_mode.py)"]:::library
        GIT["GIT Interface (git.py)"]:::library
    end

    %% Utility Layer
    subgraph "Utility Layer"
        Measures["Measurement Routines (measures.py)"]:::library
        PlotTools["Plotting Helpers (plot_tools.py)"]:::library
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Notebooks["Jupyter Notebooks"]:::notebook
        Tests["Unit Tests & Test Notebooks"]:::notebook
    end

    %% CI/CD & Distribution
    subgraph "CI/CD & Distribution"
        Repo["GitHub Repo"]:::external
        CodeQuality["Code Quality Workflow"]:::ci
        PackageTest["Package Test Workflow"]:::ci
        TestPyPI["TestPyPI"]:::external
        Packaging["Packaging & Distribution"]:::config
        PyProject["pyproject.toml"]:::config
        Requirements["requirements.txt"]:::config
        Makefile["Makefile"]:::config
    end

    %% Data Flow
    Datasets --> ToyLoader
    Datasets --> RealLoader
    Datasets --> MNISTLoader
    ToyLoader --> KDE
    RealLoader --> KDE
    MNISTLoader --> KDE
    KDE --> TopoGraph
    TopoGraph --> DetectMode
    DetectMode --> GIT
    GIT --> Measures
    GIT --> PlotTools
    Measures --> Notebooks
    PlotTools --> Notebooks
    Measures --> Tests
    PlotTools --> Tests

    %% CI/CD Flow
    Repo --> CodeQuality
    Repo --> PackageTest
    CodeQuality --> Tests
    PackageTest --> TestPyPI
    PackageTest --> Packaging
    Packaging --> PyProject
    Packaging --> Requirements
    Packaging --> Makefile

    %% Click Events
    click Datasets "https://github.com/labrijisaad/git-clustering/tree/main/datasets/"
    click ToyLoader "https://github.com/labrijisaad/git-clustering/blob/main/src/dataloaders/toy_dataloader.py"
    click RealLoader "https://github.com/labrijisaad/git-clustering/blob/main/src/dataloaders/real_dataloader.py"
    click MNISTLoader "https://github.com/labrijisaad/git-clustering/blob/main/src/dataloaders/mnist_loader.py"
    click KDE "https://github.com/labrijisaad/git-clustering/blob/main/src/git_cluster/kde.py"
    click TopoGraph "https://github.com/labrijisaad/git-clustering/blob/main/src/git_cluster/topo_graph.py"
    click DetectMode "https://github.com/labrijisaad/git-clustering/blob/main/src/git_cluster/detect_local_mode.py"
    click GIT "https://github.com/labrijisaad/git-clustering/blob/main/src/git_cluster/git.py"
    click Measures "https://github.com/labrijisaad/git-clustering/blob/main/src/utils/measures.py"
    click PlotTools "https://github.com/labrijisaad/git-clustering/blob/main/src/utils/plot_tools.py"
    click Notebooks "https://github.com/labrijisaad/git-clustering/tree/main/notebooks/"
    click Tests "https://github.com/labrijisaad/git-clustering/tree/main/tests/"
    click CodeQuality "https://github.com/labrijisaad/git-clustering/blob/main/.github/workflows/code_quality.yml"
    click PackageTest "https://github.com/labrijisaad/git-clustering/blob/main/.github/workflows/package_test.yml"
    click PyProject "https://github.com/labrijisaad/git-clustering/blob/main/pyproject.toml"
    click Requirements "https://github.com/labrijisaad/git-clustering/blob/main/requirements.txt"
    click Makefile "https://github.com/labrijisaad/git-clustering/tree/main/Makefile"

    %% Styles
    classDef library fill:#cfe2f3, stroke:#6a96c8, color:#0b3d91
    classDef external fill:#d9ead3, stroke:#6aa84f, color:#274e13
    classDef notebook fill:#f4cccc, stroke:#cc0000, color:#660000
    classDef ci fill:#fce5cd, stroke:#e69138, color:#7f6000
    classDef config fill:#e7e6e6, stroke:#999999, color:#333333
```
