# janbiasi/rollup-plugin-sbom architecture

> Architecture diagram of the GitHub repository janbiasi/rollup-plugin-sbom, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/janbiasi/rollup-plugin-sbom
- Repository: https://github.com/janbiasi/rollup-plugin-sbom

## Overview

##### Main Components

a. Input Layer:
- Rollup/Vite Build Process
- Project Dependencies
- Configuration Options

b. Core Plugin Components:
- Builder Module (src/builder.ts)
- Options Handler (src/options.ts)
- Helpers (src/helpers.ts)
- Type Definitions (src/types/)

c. Output Layer:
- CycloneDX SBOM Generation
- Multiple Format Outputs (JSON/XML)
- Well-known Directory Output

**┌─────────────────────────────────────────────────────────┐**
- Build Process                       │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- Rollup    │    │    Vite     │    │   Project   │ │
- Plugin    │───▶│   Plugin    │    │Dependencies │ │
- ┘    └─────────────┘    └─────────────┘ │
- ┬─────────────────────────────┘
- ▼
**┌─────────────────────────────────────────────────────────┐**
- Plugin Core                          │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- Options   │    │   Builder   │    │   Helpers   │ │
- Handler    │───▶│   Module    │◄───│   Module    │ │
- ┘    └─────────────┘    └─────────────┘ │
- ▲                │                            │
- ┌────────────────┐       │                            │
- Types      │       │                            │
- Definitions    │       │                            │
- ┘       ▼                            │
- ┘

- ▼
**┌─────────────────────────────────────────────────────────┐**
- Output Generation                     │
- ┌─────────────┐    ┌─────────────┐    ┌─────────────┐ │
- CycloneDX  │    │    JSON     │    │    XML      │ │
- SBOM      │───▶│   Format    │    │   Format    │ │
- ┘    └─────────────┘    └─────────────┘ │
- ┘

##### Important Elements to Highlight

- Version Compatibility:
- Supported Vite (v4, v5, v6) and Rollup (v3, v4) versions
- Node.js version support (18, 20, 22)
- CycloneDX spec versions (1.5, 1.6)

- Configuration Options Flow:
- How user configuration merges with default options
- Configuration validation process

##### Key Relationships

- Builder module's interaction with the input build process
- Options handling and validation flow
- Output format generation paths
- Test fixtures integration for different Vite versions

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Build
        RollupPlugin["Rollup Plugin"]
        VitePlugin["Vite Plugin"]
        Dependencies["Project Dependencies"]
        RollupPlugin --> VitePlugin
        VitePlugin --> Dependencies
    end

    subgraph Core
        EntryPoint["Plugin Entry Point"]:::file
        Options["Options Handler"]:::file
        Builder["Builder Module"]:::file
        Helpers["Helpers Module"]:::file
        Types["Type Definitions"]:::dir
        
        EntryPoint --> Options
        Options --> Builder
        Helpers --> Builder
        Types --> Options
    end

    subgraph Testing
        TestInfra["Test Infrastructure"]:::dir
        ViteV5Tests["Vite v5 Tests"]:::file
        ViteV6Tests["Vite v6 Tests"]:::file
        TestHelpers["Test Helpers"]:::file
        TestFixtures["Test Fixtures"]:::dir
        
        TestInfra --> ViteV5Tests
        TestInfra --> ViteV6Tests
        TestHelpers --> ViteV5Tests
        TestHelpers --> ViteV6Tests
        TestFixtures --> TestInfra
    end

    subgraph Validation
        Schema15["CycloneDX 1.5 Schema"]:::file
        Schema16["CycloneDX 1.6 Schema"]:::file
    end

    subgraph Output
        SBOM["CycloneDX SBOM"]
        JSON["JSON Format"]
        XML["XML Format"]
        
        SBOM --> JSON
        SBOM --> XML
    end

    subgraph Config
        BuildConfig["Build Configuration"]:::file
        TSConfig["TypeScript Configuration"]:::file
        CICD["CI/CD Pipeline"]:::file
    end

    Build --> EntryPoint
    Core --> SBOM
    Schema15 --> SBOM
    Schema16 --> SBOM
    TestInfra --> Core

    %% Click events for component mapping
    click Builder "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/src/builder.ts"
    click Options "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/src/options.ts"
    click Helpers "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/src/helpers.ts"
    click Types "https://github.com/janbiasi/rollup-plugin-sbom/tree/main/src/types/"
    click EntryPoint "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/src/index.ts"
    click ViteV5Tests "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/test/vite-v5.test.ts"
    click ViteV6Tests "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/test/vite-v6.test.ts"
    click TestHelpers "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/test/helpers.ts"
    click Schema15 "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/test/schemas/bom-1.5.schema.json"
    click Schema16 "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/test/schemas/bom-1.6.schema.json"
    click TestFixtures "https://github.com/janbiasi/rollup-plugin-sbom/tree/main/test/fixtures/"
    click BuildConfig "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/build.config.ts"
    click TSConfig "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/tsconfig.json"
    click CICD "https://github.com/janbiasi/rollup-plugin-sbom/blob/main/.github/workflows/ci.yml"

    %% Styling
    classDef file fill:#f9f,stroke:#333,stroke-width:2px
    classDef dir fill:#bbf,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        File["File"]:::file
        Directory["Directory"]:::dir
    end
```
