# lennonkc/netsuiteai architecture

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

- Interactive diagram: https://gitdiagram.com/lennonkc/netsuiteai
- Repository: https://github.com/lennonkc/netsuiteai

## Overview

##### Project type and purpose
- This is a Node.js‐based backend integration tool (not a full “frontend/backend” app).
- Purpose: automate data flows between spreadsheets (XLSX/JSON/HTML) and a NetSuite instance for Thrasio’s sourcing and vendor processes.

##### File structure
- Top‐level:
- config/config.js – holds environment or NetSuite API credentials.
- package.json, package-lock.json – npm project metadata and dependencies.
- src/index.js – entry point; orchestrates the workflow.
- src/services:
- SourcePO.js – service for sourcing purchase orders.
- fullSourcing.js – orchestrates a complete sourcing run.
- vendorID.js – fetches or resolves vendor IDs.
- src/utils:
- netsuite_GetSearch.js – wraps NetSuite search API calls.
- xlsxToJson.js – parses incoming XLSX sheets into JSON objects.
- xlsxGenerator.js – builds XLSX outputs.
- htmlGenerator.js – produces HTML reports.
- 示例响应.json – sample response used for testing or offline processing.

##### README
- Very brief: “用于搭建为Thrasio设计的Netsuite项目.”
- Confirms integration with NetSuite and custom workflows to support Thrasio’s sourcing.

a. Main components
- “Orchestrator” (src/index.js)
- Service modules (SourcePO, fullSourcing, vendorID)
- Utility modules (NetSuite API wrapper, XLSX parser/generator, HTML generator)
- External systems:
- NetSuite SuiteTalk/WebServices API
- File storage (local or cloud for XLSX/JSON files)
- (Optional) Email or dashboard consuming HTML reports
b. Relationships & interactions
- Orchestrator invokes service modules in sequence.
- Each service calls netSuite_GetSearch to retrieve data.
- XLSX input → xlsxToJson → service logic → xlsxGenerator / htmlGenerator → output storage.
- Data/config flows from config module into every component.
c. Architectural patterns
- Modular layering: entry‐point → services → utilities → external systems.
- Single‐responsibility for each module.
- Clear separation between business logic (services) and I/O concerns (utils).
d. Technologies/frameworks
- Node.js runtime
- npm modules (xlsx, netsuite SDK or SOAP client)
- JavaScript ES modules or CommonJS

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Entry & Config"
    Orchestrator["Orchestrator<br/>(index.js)"]:::orchestrator
    Config["Config<br/>(config/config.js)"]:::orchestrator
  end

  subgraph "Services"
    FullSourcing["Service: fullSourcing<br/>(src/services/fullSourcing.js)"]:::service
    SourcePO["Service: SourcePO<br/>(src/services/SourcePO.js)"]:::service
    VendorID["Service: vendorID<br/>(src/services/vendorID.js)"]:::service
  end

  subgraph "Utilities"
    NSSearch["Util: netsuite_GetSearch<br/>(src/utils/netsuite_GetSearch.js)"]:::util
    XLSXToJson["Util: xlsxToJson<br/>(src/utils/xlsxToJson.js)"]:::util
    XLSXGen["Util: xlsxGenerator<br/>(src/utils/xlsxGenerator.js)"]:::util
    HTMLGen["Util: htmlGenerator<br/>(src/utils/htmlGenerator.js)"]:::util
  end

  subgraph "External Systems"
    NetSuiteAPI["NetSuite API"]:::external
    FileStorage["File Storage<br/>(XLSX/JSON/HTML)"]:::external
    EmailDash["Email/Dashboard"]:::external
  end

  subgraph "Resources"
    SampleResp["Sample Response<br/>(示例响应.json)"]:::external
    PackageJson["package.json"]:::external
  end

  Config --> Orchestrator
  Config --> FullSourcing
  Config --> SourcePO
  Config --> VendorID

  Orchestrator --> FullSourcing
  Orchestrator --> SourcePO
  Orchestrator --> VendorID
  Orchestrator --> XLSXToJson
  FileStorage --> XLSXToJson

  XLSXToJson --> FullSourcing
  FullSourcing --> NSSearch
  SourcePO --> NSSearch
  VendorID --> NSSearch
  NSSearch --> NetSuiteAPI

  FullSourcing --> XLSXGen
  FullSourcing --> HTMLGen
  XLSXGen --> FileStorage
  HTMLGen --> FileStorage

  SampleResp -.-> NSSearch

  click Orchestrator "https://github.com/lennonkc/netsuiteai/blob/main/src/index.js"
  click Config "https://github.com/lennonkc/netsuiteai/blob/main/config/config.js"
  click SourcePO "https://github.com/lennonkc/netsuiteai/blob/main/src/services/SourcePO.js"
  click FullSourcing "https://github.com/lennonkc/netsuiteai/blob/main/src/services/fullSourcing.js"
  click VendorID "https://github.com/lennonkc/netsuiteai/blob/main/src/services/vendorID.js"
  click NSSearch "https://github.com/lennonkc/netsuiteai/blob/main/src/utils/netsuite_GetSearch.js"
  click XLSXToJson "https://github.com/lennonkc/netsuiteai/blob/main/src/utils/xlsxToJson.js"
  click XLSXGen "https://github.com/lennonkc/netsuiteai/blob/main/src/utils/xlsxGenerator.js"
  click HTMLGen "https://github.com/lennonkc/netsuiteai/blob/main/src/utils/htmlGenerator.js"
  click SampleResp "https://github.com/lennonkc/netsuiteai/blob/main/示例响应.json"
  click PackageJson "https://github.com/lennonkc/netsuiteai/blob/main/package.json"

  classDef orchestrator fill:#f9f,stroke:#333,stroke-width:2px
  classDef service fill:#bbf,stroke:#333,stroke-width:2px
  classDef util fill:#bfb,stroke:#333,stroke-width:2px
  classDef external fill:#fbb,stroke:#333,stroke-width:2px
```
