# ayiux/cloudflare-imgbed architecture

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

- Interactive diagram: https://gitdiagram.com/ayiux/cloudflare-imgbed
- Repository: https://github.com/ayiux/cloudflare-imgbed

## Overview

CloudFlare-ImgBed is a file-hosting application with upload, management, and retrieval workflows, plus authentication, WebDAV, directories, moderation, and random-image features. Requests enter through the Functions routes; uploads select storage and record metadata, while file-serving and management routes provide retrieval and lifecycle operations. Database adapters and the index manager support persistent records and directory-aware listings. The README documents storage channels beyond those demonstrated in sampled code; those modules are shown without asserting their internal dispatch wiring.

Main entry points: [`functions/utils/databaseAdapter.js`](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/databaseAdapter.js) (Database adapter), [`functions/upload/index.js`](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/upload/index.js) (Upload handler), [`frontend-dist/js/app.d5cd9b3f.js`](https://github.com/ayiux/cloudflare-imgbed/blob/main/frontend-dist/js/app.d5cd9b3f.js) (Web interface), [`functions/utils/indexManager.js`](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/indexManager.js) (Directory index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_frontend["Web interface<br/>[app.d5cd9b3f.js]"]
end

subgraph group_api["Request workflows"]
  node_upload["Upload handler<br/>[index.js]"]
  node_uploadtools["Upload utilities<br/>[uploadTools.js]"]
  node_management["File management"]
  node_filedelivery["File delivery<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_webdav["WebDAV access<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_publiclist["Public listings<br/>[list.js]"]
  node_random["Random images<br/>[index.js]"]
end

subgraph group_identity["Identity and settings"]
  node_authroutes["Auth endpoints"]
  node_sessions["Session manager<br/>[sessionManager.js]"]
  node_config["System configuration<br/>[sysConfig.js]"]
end

subgraph group_content["Content and indexing"]
  node_index["Directory index<br/>[indexManager.js]"]
  node_metadata["Metadata utilities"]
end

subgraph group_persistence["Persistence and channels"]
  node_dbadapter["Database adapter<br/>[databaseAdapter.js]"]
  node_d1[("D1 operations<br/>[d1Database.js]")]
  node_telegram["Telegram adapter<br/>[telegramAPI.js]"]
  node_discord["Discord adapter<br/>[discordAPI.js]"]
  node_huggingface["Hugging Face adapter<br/>[huggingfaceAPI.js]"]
  node_webdavstore["WebDAV adapter<br/>[webdavAPI.js]"]
  node_localr2[("Local R2 emulation<br/>[r2Storage.js]")]
end

node_visitor(("User or admin"))
node_channelservices(("Storage services"))

node_visitor -->|"uses"| node_frontend
node_frontend -->|"submits uploads"| node_upload
node_frontend -->|"manages files"| node_management
node_frontend -->|"authenticates"| node_authroutes
node_frontend -->|"browses"| node_publiclist
node_upload -->|"reads settings"| node_config
node_upload -->|"uses utilities"| node_uploadtools
node_upload -->|"writes metadata"| node_dbadapter
node_upload -->|"large-file upload"| node_telegram
node_upload -->|"moderates content"| node_metadata
node_authroutes -->|"checks sessions"| node_sessions
node_sessions -->|"reads and writes"| node_dbadapter
node_sessions -->|"reads policy"| node_config
node_management -->|"manages records"| node_dbadapter
node_management -->|"manages index"| node_index
node_filedelivery -->|"reads file record"| node_dbadapter
node_webdav -->|"accesses records"| node_dbadapter
node_publiclist -->|"lists files"| node_index
node_random -->|"reads settings"| node_config
node_random -->|"selects files"| node_index
node_index -->|"reads and writes"| node_dbadapter
node_dbadapter -->|"adapts D1"| node_d1
node_telegram -.->|"uses channel"| node_channelservices
node_discord -.->|"uses channel"| node_channelservices
node_huggingface -.->|"uses channel"| node_channelservices
node_webdavstore -.->|"uses channel"| node_channelservices

click node_frontend "https://github.com/ayiux/cloudflare-imgbed/blob/main/frontend-dist/js/app.d5cd9b3f.js"
click node_upload "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/upload/index.js"
click node_uploadtools "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/upload/uploadTools.js"
click node_management "https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/api/manage"
click node_filedelivery "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/file/%5B%5Bpath%5D%5D.js"
click node_webdav "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/dav/%5B%5Bpath%5D%5D.js"
click node_publiclist "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/api/public/list.js"
click node_random "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/random/index.js"
click node_authroutes "https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/api/auth"
click node_sessions "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/auth/sessionManager.js"
click node_config "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/sysConfig.js"
click node_index "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/indexManager.js"
click node_metadata "https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/utils/metadata"
click node_dbadapter "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/databaseAdapter.js"
click node_d1 "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/d1Database.js"
click node_telegram "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/telegramAPI.js"
click node_discord "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/discordAPI.js"
click node_huggingface "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/huggingfaceAPI.js"
click node_webdavstore "https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/webdavAPI.js"
click node_localr2 "https://github.com/ayiux/cloudflare-imgbed/blob/main/deploy/server/r2Storage.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_frontend,node_visitor toneBlue
class node_upload,node_uploadtools,node_management,node_filedelivery,node_webdav,node_publiclist,node_random,node_channelservices toneAmber
class node_authroutes,node_sessions,node_config toneMint
class node_index,node_metadata toneRose
class node_dbadapter,node_d1,node_telegram,node_discord,node_huggingface,node_webdavstore,node_localr2 toneIndigo
```

## Components

### Client experience

- [Web interface](https://github.com/ayiux/cloudflare-imgbed/blob/main/frontend-dist/js/app.d5cd9b3f.js): `frontend-dist/js/app.d5cd9b3f.js`

### Request workflows

- [Upload handler](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/upload/index.js): `functions/upload/index.js`
- [Upload utilities](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/upload/uploadTools.js): `functions/upload/uploadTools.js`
- [File management](https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/api/manage): `functions/api/manage`
- [File delivery](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/file/%5B%5Bpath%5D%5D.js): `functions/file/[[path]].js`
- [WebDAV access](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/dav/%5B%5Bpath%5D%5D.js): `functions/dav/[[path]].js`
- [Public listings](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/api/public/list.js): `functions/api/public/list.js`
- [Random images](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/random/index.js): `functions/random/index.js`

### Identity and settings

- [Auth endpoints](https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/api/auth): `functions/api/auth`
- [Session manager](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/auth/sessionManager.js): `functions/utils/auth/sessionManager.js`
- [System configuration](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/sysConfig.js): `functions/utils/sysConfig.js`

### Content and indexing

- [Directory index](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/indexManager.js): `functions/utils/indexManager.js`
- [Metadata utilities](https://github.com/ayiux/cloudflare-imgbed/tree/main/functions/utils/metadata): `functions/utils/metadata`

### Persistence and channels

- [Database adapter](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/databaseAdapter.js): `functions/utils/databaseAdapter.js`
- [D1 operations](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/d1Database.js): `functions/utils/d1Database.js`
- [Telegram adapter](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/telegramAPI.js): `functions/utils/storage/telegramAPI.js`
- [Discord adapter](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/discordAPI.js): `functions/utils/storage/discordAPI.js`
- [Hugging Face adapter](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/huggingfaceAPI.js): `functions/utils/storage/huggingfaceAPI.js`
- [WebDAV adapter](https://github.com/ayiux/cloudflare-imgbed/blob/main/functions/utils/storage/webdavAPI.js): `functions/utils/storage/webdavAPI.js`
- [Local R2 emulation](https://github.com/ayiux/cloudflare-imgbed/blob/main/deploy/server/r2Storage.js): `deploy/server/r2Storage.js`

### Other components

- **User or admin**
- **Storage services**

## Connections

- User or admin → Web interface: uses
- Web interface → Upload handler: submits uploads
- Web interface → File management: manages files
- Web interface → Auth endpoints: authenticates
- Web interface → Public listings: browses
- Upload handler → System configuration: reads settings
- Upload handler → Upload utilities: uses utilities
- Upload handler → Database adapter: writes metadata
- Upload handler → Telegram adapter: large-file upload
- Upload handler → Metadata utilities: moderates content
- Auth endpoints → Session manager: checks sessions
- Session manager → Database adapter: reads and writes
- Session manager → System configuration: reads policy
- File management → Database adapter: manages records
- File management → Directory index: manages index
- File delivery → Database adapter: reads file record
- WebDAV access → Database adapter: accesses records
- Public listings → Directory index: lists files
- Random images → System configuration: reads settings
- Random images → Directory index: selects files
- Directory index → Database adapter: reads and writes
- Database adapter → D1 operations: adapts D1
- Telegram adapter → Storage services: uses channel
- Discord adapter → Storage services: uses channel
- Hugging Face adapter → Storage services: uses channel
- WebDAV adapter → Storage services: uses channel
