# nexryai/google-drive-s3 architecture

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

- Interactive diagram: https://gitdiagram.com/nexryai/google-drive-s3
- Repository: https://github.com/nexryai/google-drive-s3

## Overview

I.R.I.S. is a Cloudflare Worker that presents Google Drive as S3-compatible object storage. An S3 client sends requests to the Worker, which routes object operations, applies signature and bucket-access checks, and uses Google credentials to access Drive; Drive folders represent buckets and nested object paths. The README also documents public-read buckets and KV bindings for authentication and folder caching. Most runtime behavior lives in one file; omitted portions prevent confirming several internal call relationships, so those are shown only as unverified links or omitted.

Main entry points: [`src/index.ts`](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts) (Request Router), [`README.md`](https://github.com/nexryai/google-drive-s3/blob/main/README.md) (Auth KV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["S3 API"]
  node_worker["Request Router<br/>[index.ts]"]
  node_response["S3 Response<br/>[index.ts]"]
end

subgraph group_access["Access Control"]
  node_sigv4["SigV4 Verification<br/>[index.ts]"]
  node_bucketpolicy["Bucket Access Rules<br/>[index.ts]"]
  node_token["Token Refresh<br/>[index.ts]"]
end

subgraph group_drive["Drive Storage"]
  node_upload["Stream Upload<br/>[index.ts]"]
  node_download["Stream Download<br/>[index.ts]"]
  node_delete["Object Delete<br/>[index.ts]"]
  node_pathresolve["Drive Path Resolution<br/>[index.ts]"]
end

subgraph group_state["Worker State"]
  node_foldercache[("Folder Cache<br/>[index.ts]")]
  node_authkv[("Auth KV<br/>[README.md]")]
end

node_client(("S3 Client"))
node_driveapi["Google Drive API"]
node_oauth["Google OAuth"]

node_client -->|"sends request"| node_worker
node_worker -->|"calls upload"| node_upload
node_worker -->|"calls delete"| node_delete
node_worker -.->|"verifies signature"| node_sigv4
node_worker -.->|"checks access"| node_bucketpolicy
node_worker -.->|"gets token"| node_token
node_worker -.->|"routes download"| node_download
node_worker -.->|"returns response"| node_response
node_token -->|"reads and writes"| node_authkv
node_token -->|"refreshes token"| node_oauth
node_upload -->|"resolves path"| node_pathresolve
node_delete -->|"resolves path"| node_pathresolve
node_pathresolve -->|"caches folders"| node_foldercache
node_upload -->|"uploads stream"| node_driveapi
node_download -.->|"downloads object"| node_driveapi
node_delete -.->|"deletes object"| node_driveapi

click node_worker "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_sigv4 "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_bucketpolicy "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_token "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_upload "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_download "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_delete "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_pathresolve "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_foldercache "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"
click node_authkv "https://github.com/nexryai/google-drive-s3/blob/main/README.md"
click node_response "https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts"

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,node_response,node_client toneBlue
class node_sigv4,node_bucketpolicy,node_token toneAmber
class node_upload,node_download,node_delete,node_pathresolve,node_driveapi toneMint
class node_foldercache,node_authkv toneRose
class node_oauth toneIndigo
```

## Components

### S3 API

- [Request Router](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [S3 Response](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`

### Access Control

- [SigV4 Verification](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Bucket Access Rules](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Token Refresh](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`

### Drive Storage

- [Stream Upload](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Stream Download](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Object Delete](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Drive Path Resolution](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`

### Worker State

- [Folder Cache](https://github.com/nexryai/google-drive-s3/blob/main/src/index.ts): `src/index.ts`
- [Auth KV](https://github.com/nexryai/google-drive-s3/blob/main/README.md): `README.md`

### Other components

- **S3 Client**
- **Google Drive API**
- **Google OAuth**

## Connections

- S3 Client → Request Router: sends request (evidence: `README.md`)
- Request Router → Stream Upload: calls upload (evidence: `src/index.ts`)
- Request Router → Object Delete: calls delete (evidence: `src/index.ts`)
- Request Router → SigV4 Verification: verifies signature (evidence: `src/index.ts`)
- Request Router → Bucket Access Rules: checks access (evidence: `src/index.ts`)
- Request Router → Token Refresh: gets token (evidence: `src/index.ts`)
- Request Router → Stream Download: routes download (evidence: `src/index.ts`)
- Request Router → S3 Response: returns response (evidence: `src/index.ts`)
- Token Refresh → Auth KV: reads and writes (evidence: `src/index.ts`)
- Token Refresh → Google OAuth: refreshes token (evidence: `src/index.ts`)
- Stream Upload → Drive Path Resolution: resolves path (evidence: `src/index.ts`)
- Object Delete → Drive Path Resolution: resolves path (evidence: `src/index.ts`)
- Drive Path Resolution → Folder Cache: caches folders (evidence: `src/index.ts`)
- Stream Upload → Google Drive API: uploads stream (evidence: `src/index.ts`)
- Stream Download → Google Drive API: downloads object
- Object Delete → Google Drive API: deletes object
