# helloyug/noteflow architecture

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

- Interactive diagram: https://gitdiagram.com/helloyug/noteflow
- Repository: https://github.com/helloyug/noteflow

## Overview

1. **Overall shape**
   NoteFlow is a three-part system: a static frontend, a Google Apps Script backend, and Google Sheets/Drive as the data and file layer. The frontend never talks to Sheets directly; all product, order, and delivery actions go through the Apps Script web app.

2. **Frontend presentation layer**
   The UI is split into page-specific HTML files: `index.html` for the landing page, and `pages/notes.html`, `pages/buy.html`, and `pages/contact.html` for the storefront, purchase flow, and support page. Each page has its own CSS file under `assets/css/`, with `global.css` for shared styling and page files for layout-specific visuals.

3. **Client-side application modules**
   The behavior is organized into small vanilla-JS modules under `assets/js/`. `api.js` is the backend gateway, `config.js` holds deployment URLs, `utils.js` and `ui.js` provide shared helpers/rendering, `theme.js` manages dark/light mode persistence, `qr.js` generates UPI QR codes, and `notes.js`, `buy.js`, `home.js`, `contact.js`, and `filters.js` drive page-specific interactions.

4. **Catalog browsing flow**
   The notes storefront is driven by data fetched from Google Sheets via Apps Script. `notes.html` uses the JS modules to render cards, apply search/filtering, and sort results. The sheet-backed catalog is the primary content source, with `visible`, `featured`, `tags`, and date/price fields shaping what the user sees.

5. **Purchase flow**
   The buy page is the transaction hub. It reads the selected product’s data, shows note details, generates a UPI payment QR from the configured payee and amount, and collects buyer details plus a payment screenshot before submitting the order to the backend.

6. **Backend orchestration**
   `gas/Code.gs` is the serverless control plane. It exposes the web app endpoints used by the frontend, validates inputs, appends new orders, handles screenshot uploads, and reacts to admin edits in the sheet to trigger delivery actions. The backend also centralizes sanitization and quota checks.

7. **Google Sheets as CMS and order database**
   The spreadsheet is the operational source of truth. `notes_db` stores storefront content and product metadata, `orders` stores purchase records and verification state, and `config` stores runtime settings like UPI ID, delivery mode, email templates, support email, and Drive folder IDs. This makes the app mostly configuration-driven.

8. **Google Drive as secure file storage**
   Drive stores two sensitive file types: the premium PDFs for sale and buyer payment screenshots. PDFs remain restricted until an order is verified, while screenshots are uploaded into a private folder referenced by the `screenshots_folder_id` config value.

9. **Verification and delivery boundary**
   Order state changes are controlled manually in the `orders` sheet. When an admin marks a payment as verified, Apps Script detects the change and performs fulfillment based on config: email attachment delivery or Drive-based sharing. That means verification is the handoff between human review and automated delivery.

10. **Caching and quota protection**
    Because Apps Script has execution limits, the catalog payload is cached in `CacheService` and refreshed when the sheet changes. This creates a read-optimized path for storefront browsing, while write paths like order submission and delivery remain more controlled and quota-sensitive.

11. **Support/contact integration**
    The contact page is separate from the notes/order pipeline. It uses static contact details plus an external Formspree endpoint for message capture, so support traffic does not depend on the Sheets backend.

12. **Deployment model**
    The frontend is purely static and is designed to work with relative paths, so it can be hosted on GitHub Pages, Netlify, or similar platforms. The backend is deployed as a Google Apps Script web app, and `assets/js/config.js` is where the frontend is pointed at the live Apps Script URL.

13. **Operational focus**
    The repo is built around a “spreadsheet CMS + serverless fulfillment” pattern rather than a traditional app server. The key architectural boundary is: frontend for presentation and input, Sheets for editable business data, Apps Script for logic and automation, and Drive for protected file assets.

