# bazaarvoice/jolt architecture

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

- Interactive diagram: https://gitdiagram.com/bazaarvoice/jolt
- Repository: https://github.com/bazaarvoice/jolt

## Overview

##### Main Components

a. Core Transform Engine
- Main transform types (Shiftr, Defaultr, Removr, Sortr, CardinalityTransform)
- Transform interface as the base contract

b. Transform Chain System
- Chainr as the orchestrator
- How multiple transforms can be chained together
- ChainrBuilder and ChainrSpec components

c. Specification System
- How JSON specifications are processed
- SpecDriven interface connections
- Relationship with transform implementations

d. Common Utilities Layer
- JsonUtils and supporting classes
- Diffy for comparison operations
- Common path handling components

##### Component Relationships

- Input JSON → Transform Chain → Output JSON (main flow)
- JSON Specs → SpecDriven Transforms (configuration flow)
- Transform Chain → Individual Transforms (composition)
- Transforms → Common Utilities (dependency)

##### Architectural Patterns to Highlight

a. Chain of Responsibility
- How transforms are chained together
- Flow of data through the chain

b. Strategy Pattern
- How different transform implementations can be used
- Relationship between transforms and their specs

c. Builder Pattern
- ChainrBuilder's role in constructing transform chains

##### Implementation Details

Packages and their relationships:
**com.bazaarvoice.jolt**
- core transforms
- Shiftr
- Defaultr
- Removr
- Sortr
- CardinalityTransform
- chainr
- ChainrBuilder
- ChainrSpec
- common
- pathelement
- reference
- utils
- JsonUtils

##### External Interfaces

Integration points:
- JSON input/output interfaces
- Custom transform integration points
- CLI interface connection

##### Processing Flow

Main data flow:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input/Output
        Input[JSON Input]:::external
        Output[JSON Output]:::external
    end

    subgraph Transform_Chain
        Chainr["Chainr Orchestrator"]:::core
        ChainrBuilder["ChainrBuilder"]:::core
        ChainrSpec["ChainrSpec"]:::core
        
        Chainr --> ChainrBuilder
        ChainrBuilder --> ChainrSpec
    end
    click Chainr "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Chainr.java"
    click ChainrBuilder "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/chainr/ChainrBuilder.java"
    click ChainrSpec "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/chainr/spec/ChainrSpec.java"

    subgraph Core_Transforms
        Transform["Transform Interface"]:::interface
        SpecDriven["SpecDriven Interface"]:::interface
        BaseSpec["Base Spec"]:::core
        
        Shiftr["Shiftr"]:::transform
        Defaultr["Defaultr"]:::transform
        Removr["Removr"]:::transform
        Sortr["Sortr"]:::transform
        Cardinality["CardinalityTransform"]:::transform
        
        Transform --> Shiftr
        Transform --> Defaultr
        Transform --> Removr
        Transform --> Sortr
        Transform --> Cardinality
        
        SpecDriven --> BaseSpec
    end
    click Transform "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Transform.java"
    click SpecDriven "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/SpecDriven.java"
    click BaseSpec "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/common/spec/BaseSpec.java"
    click Shiftr "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Shiftr.java"
    click Defaultr "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Defaultr.java"
    click Removr "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Removr.java"
    click Sortr "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/Sortr.java"
    click Cardinality "https://github.com/bazaarvoice/jolt/blob/master/jolt-core/src/main/java/com/bazaarvoice/jolt/CardinalityTransform.java"

    subgraph Common_Utilities
        JsonUtils["JsonUtils"]:::utility
        Diffy["Diffy"]:::utility
        PathElements["Path Elements"]:::utility
        PathReference["Path Reference"]:::utility
    end
    click JsonUtils "https://github.com/bazaarvoice/jolt/blob/master/json-utils/src/main/java/com/bazaarvoice/jolt/JsonUtils.java"
    click Diffy "https://github.com/bazaarvoice/jolt/blob/master/json-utils/src/main/java/com/bazaarvoice/jolt/Diffy.java"
    click PathElements "https://github.com/bazaarvoice/jolt/tree/master/jolt-core/src/main/java/com/bazaarvoice/jolt/common/pathelement/"
    click PathReference "https://github.com/bazaarvoice/jolt/tree/master/jolt-core/src/main/java/com/bazaarvoice/jolt/common/reference/"

    subgraph CLI
        JoltCli["Jolt CLI"]:::interface
    end
    click JoltCli "https://github.com/bazaarvoice/jolt/blob/master/cli/src/main/java/com/bazaarvoice/jolt/JoltCli.java"

    Input --> Chainr
    Chainr --> Output
    
    Chainr --> Transform
    Transform --> Common_Utilities
    SpecDriven --> Transform
    
    JoltCli --> Chainr

    classDef core fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef transform fill:#99ccff,stroke:#333,stroke-width:2px
    classDef interface fill:#ffeb99,stroke:#333,stroke-width:2px
    classDef utility fill:#99ff99,stroke:#333,stroke-width:2px
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:2px

    subgraph Legend
        L1[Core Components]:::core
        L2[Transforms]:::transform
        L3[Interfaces]:::interface
        L4[Utilities]:::utility
        L5[External]:::external
    end
```
