# node-gradle/gradle-node-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/node-gradle/gradle-node-plugin
- Repository: https://github.com/node-gradle/gradle-node-plugin

## Overview

##### Main Components

a. Core Plugin Components:
- NodePlugin (Main entry point)
- NodeExtension (Configuration)
- PackageJsonExtension (Package.json handling)

b. Package Manager Integration Modules:
- npm Module
- Yarn Module
- pnpm Module
- Bun Module

c. Execution Components:
- Task System
- Exec Runners
- Platform Helpers

**Rectangle: Core Components**
**Hexagon: Package Managers**

- [External Tools]
- ┌──────────────┐
- Node.js    │
- npm      │
- Yarn      │
- pnpm      │
- Bun      │
- ┘
- ▲

**┌─────────────────────────────────────────┼─────────────────────────────────┐**

- Gradle Node Plugin                          │

- ┌─────────────────┐           ┌───────┴──────────┐                      │
- Core Plugin    │           │   Exec System     │                      │
- ┌───────────┐   │           │ ┌──────────────┐ │      ┌────────────┐  │
- NodePlugin │◄──┼──────────►│ │ ExecRunner   │ │      │Platform    │  │
- ┘   │           │ └──────────────┘ │      │Helpers     │  │
- ┌───────────┐   │           │ ┌──────────────┐ │      │┌─────────┐ │  │
- Extensions │   │           │ │NodeExecRunner│ │      ││Platform │ │  │
- ┘   │           │ └──────────────┘ │      │└─────────┘ │  │
- ┘           └─────────────────┘       └────────────┘  │
- ▲                                  │

- ┌─────────────────────────────────────┴─────────────────────────────┐   │
- Package Manager Modules                        │   │
- ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐    │   │
- npm    │    │   Yarn   │    │   pnpm   │    │   Bun    │    │   │
- Module  │    │  Module  │    │  Module  │    │  Module  │    │   │
- ┘    └──────────┘    └──────────┘    └──────────┘    │   │
- ┘   │

- ┘

##### Key Elements to Highlight

- Clear separation between the plugin's internal components and external tools
- Plugin's role as a bridge between Gradle and Node.js ecosystem
- Modular nature of package manager support
- Execution flow from Gradle tasks through the exec system to external tools

##### Important Relationships

- NodePlugin's central role in coordinating all components
- Package manager modules' dependency on the exec system
- Platform helpers' support for cross-platform compatibility
- Extension configuration flow to tasks and execution

##### Additional Notes

- Version compatibility information (Gradle 6.6+, Node.js 10+)
- Optional nature of different package managers
- Configuration points for proxy settings and environment variables

##### Implementation Details

- Brief annotations for key interaction points

- How the plugin integrates with Gradle
- The flow of execution from Gradle tasks to Node.js tools
- The modular architecture supporting different package managers
- Cross-platform support implementation
- Configuration and extension points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333
    classDef package fill:#90EE90,stroke:#333
    classDef exec fill:#FFB366,stroke:#333
    classDef external fill:#E0E0E0,stroke:#333
    
    %% External Tools
    subgraph ExternalTools["External Tools"]
        Node["Node.js"]:::external
        NPM["npm"]:::external
        Yarn["Yarn"]:::external
        PNPM["pnpm"]:::external
        Bun["Bun"]:::external
    end

    %% Core Plugin Section
    subgraph CorePlugin["Core Plugin"]
        NodePlugin["NodePlugin"]:::core
        NodeExt["NodeExtension"]:::core
        PackageExt["PackageJsonExtension"]:::core
    end

    %% Execution System
    subgraph ExecSystem["Exec System"]
        ExecRunner["ExecRunner"]:::exec
        NodeExecRunner["NodeExecRunner"]:::exec
    end

    %% Platform Helpers
    subgraph Platform["Platform Helpers"]
        PlatformHelper["PlatformHelper"]:::exec
    end

    %% Task System
    subgraph Tasks["Task System"]
        BaseTask["BaseTask"]:::core
        NodeTask["NodeTask"]:::core
        NodeSetupTask["NodeSetupTask"]:::core
    end

    %% Package Manager Modules
    subgraph PackageManagers["Package Manager Modules"]
        NPMModule["npm Module"]:::package
        YarnModule["Yarn Module"]:::package
        PNPMModule["pnpm Module"]:::package
        BunModule["Bun Module"]:::package
    end

    %% Relationships
    NodePlugin --> NodeExt
    NodePlugin --> PackageExt
    NodePlugin --> ExecSystem
    ExecSystem --> ExternalTools
    NodeExecRunner --> Node
    ExecRunner --> NodeExecRunner
    PackageManagers --> ExecSystem
    Tasks --> ExecSystem
    ExecSystem --> PlatformHelper

    %% Click Events
    click NodePlugin "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/NodePlugin.kt"
    click NodeExt "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/NodeExtension.kt"
    click PackageExt "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/PackageJsonExtension.kt"
    click NPMModule "https://github.com/node-gradle/gradle-node-plugin/tree/main/src/main/kotlin/com/github/gradle/node/npm/"
    click YarnModule "https://github.com/node-gradle/gradle-node-plugin/tree/main/src/main/kotlin/com/github/gradle/node/yarn/"
    click PNPMModule "https://github.com/node-gradle/gradle-node-plugin/tree/main/src/main/kotlin/com/github/gradle/node/pnpm/"
    click BunModule "https://github.com/node-gradle/gradle-node-plugin/tree/main/src/main/kotlin/com/github/gradle/node/bun/"
    click ExecRunner "https://github.com/node-gradle/gradle-node-plugin/tree/main/src/main/kotlin/com/github/gradle/node/exec/"
    click NodeExecRunner "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/exec/NodeExecRunner.kt"
    click PlatformHelper "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/util/PlatformHelper.kt"
    click BaseTask "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/task/BaseTask.kt"
    click NodeTask "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/task/NodeTask.kt"
    click NodeSetupTask "https://github.com/node-gradle/gradle-node-plugin/blob/main/src/main/kotlin/com/github/gradle/node/task/NodeSetupTask.kt"
```
