# project-x-innovation/ns-gm architecture

> Architecture diagram of the GitHub repository project-x-innovation/ns-gm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/project-x-innovation/ns-gm
- Repository: https://github.com/project-x-innovation/ns-gm

## Overview

ns-gm is a NetSuite SuiteScript execution and log-retrieval CLI backed by a local HTTP proxy and a deployed NetSuite RESTlet. Users configure an OAuth profile, start the proxy, submit inline or file-based code (or request logs), and receive results in the CLI. The graph separates CLI command workflows, local proxy handling, authentication/transport, and NetSuite-side execution. The RESTlet implementation and several command implementations were not excerpted; those capabilities and relationships are included only where the README documents them.

Main entry points: [`src/cli.js`](https://github.com/project-x-innovation/ns-gm/blob/main/src/cli.js) (Command dispatcher), [`server/app.js`](https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js) (HTTP proxy), [`server/auth.js`](https://github.com/project-x-innovation/ns-gm/blob/main/server/auth.js) (RESTlet transport), [`src/commands/run.js`](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/run.js) (Run code)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_dispatcher["Command dispatcher<br/>[cli.js]"]
  node_setup["Interactive setup<br/>[setup.js]"]
  node_setupci["CI setup<br/>[setup-ci.js]"]
  node_profiles[("Profile store<br/>[profileStore.js]")]
  node_init["Start proxy<br/>[init.js]"]
  node_run["Run code<br/>[run.js]"]
  node_logs["Fetch logs<br/>[logs.js]"]
  node_env["Environment query<br/>[env.js]"]
  node_stop["Stop proxy<br/>[stop.js]"]
  node_help["CLI help<br/>[help.js]"]
  node_exitcodes["Exit handling<br/>[exitCodes.js]"]
end

subgraph group_proxy["Local proxy"]
  node_config["Proxy configuration<br/>[config.js]"]
  node_server["HTTP proxy<br/>[app.js]"]
  node_runroute["Code endpoint<br/>[app.js]"]
  node_logsroute["Logs endpoint<br/>[app.js]"]
end

subgraph group_auth["Authentication and transport"]
  node_oauth["OAuth token client<br/>[auth.js]"]
  node_restlettransport["RESTlet transport<br/>[auth.js]"]
end

subgraph group_netsuite["NetSuite service"]
  node_restlet["SuiteScript RESTlet<br/>[ns_gm_restlet.js]"]
  node_netsuite(("NetSuite account"))
  node_oauthservice(("OAuth service"))
end

node_user(("CLI user"))

node_user -->|"runs commands"| node_dispatcher
node_dispatcher -->|"dispatches"| node_setup
node_dispatcher -->|"dispatches"| node_setupci
node_dispatcher -->|"dispatches"| node_init
node_dispatcher -->|"dispatches"| node_run
node_dispatcher -->|"dispatches"| node_logs
node_dispatcher -->|"dispatches"| node_env
node_dispatcher -->|"dispatches"| node_stop
node_dispatcher -->|"dispatches"| node_help
node_setup -->|"reads and writes"| node_profiles
node_setupci -->|"updates"| node_profiles
node_init -->|"starts process"| node_server
node_run -->|"posts code"| node_server
node_logs -->|"posts filters"| node_server
node_run -->|"uses"| node_exitcodes
node_logs -->|"uses"| node_exitcodes
node_server -->|"reads port"| node_config
node_server -->|"reads active profile"| node_profiles
node_server -->|"routes request"| node_runroute
node_server -->|"routes request"| node_logsroute
node_runroute -->|"submits code"| node_restlettransport
node_logsroute -->|"requests logs"| node_restlettransport
node_restlettransport -->|"gets token"| node_oauth
node_oauth -->|"requests token"| node_oauthservice
node_restlettransport -->|"posts action"| node_restlet
node_restlet -->|"executes in"| node_netsuite
node_stop -.->|"stops service"| node_server

click node_dispatcher "https://github.com/project-x-innovation/ns-gm/blob/main/src/cli.js"
click node_setup "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/setup.js"
click node_setupci "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/setup-ci.js"
click node_profiles "https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/profileStore.js"
click node_init "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/init.js"
click node_run "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/run.js"
click node_logs "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/logs.js"
click node_env "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/env.js"
click node_stop "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/stop.js"
click node_help "https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/help.js"
click node_exitcodes "https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/exitCodes.js"
click node_config "https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/config.js"
click node_server "https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js"
click node_runroute "https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js"
click node_logsroute "https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js"
click node_oauth "https://github.com/project-x-innovation/ns-gm/blob/main/server/auth.js"
click node_restlettransport "https://github.com/project-x-innovation/ns-gm/blob/main/server/auth.js"
click node_restlet "https://github.com/project-x-innovation/ns-gm/blob/main/ns_gm_restlet.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dispatcher,node_setup,node_setupci,node_profiles,node_init,node_run,node_logs,node_env,node_stop,node_help,node_exitcodes,node_user toneBlue
class node_config,node_server,node_runroute,node_logsroute toneAmber
class node_oauth,node_restlettransport toneMint
class node_restlet,node_netsuite,node_oauthservice toneRose
```

## Components

### CLI workflows

- [Command dispatcher](https://github.com/project-x-innovation/ns-gm/blob/main/src/cli.js): `src/cli.js`
- [Interactive setup](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/setup.js): `src/commands/setup.js`
- [CI setup](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/setup-ci.js): `src/commands/setup-ci.js`
- [Profile store](https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/profileStore.js): `src/utils/profileStore.js`
- [Start proxy](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/init.js): `src/commands/init.js`
- [Run code](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/run.js): `src/commands/run.js`
- [Fetch logs](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/logs.js): `src/commands/logs.js`
- [Environment query](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/env.js): `src/commands/env.js`
- [Stop proxy](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/stop.js): `src/commands/stop.js`
- [CLI help](https://github.com/project-x-innovation/ns-gm/blob/main/src/commands/help.js): `src/commands/help.js`
- [Exit handling](https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/exitCodes.js): `src/utils/exitCodes.js`

### Local proxy

- [Proxy configuration](https://github.com/project-x-innovation/ns-gm/blob/main/src/utils/config.js): `src/utils/config.js`
- [HTTP proxy](https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js): `server/app.js`
- [Code endpoint](https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js): `server/app.js`
- [Logs endpoint](https://github.com/project-x-innovation/ns-gm/blob/main/server/app.js): `server/app.js`

### Authentication and transport

- [OAuth token client](https://github.com/project-x-innovation/ns-gm/blob/main/server/auth.js): `server/auth.js`
- [RESTlet transport](https://github.com/project-x-innovation/ns-gm/blob/main/server/auth.js): `server/auth.js`

### NetSuite service

- [SuiteScript RESTlet](https://github.com/project-x-innovation/ns-gm/blob/main/ns_gm_restlet.js): `ns_gm_restlet.js`
- **NetSuite account**
- **OAuth service**

### Other components

- **CLI user**

## Connections

- CLI user → Command dispatcher: runs commands (evidence: `README.md`)
- Command dispatcher → Interactive setup: dispatches (evidence: `src/cli.js`)
- Command dispatcher → CI setup: dispatches (evidence: `src/cli.js`)
- Command dispatcher → Start proxy: dispatches (evidence: `src/cli.js`)
- Command dispatcher → Run code: dispatches (evidence: `src/cli.js`)
- Command dispatcher → Fetch logs: dispatches (evidence: `src/cli.js`)
- Command dispatcher → Environment query: dispatches (evidence: `src/cli.js`)
- Command dispatcher → Stop proxy: dispatches (evidence: `src/cli.js`)
- Command dispatcher → CLI help: dispatches (evidence: `src/cli.js`)
- Interactive setup → Profile store: reads and writes (evidence: `src/commands/setup.js`)
- CI setup → Profile store: updates (evidence: `src/commands/setup-ci.js`)
- Start proxy → HTTP proxy: starts process (evidence: `src/commands/init.js`)
- Run code → HTTP proxy: posts code (evidence: `src/commands/run.js`)
- Fetch logs → HTTP proxy: posts filters (evidence: `src/commands/logs.js`)
- Run code → Exit handling: uses (evidence: `src/commands/run.js`)
- Fetch logs → Exit handling: uses (evidence: `src/commands/logs.js`)
- HTTP proxy → Proxy configuration: reads port (evidence: `server/app.js`)
- HTTP proxy → Profile store: reads active profile (evidence: `server/app.js`)
- HTTP proxy → Code endpoint: routes request (evidence: `server/app.js`)
- HTTP proxy → Logs endpoint: routes request (evidence: `server/app.js`)
- Code endpoint → RESTlet transport: submits code (evidence: `server/app.js`)
- Logs endpoint → RESTlet transport: requests logs (evidence: `server/app.js`)
- RESTlet transport → OAuth token client: gets token (evidence: `server/auth.js`)
- OAuth token client → OAuth service: requests token (evidence: `server/auth.js`)
- RESTlet transport → SuiteScript RESTlet: posts action (evidence: `server/auth.js`)
- SuiteScript RESTlet → NetSuite account: executes in (evidence: `README.md`)
- Stop proxy → HTTP proxy: stops service (evidence: `README.md`)
