# jubenitezg/go-clone-thesis architecture

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

- Interactive diagram: https://gitdiagram.com/jubenitezg/go-clone-thesis
- Repository: https://github.com/jubenitezg/go-clone-thesis

## Overview

##### Project’s Purpose and Type
- Purpose: The project supports a master thesis study on “Code cloning in Go open source projects” by mining GitHub repositories, extracting code metadata (like abstract syntax trees and functions), and then performing clone detection and topic analysis.
- Project Type: It is a research and data-processing pipeline that includes data collection, static code analysis, and machine learning / topic modeling components. There is a significant emphasis on extracting code fragments and analyzing similarities between them.

##### File Structure
- Top-Level Modules/Subprojects:
- GitHubMiner: Contains scripts (e.g., index.js, command.sh) for collecting repository data. It outputs files in CSV/JSON from mining GitHub.
- ast-builder: A Go-coded component that builds AST representations from source code. It includes tests and utilizes constants, nodes, and extractor logic.
- function-extractor: Another Go project that focuses on extracting functions (or code fragments) from the source code. It includes common utilities, test assets, and tests.
- metadata-extraction: A module (written in Go) responsible for collecting metadata from repositories, outputting processed JSON and tracking skipped files.
- repositories-function-extraction: Uses shell scripts and helpers to count and extract repository functions.
- clone-detection: Contains several Python scripts and Jupyter Notebooks for analyzing clone detection data, computing clone density, similarities, and correlations.
- topic-analysis: Comprises multiple methods for topic modeling including submodules for bertopic, description extraction, and LDA analysis with its own set of notebooks and configuration files.
- utils: A set of Python utility scripts that support various extraction and upload tasks.
- Configuration & CI/CD: The .github directory with multiple workflow YAML files and linting configurations in .golangci.yml files in various modules indicate automated testing and code quality checks.

- Main Components:
- Data Collection Module: Represent GitHubMiner as the starting point for collecting Go repositories from GitHub.
- Code Extraction Modules: Group ast-builder and function-extractor as components responsible for parsing source code and building ASTs / extracting relevant function data.
- Metadata and Repository Analysis: Include metadata-extraction and repositories-function-extraction, which extract and aggregate additional details.
- Clone Detection Analysis: Capture clone-detection as the component where processed code data is analyzed for clone types (Exact, Renamed, Near miss, Semantic).
- Topic Modeling & NLP Analysis: Represent topic-analysis (subdivided into bertopic, description extraction, and LDA) for deriving insights and topics from textual metadata or clone patterns.
- CI/CD / Quality Assurance: Note the presence of GitHub Actions workflows for testing and linting as part of the development operations.

- Relationships & Data Flow:

##### Architectural Patterns and Design Principles
- Modularity: Each subproject is a self-contained module with its own responsibilities, tests, and configurations.
- Pipeline Architecture: The system can be viewed as a sequential pipeline—from data collection to extraction and finally, data analysis.
- Interoperability: Components are implemented in different languages (Go, Node.js, Python) but interoperate through file-based outputs (CSV, JSON) and scripts.
- CI/CD integration: The inclusion of GitHub workflows that automate testing and linting is also an important part of the system's operational design.

- A separate container or notation for CI/CD integrations (.github workflows) that monitors code quality.

- Data is harvested via GitHubMiner,
- Source code is processed (AST & function extraction) by dedicated Go-based modules,
- Additional metadata and repository function count is collected,
- Clone detection analysis is performed using Python notebooks,
- And finally, topic analysis is applied to derive insights from the aggregated data.

This detailed view will help capture the essential architecture, making it easier for the principal software engineer to understand the distinct responsibilities, dependencies, and technologies used across this multifaceted research project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Collection"
        GitHubMiner["GitHubMiner"]
    end

    subgraph "Code Extraction"
        AST_Builder["AST Builder"]
        Function_Extractor["Function Extractor"]
        Metadata_Extractor["Metadata Extractor"]
        Repo_Function_Extraction["Repository Function Extraction"]
    end

    subgraph "Clone Detection & Analysis"
        Clone_Detection["Clone Detection"]
        Topic_Analysis["Topic Analysis"]
    end

    Utils["Utils"]
    CI_CD[".github"]

    %% Data flow from Data Collection to Code Extraction
    GitHubMiner -->|"GitHubRepositoryData"| AST_Builder
    GitHubMiner -->|"GitHubRepositoryData"| Function_Extractor
    GitHubMiner -->|"GitHubRepositoryData"| Metadata_Extractor
    GitHubMiner -->|"GitHubRepositoryData"| Repo_Function_Extraction

    %% Data flow from Code Extraction to Clone Detection
    AST_Builder -->|"ASTData"| Clone_Detection
    Function_Extractor -->|"FunctionData"| Clone_Detection
    Metadata_Extractor -->|"Metadata"| Clone_Detection
    Repo_Function_Extraction -->|"RepoFunctionData"| Clone_Detection

    %% Clone Detection feeds Topic Analysis
    Clone_Detection -->|"CloneAnalysis"| Topic_Analysis

    %% Support arrows to Utils (dotted style)
    AST_Builder -.->|"support"| Utils
    Function_Extractor -.->|"support"| Utils
    Metadata_Extractor -.->|"support"| Utils
    Repo_Function_Extraction -.->|"support"| Utils
    Clone_Detection -.->|"support"| Utils
    Topic_Analysis -.->|"support"| Utils

    %% CI/CD Testing Dotted Arrows
    GitHubMiner -.->|"tested"| CI_CD
    AST_Builder -.->|"tested"| CI_CD
    Function_Extractor -.->|"tested"| CI_CD
    Metadata_Extractor -.->|"tested"| CI_CD
    Repo_Function_Extraction -.->|"tested"| CI_CD
    Clone_Detection -.->|"tested"| CI_CD
    Topic_Analysis -.->|"tested"| CI_CD
    Utils -.->|"tested"| CI_CD

    %% Click Events
    click GitHubMiner "https://github.com/jubenitezg/go-clone-thesis/tree/main/GitHubMiner"
    click AST_Builder "https://github.com/jubenitezg/go-clone-thesis/tree/main/ast-builder"
    click Function_Extractor "https://github.com/jubenitezg/go-clone-thesis/tree/main/function-extractor"
    click Metadata_Extractor "https://github.com/jubenitezg/go-clone-thesis/tree/main/metadata-extraction"
    click Repo_Function_Extraction "https://github.com/jubenitezg/go-clone-thesis/tree/main/repositories-function-extraction"
    click Clone_Detection "https://github.com/jubenitezg/go-clone-thesis/tree/main/clone-detection"
    click Topic_Analysis "https://github.com/jubenitezg/go-clone-thesis/tree/main/topic-analysis"
    click Utils "https://github.com/jubenitezg/go-clone-thesis/tree/main/utils"
    click CI_CD "https://github.com/jubenitezg/go-clone-thesis/blob/main/.github"

    %% Styles
    classDef nodejs fill:#FFCC00,stroke:#333,stroke-width:2px,color:black;
    classDef go fill:#66CC66,stroke:#333,stroke-width:2px,color:black;
    classDef python fill:#6699FF,stroke:#333,stroke-width:2px,color:black;
    classDef ci fill:#CCCCCC,stroke:#333,stroke-width:2px,color:black;

    class GitHubMiner nodejs;
    class AST_Builder,Function_Extractor,Metadata_Extractor,Repo_Function_Extraction go;
    class Clone_Detection,Topic_Analysis,Utils python;
    class CI_CD ci;
```
