# deepakkasundra/gas-github architecture

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

- Interactive diagram: https://gitdiagram.com/deepakkasundra/gas-github
- Repository: https://github.com/deepakkasundra/gas-github

## Overview

##### Project type and purpose
- This is a small Node.js CLI utility (an open-source tool) whose sole responsibility is to automate the flow of:
- Cloning a Google Apps Script project (via Google’s clasp CLI)
- Sanitizing sensitive content (optional)
- Copying files into a local Git repo directory
- Performing Git operations to push to a GitHub remote
- Logging all steps

##### File structure
- Top level:
- GAS-Git.js (core script)
- README.md (documentation)
- No subdirectories except those created at runtime:
- ./temp-clasp (for clasp clone)
- Destination folder (e.g., D:/AppScripts/CM) for the Git repo
- SanitizingOutput.txt (log file)

##### Extract architectural insights from README
- External dependencies: Node.js, npm, @google/clasp, git CLI
- Runtime interactions with: Google Apps Script servers, local filesystem, GitHub
- Main phases: Prompt → clone → sanitize → copy → git commit/push → log

##### Main components & relationships
a. User CLI
- Initiates the script, provides Script ID, sanitization flag, and GitHub URL
b. Node.js Process (GAS-Git.js)
- Orchestrator that invokes all modules/functions
c. clasp CLI
- Subprocess calls to pull down the GAS project into ./temp-clasp
d. Sanitization Module
- In-memory transformation of source files to scrub domains/API paths
e. Local Filesystem
- ./temp-clasp (input)
- Destination Git folder (staging area for cleaned files)
- SanitizingOutput.txt (log)
f. Git CLI & GitHub
- Local Git: add, commit, rebase, push
- Remote GitHub: final destination of cleaned code

##### Architectural patterns & design principles
- Single-entry orchestrator (linear workflow)
- Modular subprocess calls (clasp, git)
- Separation of concerns:
- Input gathering (CLI)
- Data retrieval (clasp clone)
- Data processing (sanitization)
- Data deployment (Git commit/push)
- Logging & error handling

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    CLI["User CLI"]:::process
    README["README.md"]:::storage

    %% Local Processes
    Orchestrator["Node.js Orchestrator"]:::process
    Clasp["clasp CLI"]:::process
    Sanitizer["Sanitization Module"]:::process
    GitCLI["Git CLI"]:::process

    %% External Services
    GASAPI["Google Apps Script API"]:::external
    GitHub["GitHub Remote"]:::external

    %% Storage
    Temp["./temp-clasp"]:::storage
    Repo["Destination Git Repo Folder"]:::storage
    Log["SanitizingOutput.txt"]:::storage

    %% Workflow
    CLI -->|"starts"| Orchestrator
    Orchestrator -->|"clasp clone"| Clasp
    Clasp -->|"fetch project"| GASAPI
    GASAPI -->|"deliver files"| Temp
    Orchestrator -.->|"sanitize files (optional)"| Sanitizer
    Sanitizer -->|"logs sanitization"| Log
    Sanitizer -->|"output cleaned files"| Repo
    Orchestrator -->|"copy files"| Repo
    Orchestrator -->|"git operations"| GitCLI
    GitCLI -->|"push code"| GitHub
    GitCLI -->|"logs operations"| Log
    Orchestrator -->|"error logs"| Log

    %% Click Events
    click CLI "https://github.com/deepakkasundra/gas-github/blob/main/GAS-Git.js"
    click Orchestrator "https://github.com/deepakkasundra/gas-github/blob/main/GAS-Git.js"
    click Clasp "https://github.com/deepakkasundra/gas-github/blob/main/GAS-Git.js"
    click Sanitizer "https://github.com/deepakkasundra/gas-github/blob/main/GAS-Git.js"
    click Temp "https://github.com/deepakkasundra/gas-github/tree/main/./temp-clasp"
    click Repo "https://github.com/deepakkasundra/gas-github/tree/main/Destination Git repo folder"
    click Log "https://github.com/deepakkasundra/gas-github/blob/main/SanitizingOutput.txt"
    click README "https://github.com/deepakkasundra/gas-github/blob/main/README.md"

    %% Styles
    classDef process fill:#9f6,stroke:#333,color:#000
    classDef external fill:#6cf,stroke:#333,color:#000
    classDef storage fill:#fc6,stroke:#333,color:#000
```
