# yuukiofuyu/serverless-temp-file-sharing architecture

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

- Interactive diagram: https://gitdiagram.com/yuukiofuyu/serverless-temp-file-sharing
- Repository: https://github.com/yuukiofuyu/serverless-temp-file-sharing

## Overview

This Cloudflare Worker provides browser-based file sharing backed by Google Drive: users upload a file, receive a shareable result page with a QR code, and the file is removed after download. The sampled source shows request routing, page rendering, and the Drive upload helper obtaining an access token. README claims document the broader download-and-delete workflow; download internals were not sampled.

Main entry points: [`worker.js`](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js) (Request handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Worker routing"]
  node_worker["Request handler<br/>[worker.js]"]
end

subgraph group_sharing["Sharing experience"]
  node_upload_ui["Upload page<br/>[worker.js]"]
  node_result_ui["Share result<br/>[worker.js]"]
  node_qr["QR code<br/>[worker.js]"]
  node_download["File download<br/>[worker.js]"]
  node_expired_ui["Expired page<br/>[worker.js]"]
  node_not_found["Not-found pages<br/>[worker.js]"]
end

subgraph group_drive["Drive integration"]
  node_upload["Drive upload<br/>[worker.js]"]
  node_oauth["Access token<br/>[worker.js]"]
  node_google_api["Google Drive API"]
  node_drive_store[("Destination folder")]
end

node_user(("Visitor"))

node_user -->|"sends requests"| node_worker
node_worker -->|"renders root"| node_upload_ui
node_worker -->|"renders fallback"| node_not_found
node_worker -.->|"uploads file"| node_upload
node_upload -->|"gets token"| node_oauth
node_upload -->|"sends multipart upload"| node_google_api
node_google_api -->|"stores file"| node_drive_store
node_worker -.->|"shows upload result"| node_result_ui
node_result_ui -->|"generates code"| node_qr
node_user -->|"requests shared file"| node_download
node_download -.->|"downloads file"| node_google_api
node_download -.->|"deletes after download"| node_google_api
node_worker -.->|"shows expired state"| node_expired_ui

click node_worker "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_upload_ui "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_upload "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_oauth "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_result_ui "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_qr "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_download "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_expired_ui "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js"
click node_not_found "https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.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_worker toneBlue
class node_upload_ui,node_result_ui,node_qr,node_download,node_expired_ui,node_not_found toneAmber
class node_upload,node_oauth,node_google_api,node_drive_store toneMint
class node_user toneIndigo
```

## Components

### Worker routing

- [Request handler](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`

### Sharing experience

- [Upload page](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [Share result](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [QR code](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [File download](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [Expired page](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [Not-found pages](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`

### Drive integration

- [Drive upload](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- [Access token](https://github.com/yuukiofuyu/serverless-temp-file-sharing/blob/main/worker.js): `worker.js`
- **Google Drive API**
- **Destination folder**

### Other components

- **Visitor**

## Connections

- Visitor → Request handler: sends requests (evidence: `README.md`)
- Request handler → Upload page: renders root (evidence: `worker.js`)
- Request handler → Not-found pages: renders fallback (evidence: `worker.js`)
- Request handler → Drive upload: uploads file (evidence: `worker.js`)
- Drive upload → Access token: gets token (evidence: `worker.js`)
- Drive upload → Google Drive API: sends multipart upload (evidence: `worker.js`)
- Google Drive API → Destination folder: stores file (evidence: `README.md`)
- Request handler → Share result: shows upload result (evidence: `worker.js`)
- Share result → QR code: generates code (evidence: `worker.js`)
- Visitor → File download: requests shared file (evidence: `README.md`)
- File download → Google Drive API: downloads file
- File download → Google Drive API: deletes after download
- Request handler → Expired page: shows expired state (evidence: `worker.js`)
