# hangga/delvelin architecture

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

- Interactive diagram: https://gitdiagram.com/hangga/delvelin
- Repository: https://github.com/hangga/delvelin

## Overview

##### Core Components

a. Scanner Core (Main Entry Points):
- `Delvelin.java` and `DelvelinScan.java` as the central components
- Configuration input handling from both Gradle plugin and library usage paths

b. Detector System:
- Various detectors into categories:
- Security Detectors (SQL Injection, XSS, etc.)
- Thread Safety Detectors (NonThreadSafe, NonAtomic)
- Cryptographic Detectors (WeakCryptographic)
- Code Quality Detectors (Reflection, etc.)

c. OSV Integration:
- `OsvDetector` and `OsvVulnerabilityParser` as a separate subsystem
- External communication with OSV.dev API

##### Supporting Systems

a. Configuration Management:
- `Config.java` handling various configuration options
- `OutputFileFormat` and other properties

b. Output Generation:
- HTML template system (from src/main/resources/html)
- JSON and LOG output paths
- `Reports.java` as the coordinator

c. Utility Services:
- File handling (`FileUtil.java`)
- Logging system (`DelvelinLog.java`)
- Source code analysis (`SourceSet.java`)

##### Use a layered architecture approach
**[Input Layer]**
- ↓
**[Configuration Layer]**
- ↓
**[Core Scanner Layer]**
- ↓
**[Detector Layer]**
- ↓
**[Output Layer]**

##### The output generation process

Remember to include external dependencies and integration points, particularly the OSV.dev API connection and browser interaction for HTML reports.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef output fill:#9b59b6,stroke:#8e44ad,color:white

    %% Input Layer
    subgraph Input
        GradlePlugin["Gradle Plugin"]
        LibraryUsage["Library Usage"]
    end

    %% Configuration Layer
    subgraph Configuration
        Config["Configuration Manager"]:::config
        OutputFormat["Output Format Settings"]:::config
    end

    %% Core Scanner Layer
    subgraph CoreScanner
        Delvelin["Delvelin"]:::core
        DelvelinScan["DelvelinScan"]:::core
    end

    %% Detector Layer
    subgraph Detectors
        BaseDetector["Base Detector"]:::core
        
        subgraph SecurityDetectors
            SQLInjection["SQL Injection"]:::security
            XSS["XSS"]:::security
            CmdInjection["Command Injection"]:::security
        end
        
        subgraph ThreadSafetyDetectors
            NonThreadSafe["Non Thread Safe"]:::security
            NonAtomic["Non Atomic"]:::security
        end
        
        subgraph CryptoDetectors
            WeakCrypto["Weak Cryptographic"]:::security
        end
        
        subgraph OSVSystem
            OsvDetector["OSV Detector"]:::external
            OsvParser["OSV Parser"]:::external
            OsvAPI["OSV.dev API"]:::external
        end
    end

    %% Utility Layer
    subgraph Utilities
        FileUtil["File Utility"]:::utility
        DelvelinLog["Logging System"]:::utility
        SourceSet["Source Analysis"]:::utility
    end

    %% Output Layer
    subgraph Output
        Reports["Report Generator"]:::output
        HTMLOutput["HTML Reports"]:::output
        JSONOutput["JSON Output"]:::output
        LOGOutput["LOG Output"]:::output
        Browser["Web Browser"]:::external
    end

    %% Relationships
    GradlePlugin --> Config
    LibraryUsage --> Config
    Config --> DelvelinScan
    Config --> OutputFormat
    Delvelin --> DelvelinScan
    DelvelinScan --> BaseDetector
    BaseDetector --> SecurityDetectors
    BaseDetector --> ThreadSafetyDetectors
    BaseDetector --> CryptoDetectors
    BaseDetector --> OSVSystem
    OsvDetector --> OsvParser
    OsvParser -.-> OsvAPI
    DelvelinScan --> Reports
    Reports --> HTMLOutput
    Reports --> JSONOutput
    Reports --> LOGOutput
    HTMLOutput -.-> Browser
    FileUtil --> DelvelinScan
    DelvelinLog --> DelvelinScan
    SourceSet --> DelvelinScan

    %% Click Events
    click Delvelin "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/Delvelin.java"
    click DelvelinScan "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/DelvelinScan.java"
    click BaseDetector "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/BaseDetector.java"
    click SQLInjection "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/SQLInjectionDetector.java"
    click XSS "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/XSSDetector.java"
    click CmdInjection "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/CmdInjectionDetector.java"
    click NonThreadSafe "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/NonThreadSafeDetector.java"
    click NonAtomic "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/NonAtomicDetector.java"
    click WeakCrypto "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/cwedetectors/WeakCryptographicDetector.java"
    click OsvDetector "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/osvdetector/OsvDetector.java"
    click OsvParser "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/osvdetector/OsvVulnerabilityParser.java"
    click Config "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/properties/Config.java"
    click OutputFormat "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/properties/OutputFileFormat.java"
    click HTMLOutput "https://github.com/hangga/delvelin/tree/main/src/main/resources/html"
    click Reports "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/utils/Reports.java"
    click FileUtil "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/utils/FileUtil.java"
    click DelvelinLog "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/utils/DelvelinLog.java"
    click SourceSet "https://github.com/hangga/delvelin/blob/main/src/main/java/io/github/hangga/delvelin/utils/SourceSet.java"
```
