# yogeshs130/payflow architecture

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

- Interactive diagram: https://gitdiagram.com/yogeshs130/payflow
- Repository: https://github.com/yogeshs130/payflow

## Overview

PayFlow Copilot turns a seller’s plain-language order into an editable payment draft, then creates and captures a PayPal Sandbox payment after seller approval. The browser owns review and checkout callbacks; the Node backend owns parsing, validation, credentials, and PayPal API calls. The shared cents helper supports both browser totals and server-side price checks. The README documents the intended end-to-end flow; sampled source confirms the browser requests and backend integrations. This is a Sandbox prototype, not a production payment system.

Main entry points: [`public/app.js`](https://github.com/yogeshs130/payflow/blob/main/public/app.js) (Browser Workflow), [`server.mjs`](https://github.com/yogeshs130/payflow/blob/main/server.mjs) (Order Creation), [`public/money.js`](https://github.com/yogeshs130/payflow/blob/main/public/money.js) (Cents Conversion), [`public/index.html`](https://github.com/yogeshs130/payflow/blob/main/public/index.html) (Order Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Seller Interface"]
  node_page["Order Page<br/>[index.html]"]
  node_workflow["Browser Workflow<br/>[app.js]"]
end

subgraph group_backend["Order Backend"]
  node_parse["Order Parsing<br/>[server.mjs]"]
  node_config["PayPal Config<br/>[server.mjs]"]
  node_create["Order Creation<br/>[server.mjs]"]
  node_capture["Payment Capture<br/>[server.mjs]"]
  node_auth["PayPal Authentication<br/>[server.mjs]"]
end

subgraph group_money["Money Handling"]
  node_money["Cents Conversion<br/>[money.js]"]
end

subgraph group_integrations["External Services"]
  node_gemini["Gemini API"]
  node_sdk["PayPal JS SDK"]
  node_paypal["PayPal Sandbox API"]
end

node_seller(("Seller"))

node_seller -->|"enters order"| node_page
node_page -->|"hosts workflow"| node_workflow
node_workflow -->|"requests draft"| node_parse
node_parse -->|"requests extraction"| node_gemini
node_gemini -->|"returns draft data"| node_parse
node_parse -->|"validates price"| node_money
node_parse -->|"returns draft"| node_workflow
node_workflow -->|"rounds total"| node_money
node_workflow -->|"fetches client ID"| node_config
node_config -->|"returns client ID"| node_workflow
node_workflow -->|"loads and renders"| node_sdk
node_sdk -->|"signals approval"| node_workflow
node_workflow -->|"requests order"| node_create
node_create -->|"validates price"| node_money
node_create -->|"gets token"| node_auth
node_auth -->|"requests token"| node_paypal
node_create -->|"creates Sandbox order"| node_paypal
node_paypal -->|"returns order ID"| node_create
node_create -->|"returns order ID"| node_workflow
node_workflow -->|"requests capture"| node_capture
node_capture -->|"gets token"| node_auth
node_capture -->|"captures payment"| node_paypal
node_paypal -->|"returns payment status"| node_capture
node_capture -->|"returns result"| node_workflow

click node_page "https://github.com/yogeshs130/payflow/blob/main/public/index.html"
click node_workflow "https://github.com/yogeshs130/payflow/blob/main/public/app.js"
click node_parse "https://github.com/yogeshs130/payflow/blob/main/server.mjs"
click node_config "https://github.com/yogeshs130/payflow/blob/main/server.mjs"
click node_create "https://github.com/yogeshs130/payflow/blob/main/server.mjs"
click node_capture "https://github.com/yogeshs130/payflow/blob/main/server.mjs"
click node_auth "https://github.com/yogeshs130/payflow/blob/main/server.mjs"
click node_money "https://github.com/yogeshs130/payflow/blob/main/public/money.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_page,node_workflow toneBlue
class node_parse,node_config,node_create,node_capture,node_auth toneAmber
class node_money toneMint
class node_gemini,node_sdk,node_paypal toneRose
class node_seller toneIndigo
```

## Components

### Seller Interface

- [Order Page](https://github.com/yogeshs130/payflow/blob/main/public/index.html): `public/index.html`
- [Browser Workflow](https://github.com/yogeshs130/payflow/blob/main/public/app.js): `public/app.js`

### Order Backend

- [Order Parsing](https://github.com/yogeshs130/payflow/blob/main/server.mjs): `server.mjs`
- [PayPal Config](https://github.com/yogeshs130/payflow/blob/main/server.mjs): `server.mjs`
- [Order Creation](https://github.com/yogeshs130/payflow/blob/main/server.mjs): `server.mjs`
- [Payment Capture](https://github.com/yogeshs130/payflow/blob/main/server.mjs): `server.mjs`
- [PayPal Authentication](https://github.com/yogeshs130/payflow/blob/main/server.mjs): `server.mjs`

### Money Handling

- [Cents Conversion](https://github.com/yogeshs130/payflow/blob/main/public/money.js): `public/money.js`

### External Services

- **Gemini API**
- **PayPal JS SDK**
- **PayPal Sandbox API**

### Other components

- **Seller**

## Connections

- Seller → Order Page: enters order (evidence: `README.md`)
- Order Page → Browser Workflow: hosts workflow (evidence: `README.md`)
- Browser Workflow → Order Parsing: requests draft (evidence: `public/app.js`)
- Order Parsing → Gemini API: requests extraction (evidence: `server.mjs`)
- Gemini API → Order Parsing: returns draft data (evidence: `server.mjs`)
- Order Parsing → Cents Conversion: validates price (evidence: `server.mjs`)
- Order Parsing → Browser Workflow: returns draft (evidence: `public/app.js`)
- Browser Workflow → Cents Conversion: rounds total (evidence: `public/app.js`)
- Browser Workflow → PayPal Config: fetches client ID (evidence: `public/app.js`)
- PayPal Config → Browser Workflow: returns client ID (evidence: `README.md`)
- Browser Workflow → PayPal JS SDK: loads and renders (evidence: `public/app.js`)
- PayPal JS SDK → Browser Workflow: signals approval (evidence: `public/app.js`)
- Browser Workflow → Order Creation: requests order (evidence: `public/app.js`)
- Order Creation → Cents Conversion: validates price (evidence: `server.mjs`)
- Order Creation → PayPal Authentication: gets token (evidence: `server.mjs`)
- PayPal Authentication → PayPal Sandbox API: requests token (evidence: `server.mjs`)
- Order Creation → PayPal Sandbox API: creates Sandbox order (evidence: `README.md`)
- PayPal Sandbox API → Order Creation: returns order ID (evidence: `README.md`)
- Order Creation → Browser Workflow: returns order ID (evidence: `public/app.js`)
- Browser Workflow → Payment Capture: requests capture (evidence: `public/app.js`)
- Payment Capture → PayPal Authentication: gets token (evidence: `server.mjs`)
- Payment Capture → PayPal Sandbox API: captures payment (evidence: `README.md`)
- PayPal Sandbox API → Payment Capture: returns payment status (evidence: `README.md`)
- Payment Capture → Browser Workflow: returns result (evidence: `public/app.js`)
