# pzehle/sheets-to-hubspot architecture

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

- Interactive diagram: https://gitdiagram.com/pzehle/sheets-to-hubspot
- Repository: https://github.com/pzehle/sheets-to-hubspot

## Overview

##### Main Components
- Google Sheets Environment: This is where the trigger lives. The script located in scripts/webhook-script.js is meant to be added as a function in the Google Sheets environment (likely via Apps Script) and is set up as a trigger that fires when a row changes.
- HubSpot API: The external service that receives the contact note created by the integration.

##### Relationships and Data Flow
- A change in the Google Sheet (new/updated row) triggers the script in the Google Sheets environment (scripts/webhook-script.js).
- The webhook-script function then calls the Node.js function (either index.js or index.axios.js) to process the data.
- The Node.js component sends the formatted data as a contact's note to HubSpot via the HubSpot API, using one of the two methods available in the project.

##### Architectural Patterns/Design Principles
- Integration / Triggered Workflow: The project is event-driven where the Google Sheets trigger drives the integration workflow.
- Alternative Implementation: By providing two versions of the Node.js integration (client-based vs. axios), the design supports flexibility and can be used to compare performance or ease of use.
- Separation of Concerns: Dividing the trigger logic (in the sheets script) and the processing/communication logic (in index.js/index.axios.js) helps in managing modularity.

##### Relevant Technologies
- Google Sheets (Apps Script) for the data trigger.
- Node.js for the server-side integration logic.
- HubSpot API for external communication.
- Axios (HTTP client library) and the HubSpot Node.js API client library as part of the integration logic.

- If necessary, add annotations to indicate that two alternative implementation paths (using HubSpot Node.js API client vs. using axios) exist within the Node.js component.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    gsTrigger["Google Sheets Trigger"]:::trigger
    choice["Choose Implementation"]:::decision
    hubspotClient["Node.js Integration (HubSpot API Client)"]:::internal
    axiosIntegration["Node.js Integration (Axios)"]:::internal
    merge["Merge Outputs"]:::internal
    hubspotAPI["HubSpot API"]:::external

    gsTrigger -->|"triggers"| choice
    choice -->|"option"| hubspotClient
    choice -->|"option"| axiosIntegration
    hubspotClient -->|"sendsNote"| merge
    axiosIntegration -->|"sendsNote"| merge
    merge -->|"update"| hubspotAPI

    click gsTrigger "https://github.com/pzehle/sheets-to-hubspot/blob/main/scripts/webhook-script.js"
    click hubspotClient "https://github.com/pzehle/sheets-to-hubspot/blob/main/index.js"
    click axiosIntegration "https://github.com/pzehle/sheets-to-hubspot/blob/main/index.axios.js"

    classDef trigger fill:#a8dadc,stroke:#1d3557,stroke-width:2px
    classDef decision fill:#ffdd57,stroke:#f4a261,stroke-width:2px
    classDef internal fill:#f1faee,stroke:#457b9d,stroke-width:2px
    classDef external fill:#e63946,stroke:#a8dadc,stroke-width:2px
```
