# interlynk-io/sbommv architecture

> Architecture diagram of the GitHub repository interlynk-io/sbommv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/interlynk-io/sbommv
- Repository: https://github.com/interlynk-io/sbommv

## Overview

##### Project Overview
- sbommv is a command-line tool designed for transferring SBOMs (Software Bills of Materials) between Source (input adapters) and Target systems (output adapters).
- The tool’s extensibility leverages an adapter-based design, with existing adapters for GitHub and folder as input sources and for Interlynk (and in future, Dependency-Track and others) as output destinations.
- The README further illustrates the data flow: inputs → enrichment/translation (conversion) → outputs.

##### Main Components
a. Command-Line Interface (CLI):
- Represented by the “cmd” directory (cmd/root.go, cmd/transfer.go, cmd/version.go) and main.go.
- This is the entry point where commands are parsed and the transfer process is invoked.

b. Input Adapters:
- Located under pkg/source, supporting folders and GitHub (pkg/source/folder and pkg/source/github).
- These components are responsible for fetching and reading SBOMs.

c. Transformation / Enrichment Layer:
- Although noted as “coming soon” for enrichment/translation, the conversion process is hinted at with pkg/converter (including file spdx22tospdx23.go).
- This as the intermediary “Enrichment/Translation Module” that standardizes or enriches the SBOM data.

d. Core Engine / Transfer Logic:
- The “pkg/engine” contains business logic for transferring the data from input to output adapters.
- Also, the pkg/tcontext and pkg/iterator indicate context management and iteration over fetched SBOMs.

e. Output Adapters:
- Implemented under pkg/target, including folders, interlynk (and a stub for dependencytrack).
- These handle the complexity of uploading or reporting the collected SBOMs to target systems.

f. Supporting Utilities:
- The “pkg/logger” for logging, “pkg/monitor” for monitoring, and various utility packages (pkg/utils, pkg/types) support the system.
- Optionally, include these components or represent them as side services that support the main data flow through cross-cutting concerns like logging and error handling.

##### Architectural Patterns & Design Principles
- Adapter-based architecture:
- Each adapter (input or output) abstracts external systems.
- The Transfer Engine decouples the overall logic from specific implementations.
- It shows a modular, loosely-coupled design, where adding a new adapter would plug into the system without affecting others.

##### Relevant Technologies & Frameworks
- The project is written in Go, as can be seen from go.mod, go.sum, and directory structure.
- GitHub Actions workflows (in .github/workflows) and Dockerfile indicate CI/CD and containerization support.
- Tools like Make (Makefile) and GoReleaser configuration (.goreleaser.yaml) support the build and deployment practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Command-Line Interface
    subgraph "Command-Line Interface"
        CLI["Command-Line Interface (CLI)"]:::cli
    end

    %% Transfer Engine Layer
    subgraph "Transfer Engine"
        TE["Transfer Engine"]:::engine
        TC["Transfer Context"]:::engine
        Iter["Iterator"]:::engine
        TE -->|"link_TC"| TC
        TE -->|"link_Iter"| Iter
    end

    %% Input Adapter Components
    subgraph "Input Adapter Components"
        GitHub["GitHub Adapter"]:::input
        FolderIn["Folder Adapter (Input)"]:::input
    end

    %% Transformation/Translation Module
    subgraph "Transformation/Translation Module"
        Converter["Converter"]:::converter
    end

    %% Output Adapter Components
    subgraph "Output Adapter Components"
        Interlynk["Interlynk Adapter"]:::output
        FolderOut["Folder Adapter (Output)"]:::output
        DepTrack["Dependency-Track Adapter (Upcoming)"]:::output
    end

    %% Supporting Utilities
    subgraph "Supporting Utilities"
        Logger["Logger"]:::util
        Monitor["Monitoring"]:::util
        Utils["Utilities & Types"]:::util
    end

    %% Data Flow
    CLI -->|"initiate_transfer"| TE
    TE -->|"fetch_SBOM"| GitHub
    TE -->|"fetch_SBOM"| FolderIn
    GitHub -->|"SBOM_data"| Converter
    FolderIn -->|"SBOM_data"| Converter
    Converter -->|"transformed_SBOMs"| Interlynk
    Converter -->|"transformed_SBOMs"| FolderOut
    Converter -->|"transformed_SBOMs"| DepTrack

    %% Feedback: Logging Arrows
    CLI ---|"logging"| Logger
    TE ---|"logging"| Logger
    GitHub ---|"logging"| Logger
    FolderIn ---|"logging"| Logger
    Converter ---|"logging"| Logger
    Interlynk ---|"logging"| Logger
    FolderOut ---|"logging"| Logger
    DepTrack ---|"logging"| Logger

    %% Feedback: Monitoring Arrows
    CLI ---|"monitoring"| Monitor
    TE ---|"monitoring"| Monitor
    GitHub ---|"monitoring"| Monitor
    FolderIn ---|"monitoring"| Monitor
    Converter ---|"monitoring"| Monitor
    Interlynk ---|"monitoring"| Monitor
    FolderOut ---|"monitoring"| Monitor
    DepTrack ---|"monitoring"| Monitor

    %% Click Events
    click CLI "https://github.com/interlynk-io/sbommv/blob/main/main.go"
    click GitHub "https://github.com/interlynk-io/sbommv/tree/main/pkg/source/github"
    click FolderIn "https://github.com/interlynk-io/sbommv/tree/main/pkg/source/folder"
    click Converter "https://github.com/interlynk-io/sbommv/tree/main/pkg/converter"
    click TE "https://github.com/interlynk-io/sbommv/tree/main/pkg/engine"
    click TC "https://github.com/interlynk-io/sbommv/tree/main/pkg/tcontext"
    click Iter "https://github.com/interlynk-io/sbommv/tree/main/pkg/iterator"
    click Interlynk "https://github.com/interlynk-io/sbommv/tree/main/pkg/target/interlynk"
    click FolderOut "https://github.com/interlynk-io/sbommv/tree/main/pkg/target/folder"
    click DepTrack "https://github.com/interlynk-io/sbommv/tree/main/pkg/target/dependencytrack"
    click Logger "https://github.com/interlynk-io/sbommv/tree/main/pkg/logger"
    click Monitor "https://github.com/interlynk-io/sbommv/tree/main/pkg/monitor"
    click Utils "https://github.com/interlynk-io/sbommv/tree/main/pkg/utils"

    %% Styles
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef engine fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef input fill:#F4A460,stroke:#000,stroke-width:2px;
    classDef converter fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef output fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef util fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