Main entry points: [`gas/Code.gs`](https://github.com/helloyug/noteflow/blob/main/gas/Code.gs) (Apps Script), [`pages/buy.html`](https://github.com/helloyug/noteflow/blob/main/pages/buy.html) (Buy page), [`assets/js/api.js`](https://github.com/helloyug/noteflow/blob/main/assets/js/api.js) (API gateway), [`pages/notes.html`](https://github.com/helloyug/noteflow/blob/main/pages/notes.html) (Notes shop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_index_html["Landing<br/>page<br/>[index.html]"]
  node_notes_html["Notes shop<br/>page<br/>[notes.html]"]
  node_buy_html["Buy page<br/>[buy.html]"]
  node_contact_html["Contact<br/>page<br/>[contact.html]"]
  node_global_css["Global CSS<br/>style<br/>[global.css]"]
  node_page_css["Page CSS<br/>style<br/>[notes.css]"]
  node_api_js["API gateway<br/>client module<br/>[api.js]"]
  node_ui_js["UI helpers<br/>client module<br/>[ui.js]"]
  node_notes_js["Catalog logic<br/>client module<br/>[notes.js]"]
  node_buy_js["Checkout logic<br/>client module<br/>[buy.js]"]
  node_contact_js["Contact logic<br/>client module<br/>[contact.js]"]
  node_theme_js["Theme mode<br/>client module<br/>[theme.js]"]
  node_qr_js["UPI QR<br/>client module<br/>[qr.js]"]
  node_config_js["Deployment config<br/>client module<br/>[config.js]"]
end

subgraph group_backend["Backend"]
  node_gas_code["Apps Script<br/>serverless backend<br/>[Code.gs]"]
end

subgraph group_data["Data layer"]
  node_notes_db[("Notes sheet")]
  node_orders_sheet[("Orders sheet")]
  node_config_sheet[("Config sheet")]
  node_drive_store[("Drive assets<br/>file store")]
end

subgraph group_external["External services"]
  node_formspree{{"Formspree<br/>external form endpoint"}}
end

node_index_html -->|"styles"| node_global_css
node_index_html -->|"theme"| node_theme_js
node_index_html -->|"ui"| node_ui_js
node_notes_html -->|"styles"| node_global_css
node_notes_html -->|"page styles"| node_page_css
node_notes_html -->|"data"| node_api_js
node_notes_html -->|"behavior"| node_notes_js
node_buy_html -->|"styles"| node_global_css
node_buy_html -->|"page styles"| node_page_css
node_buy_html -->|"data"| node_api_js
node_buy_html -->|"behavior"| node_buy_js
node_buy_html -->|"payment"| node_qr_js
node_contact_html -->|"styles"| node_global_css
node_contact_html -->|"page styles"| node_page_css
node_contact_html -->|"behavior"| node_contact_js
node_config_js -->|"endpoint"| node_gas_code
node_api_js -->|"requests"| node_gas_code
node_notes_js -->|"reads"| node_api_js
node_buy_js -->|"submits"| node_api_js
node_buy_js -->|"config"| node_config_js
node_notes_js -->|"renders"| node_ui_js
node_buy_js -->|"renders"| node_ui_js
node_contact_js -->|"messages"| node_formspree
node_gas_code -->|"catalog"| node_notes_db
node_gas_code -->|"orders"| node_orders_sheet
node_gas_code -->|"settings"| node_config_sheet
node_gas_code -->|"files"| node_drive_store
node_gas_code -.->|"verify"| node_orders_sheet
node_gas_code -.->|"deliver"| node_drive_store
node_notes_db -->|"catalog data"| node_notes_js
node_orders_sheet -->|"state"| node_gas_code
node_config_sheet -->|"runtime config"| node_gas_code

click node_index_html "https://github.com/helloyug/noteflow/blob/main/index.html"
click node_notes_html "https://github.com/helloyug/noteflow/blob/main/pages/notes.html"
click node_buy_html "https://github.com/helloyug/noteflow/blob/main/pages/buy.html"
click node_contact_html "https://github.com/helloyug/noteflow/blob/main/pages/contact.html"
click node_global_css "https://github.com/helloyug/noteflow/blob/main/assets/css/global.css"
click node_page_css "https://github.com/helloyug/noteflow/blob/main/assets/css/notes.css"
click node_api_js "https://github.com/helloyug/noteflow/blob/main/assets/js/api.js"
click node_ui_js "https://github.com/helloyug/noteflow/blob/main/assets/js/ui.js"
click node_notes_js "https://github.com/helloyug/noteflow/blob/main/assets/js/notes.js"
click node_buy_js "https://github.com/helloyug/noteflow/blob/main/assets/js/buy.js"
click node_contact_js "https://github.com/helloyug/noteflow/blob/main/assets/js/contact.js"
click node_theme_js "https://github.com/helloyug/noteflow/blob/main/assets/js/theme.js"
click node_qr_js "https://github.com/helloyug/noteflow/blob/main/assets/js/qr.js"
click node_config_js "https://github.com/helloyug/noteflow/blob/main/assets/js/config.js"
click node_gas_code "https://github.com/helloyug/noteflow/blob/main/gas/Code.gs"
click node_notes_db "https://github.com/helloyug/noteflow/blob/main/Project NoteFlow.xlsx"
click node_orders_sheet "https://github.com/helloyug/noteflow/blob/main/Project NoteFlow.xlsx"
click node_config_sheet "https://github.com/helloyug/noteflow/blob/main/Project NoteFlow.xlsx"

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_index_html,node_notes_html,node_buy_html,node_contact_html,node_global_css,node_page_css,node_api_js,node_ui_js,node_notes_js,node_buy_js,node_contact_js,node_theme_js,node_qr_js,node_config_js toneBlue
class node_gas_code toneAmber
class node_notes_db,node_orders_sheet,node_config_sheet,node_drive_store toneMint
class node_formspree toneRose
```

## Components

### Frontend

Static pages, styling, and client-side modules.

- [Landing](https://github.com/helloyug/noteflow/blob/main/index.html): page · Static entry page. · `index.html`
- [Notes shop](https://github.com/helloyug/noteflow/blob/main/pages/notes.html): page · Catalog browsing and filtering page. · `pages/notes.html`
- [Buy page](https://github.com/helloyug/noteflow/blob/main/pages/buy.html): page · Purchase and checkout page. · `pages/buy.html`
- [Contact](https://github.com/helloyug/noteflow/blob/main/pages/contact.html): page · Support and contact page. · `pages/contact.html`
- [Global CSS](https://github.com/helloyug/noteflow/blob/main/assets/css/global.css): style · Shared styling across pages. · `assets/css/global.css`
- [Page CSS](https://github.com/helloyug/noteflow/blob/main/assets/css/notes.css): style · Page-specific layout and visuals. · `assets/css/notes.css`
- [API gateway](https://github.com/helloyug/noteflow/blob/main/assets/js/api.js): client module · Frontend bridge to the Apps Script backend. · `assets/js/api.js`
- [UI helpers](https://github.com/helloyug/noteflow/blob/main/assets/js/ui.js): client module · Shared rendering and interface helpers. · `assets/js/ui.js`
- [Catalog logic](https://github.com/helloyug/noteflow/blob/main/assets/js/notes.js): client module · Loads, filters, sorts, and renders notes. · `assets/js/notes.js`
- [Checkout logic](https://github.com/helloyug/noteflow/blob/main/assets/js/buy.js): client module · Handles selected product and purchase flow. · `assets/js/buy.js`
- [Contact logic](https://github.com/helloyug/noteflow/blob/main/assets/js/contact.js): client module · Handles contact page interactions. · `assets/js/contact.js`
- [Theme mode](https://github.com/helloyug/noteflow/blob/main/assets/js/theme.js): client module · Manages dark/light theme persistence. · `assets/js/theme.js`
- [UPI QR](https://github.com/helloyug/noteflow/blob/main/assets/js/qr.js): client module · Generates payment QR codes. · `assets/js/qr.js`
- [Deployment config](https://github.com/helloyug/noteflow/blob/main/assets/js/config.js): client module · Holds backend URL and runtime settings. · `assets/js/config.js`

### Backend

Google Apps Script control plane and fulfillment logic.

- [Apps Script](https://github.com/helloyug/noteflow/blob/main/gas/Code.gs): serverless backend · Web app endpoints, validation, order handling, and fulfillment. · `gas/Code.gs`

### Data layer

Sheets and Drive-backed operational storage.

- [Notes sheet](https://github.com/helloyug/noteflow/blob/HEAD/Project%20NoteFlow.xlsx): sheet · Catalog content and product metadata. · `Project NoteFlow.xlsx`
- [Orders sheet](https://github.com/helloyug/noteflow/blob/HEAD/Project%20NoteFlow.xlsx): sheet · Purchase records and verification state. · `Project NoteFlow.xlsx`
- [Config sheet](https://github.com/helloyug/noteflow/blob/HEAD/Project%20NoteFlow.xlsx): sheet · Runtime settings, templates, and IDs. · `Project NoteFlow.xlsx`
- **Drive assets**: file store · Premium PDFs and uploaded payment screenshots.

### External services

Third-party endpoints and delivery channels.

- **Formspree**: external form endpoint · Captures contact messages outside the backend.

## Connections

- Landing → Global CSS: styles · Shared page styling.
- Landing → Theme mode: theme · Applies persistent theme mode.
- Landing → UI helpers: ui · Shared interface rendering.
- Notes shop → Global CSS: styles · Shared page styling.
- Notes shop → Page CSS: page styles · Catalog page visuals.
- Notes shop → API gateway: data · Fetches catalog data through backend.
- Notes shop → Catalog logic: behavior · Catalog browsing logic.
- Buy page → Global CSS: styles · Shared page styling.
- Buy page → Page CSS: page styles · Checkout page visuals.
- Buy page → API gateway: data · Submits order and fetches product data.
- Buy page → Checkout logic: behavior · Checkout flow logic.
- Buy page → UPI QR: payment · Builds UPI payment QR.
- Contact → Global CSS: styles · Shared page styling.
- Contact → Page CSS: page styles · Support page visuals.
- Contact → Contact logic: behavior · Contact form interactions.
- Deployment config → Apps Script: endpoint · Points the frontend at the live Apps Script web app.
- API gateway → Apps Script: requests · Backend gateway for catalog and orders.
- Catalog logic → API gateway: reads · Loads catalog data.
- Checkout logic → API gateway: submits · Sends order and verification data.
- Checkout logic → Deployment config: config · Uses deployment and payment settings.
- Catalog logic → UI helpers: renders · Uses shared UI helpers.
- Checkout logic → UI helpers: renders · Uses shared UI helpers.
- Contact logic → Formspree: messages · Sends support submissions externally.
- Apps Script → Notes sheet: catalog · Reads storefront content and metadata.
- Apps Script → Orders sheet: orders · Appends and updates purchase records.
- Apps Script → Config sheet: settings · Reads runtime configuration.
- Apps Script → Drive assets: files · Stores screenshots and serves protected PDFs.
- Apps Script → Orders sheet: verify · Detects admin verification changes.
- Apps Script → Drive assets: deliver · Shares attachments or file access after verification.
- Notes sheet → Catalog logic: catalog data · Source data for browse and filter UI.
- Orders sheet → Apps Script: state · Order verification boundary.
- Config sheet → Apps Script: runtime config · Delivery mode, templates, IDs, and UPI settings.
