# llnl/surfactant architecture

> Architecture diagram of the GitHub repository llnl/surfactant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/llnl/surfactant
- Repository: https://github.com/llnl/surfactant

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Framework:
- Configuration Management System
- Plugin System
- File Type Identification System
- Information Extractors
- Relationship Analyzers
- SBOM Types/Models
- Output Writers

b) CLI Interface:
- Command Processing
- User Interface Components

c) Plugin Architecture:
- Plugin Manager
- Hook Specifications
- Plugin Integration Points

##### Component Relationships

**[CLI Interface] → [Core Framework]**
- ↓
**[Configuration Manager] ← [Plugin Manager]**
- ↓
**[File Type Identification] → [Information Extractors]**
- ↓
**[Relationship Analyzers] → [SBOM Generator]**
- ↓
**[Output Writers] → [Final SBOM]**

##### Specific Implementation Details

- Blue Rectangles: Core Components
- surfactant/cmd/ (CLI components)
- surfactant/configmanager.py (Configuration)
- surfactant/plugin/ (Plugin system)

- Green Hexagons: Processing Components
- surfactant/filetypeid/ (File identification)
- surfactant/infoextractors/ (Information extraction)
- surfactant/relationships/ (Relationship analysis)

- Yellow Diamonds: Data Models
- surfactant/sbomtypes/ (SBOM data structures)

- Purple Rectangles: Output Systems
- surfactant/output/ (Various output formats)

##### Data Flow Representation

**[Input Files] → [File Type ID] → [Info Extraction]**
- ↓
**[Relationship Analysis] → [SBOM Generation]**
- ↓
**[Output Generation] → [Final SBOM]**

##### Plugin Integration Points

**[Plugin Manager] ⇢ [Info Extractors]**
**[Plugin Manager] ⇢ [Relationship Analyzers]**
**[Plugin Manager] ⇢ [Output Writers]**

##### Key Design Elements to Emphasize

- Modular Architecture: Show clear separation between components
- Plugin System: Highlight extensibility points
- Processing Pipeline: Demonstrate the flow from input to output
- Configuration System: Show how it affects all components
- Multiple Output Formats: Indicate support for different SBOM formats

##### Additional Notes

- Version/format support indicators
- Plugin system flexibility
- Configuration points
- Critical paths and dependencies

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    classDef core fill:#2b2b2b,stroke:#333,stroke-width:2px,color:#fff
    classDef processing fill:#006100,stroke:#004d00,stroke-width:2px,color:#fff
    classDef data fill:#F8B229,stroke:#c78d00,stroke-width:2px,color:#000
    classDef output fill:#7C0000,stroke:#590000,stroke-width:2px,color:#fff
    classDef plugin fill:#4B0082,stroke:#380061,stroke-width:2px,color:#fff

    subgraph Interface
        CLI["CLI Interface"]:::core
        UI["User Interface"]:::core
    end

    subgraph Core
        Config["Configuration Manager"]:::core
        PluginMgr["Plugin Manager"]:::plugin
        HookSpec["Hook Specifications"]:::plugin
    end

    subgraph Processing
        FileID["File Type Identification"]:::processing
        InfoExt["Information Extractors"]:::processing
        RelAnalyzer["Relationship Analyzers"]:::processing
        InputRead["Input Readers"]:::processing
    end

    subgraph DataModels
        SBOM["SBOM Types/Models"]:::data
    end

    subgraph Output
        OutWriter["Output Writers"]:::output
        FinalSBOM["Final SBOM"]:::output
    end

    CLI --> Config
    UI --> Config
    Config <--> PluginMgr
    PluginMgr <--> HookSpec
    
    InputRead --> FileID
    FileID --> InfoExt
    InfoExt --> RelAnalyzer
    RelAnalyzer --> SBOM
    SBOM --> OutWriter
    OutWriter --> FinalSBOM

    PluginMgr -.-> InfoExt
    PluginMgr -.-> RelAnalyzer
    PluginMgr -.-> OutWriter

    %% Click events for component mapping
    click CLI "https://github.com/llnl/surfactant/tree/main/surfactant/cmd/"
    click UI "https://github.com/llnl/surfactant/blob/main/surfactant/cmd/ui.py"
    click Config "https://github.com/llnl/surfactant/blob/main/surfactant/configmanager.py"
    click PluginMgr "https://github.com/llnl/surfactant/blob/main/surfactant/plugin/manager.py"
    click HookSpec "https://github.com/llnl/surfactant/blob/main/surfactant/plugin/hookspecs.py"
    click FileID "https://github.com/llnl/surfactant/tree/main/surfactant/filetypeid/"
    click InfoExt "https://github.com/llnl/surfactant/tree/main/surfactant/infoextractors/"
    click RelAnalyzer "https://github.com/llnl/surfactant/tree/main/surfactant/relationships/"
    click SBOM "https://github.com/llnl/surfactant/tree/main/surfactant/sbomtypes/"
    click OutWriter "https://github.com/llnl/surfactant/tree/main/surfactant/output/"
    click InputRead "https://github.com/llnl/surfactant/tree/main/surfactant/input_readers/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Processing Components"]:::processing
        L3["Data Models"]:::data
        L4["Output Components"]:::output
        L5["Plugin Components"]:::plugin
    end
```
