# rayanfer32/userscripts architecture

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

- Interactive diagram: https://gitdiagram.com/rayanfer32/userscripts
- Repository: https://github.com/rayanfer32/userscripts

## Overview

This is a Google Photos userscript for sending selected photos to Telegram. The user clicks an injected button; the script reads or prompts for bot settings, collects selected photos, and runs a concurrent upload queue while showing progress. Uploading is implemented through Telegram’s Bot API; deleting originals is not implemented despite the script’s name. The single-file excerpt supports the UI, configuration, selection, and upload components, but omits queue-worker details, so their connections are left unverified.

Main entry points: [`google-photos-to-telegram.user.js`](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js) (Sync coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Page interface"]
  node_button["Sync button"]
  node_progress["Progress UI"]
end

subgraph group_workflow["Sync workflow"]
  node_main["Sync coordinator"]
  node_selection["Photo selection"]
  node_photo_fetch["Photo fetch"]
  node_upload_queue["Concurrent upload queue"]
  node_telegram_upload["Photo upload"]
end

subgraph group_settings["Configuration"]
  node_config["Bot configuration"]
end

node_user(("User"))
node_photos_page["Google Photos page"]
node_telegram["Telegram Bot API"]
node_userscript_storage[("Userscript storage")]

node_user -->|"clicks"| node_button
node_button -->|"starts"| node_main
node_main -->|"reads settings"| node_config
node_config -->|"reads and writes"| node_userscript_storage
node_main -->|"gets selected"| node_selection
node_selection -->|"reads selection"| node_photos_page
node_main -->|"updates"| node_progress
node_main -.->|"obtains photo blobs"| node_photo_fetch
node_photo_fetch -->|"fetches photos"| node_photos_page
node_main -.->|"dispatches jobs"| node_upload_queue
node_upload_queue -.->|"runs uploads"| node_telegram_upload
node_telegram_upload -->|"posts photo"| node_telegram

click node_button "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_progress "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_main "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_selection "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_photo_fetch "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_upload_queue "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_telegram_upload "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js"
click node_config "https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.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_button,node_progress,node_user toneBlue
class node_main,node_selection,node_photo_fetch,node_upload_queue,node_telegram_upload,node_userscript_storage toneAmber
class node_config,node_telegram toneMint
class node_photos_page toneIndigo
```

## Components

### Page interface

- [Sync button](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`
- [Progress UI](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`

### Sync workflow

- [Sync coordinator](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`
- [Photo selection](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`
- [Photo fetch](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`
- [Concurrent upload queue](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`
- [Photo upload](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`

### Configuration

- [Bot configuration](https://github.com/rayanfer32/userscripts/blob/main/google-photos-to-telegram.user.js): `google-photos-to-telegram.user.js`

### Other components

- **User**
- **Google Photos page**
- **Telegram Bot API**
- **Userscript storage**

## Connections

- User → Sync button: clicks (evidence: `google-photos-to-telegram.user.js`)
- Sync button → Sync coordinator: starts (evidence: `google-photos-to-telegram.user.js`)
- Sync coordinator → Bot configuration: reads settings (evidence: `google-photos-to-telegram.user.js`)
- Bot configuration → Userscript storage: reads and writes (evidence: `google-photos-to-telegram.user.js`)
- Sync coordinator → Photo selection: gets selected (evidence: `google-photos-to-telegram.user.js`)
- Photo selection → Google Photos page: reads selection (evidence: `google-photos-to-telegram.user.js`)
- Sync coordinator → Progress UI: updates (evidence: `google-photos-to-telegram.user.js`)
- Sync coordinator → Photo fetch: obtains photo blobs (evidence: `google-photos-to-telegram.user.js`)
- Photo fetch → Google Photos page: fetches photos (evidence: `google-photos-to-telegram.user.js`)
- Sync coordinator → Concurrent upload queue: dispatches jobs (evidence: `google-photos-to-telegram.user.js`)
- Concurrent upload queue → Photo upload: runs uploads (evidence: `google-photos-to-telegram.user.js`)
- Photo upload → Telegram Bot API: posts photo (evidence: `google-photos-to-telegram.user.js`)
