# jenkinsci/templating-engine-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/jenkinsci/templating-engine-plugin
- Repository: https://github.com/jenkinsci/templating-engine-plugin

## Overview

##### Main Components

a. Core Components:
- Pipeline Template Engine
- Configuration Management System
- Library Management System
- Primitive Management System
- Governance Tier System

b. Integration Points:
- Jenkins Core Integration
- SCM Systems
- Pipeline Job Types

##### Job Layer
- AdHocTemplateFlowDefinition
- MultibranchTemplateFlowDefinition
- TemplateBranchProjectFactory

##### Governance Layer
- GovernanceTier
- Configuration Providers
- Library Providers

##### Pipeline Initialization Layer
- Template Resolution
- Configuration Aggregation
- Primitive Injection
- Template Compilation

##### Runtime Layer
- Step Execution
- Lifecycle Hooks
- Template Binding

##### Design Elements

Use the following visual elements:
- Rectangles: Main components and modules
- Diamonds: Decision points
- Blue: Core JTE components
- Green: External integrations
- Yellow: Configuration elements
- Orange: Runtime components

##### Key Relationships

**[Jenkins Core] --> [JTE Plugin]**

- v
**[Governance Tier]**

- > [Pipeline Template Resolution]

- > [Configuration Management]

- > [Library Resolution]

- v
**[Pipeline Initialization]**

- > [Template Compilation]

- > [Primitive Injection]

- > [Step Resolution]

- v
**[Runtime Execution]**

- > [Lifecycle Hooks]
- > [Step Execution]
- > [Template Binding]

##### Implementation Details

- How the Template Method pattern is implemented
- Configuration hierarchy
- Demonstrate library resolution flow
- Primitive injection points
- Hook execution points

Create distinct sections for:
- Pipeline Definition
- Governance & Configuration
- Library Management
- Runtime Execution
- Extension Points

Remember to maintain a balance between detail and clarity, focusing on the architectural relationships that make JTE unique while avoiding overwhelming technical implementation details.

This system design should help developers understand both the high-level architecture and the specific components that enable JTE's template-based pipeline execution model.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Jenkins
        JC[Jenkins Core]
    end

    subgraph "Job Layer"
        JL[Job Layer]:::job
        PJ["Pipeline Job Types"]:::job
        MB["Multibranch Support"]:::job
        
        JL --> PJ
        JL --> MB
    end

    subgraph "Governance Layer"
        GT["Governance Tier"]:::governance
        CP["Configuration Providers"]:::governance
        LP["Library Providers"]:::governance
        
        GT --> CP
        GT --> LP
    end

    subgraph "Pipeline Initialization"
        TR["Template Resolution"]:::init
        CA["Configuration Aggregation"]:::init
        TC["Template Compilation"]:::init
        
        TR --> CA
        CA --> TC
    end

    subgraph "Primitive Management"
        PI["Primitive Injection"]:::primitive
        CP1["Core Primitives"]:::primitive
        LH["Lifecycle Hooks"]:::primitive
        
        PI --> CP1
        PI --> LH
    end

    subgraph "Library Management"
        LMS["Library Management System"]:::library
        LPR["Library Provider"]:::library
        SCM["SCM Library Support"]:::library
        PLS["Plugin Library Support"]:::library
        
        LMS --> LPR
        LPR --> SCM
        LPR --> PLS
    end

    subgraph "Runtime Layer"
        SE["Step Execution"]:::runtime
        TB["Template Binding"]:::runtime
        
        SE --> TB
    end

    JC --> JL
    JL --> GT
    GT --> TR
    TR --> PI
    PI --> SE

    %% Component Mappings
    click JL "https://github.com/jenkinsci/templating-engine-plugin/tree/main/src/main/groovy/org/boozallen/plugins/jte/job/"
    click PJ "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/job/TemplateFlowDefinition.groovy"
    click MB "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/job/MultibranchTemplateFlowDefinition.groovy"
    click GT "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/GovernanceTier.groovy"
    click CP "https://github.com/jenkinsci/templating-engine-plugin/tree/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/config/"
    click LP "https://github.com/jenkinsci/templating-engine-plugin/tree/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/libs/"
    click TR "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/PipelineTemplateResolver.groovy"
    click CA "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/PipelineConfigurationAggregator.groovy"
    click TC "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/PipelineTemplateCompiler.groovy"
    click PI "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/primitives/TemplatePrimitiveInjector.groovy"
    click CP1 "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/primitives/TemplatePrimitive.groovy"
    click LH "https://github.com/jenkinsci/templating-engine-plugin/tree/main/src/main/groovy/org/boozallen/plugins/jte/init/primitives/hooks/"
    click LMS "https://github.com/jenkinsci/templating-engine-plugin/tree/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/libs/"
    click LPR "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/libs/LibraryProvider.groovy"
    click SCM "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/libs/ScmLibraryProvider.groovy"
    click PLS "https://github.com/jenkinsci/templating-engine-plugin/blob/main/src/main/groovy/org/boozallen/plugins/jte/init/governance/libs/PluginLibraryProvider.groovy"

    %% Styling
    classDef default fill:#fff,stroke:#333,stroke-width:2px;
    classDef job fill:#3498db,stroke:#2980b9,color:#fff;
    classDef governance fill:#2ecc71,stroke:#27ae60,color:#fff;
    classDef init fill:#e74c3c,stroke:#c0392b,color:#fff;
    classDef primitive fill:#f1c40f,stroke:#f39c12,color:#333;
    classDef library fill:#9b59b6,stroke:#8e44ad,color:#fff;
    classDef runtime fill:#e67e22,stroke:#d35400,color:#fff;
```
