# a5-wjc/website-for-huiyihongbei architecture

> Architecture diagram of the GitHub repository a5-wjc/website-for-huiyihongbei, 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/a5-wjc/website-for-huiyihongbei
- Repository: https://github.com/a5-wjc/website-for-huiyihongbei

## Overview

This is a Cloudflare Worker-backed cake classification and catalog manager. The main workflow is an administrator using the browser UI to manage category → subcategory → cake records, with data persisted in D1; the README also documents login, role-based access, and viewing logs. The Worker routes API requests to the business module, which performs D1 operations and can invoke idempotent schema/sample-data initialization. Source excerpts show these layers, but do not expose the full API dispatch or frontend request code, so those internal links are omitted where not evidenced.

Main entry points: [`src/api.js`](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js) (API business logic), [`src/seed.js`](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/seed.js) (Schema and seed), [`public/index.html`](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/public/index.html) (Management UI), [`src/worker.js`](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/worker.js) (Worker router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_ui["Management UI<br/>[index.html]"]
end

subgraph group_runtime["Worker runtime"]
  node_worker["Worker router<br/>[worker.js]"]
  node_api["API business logic<br/>[api.js]"]
end

subgraph group_domains["Catalog and access"]
  node_catalog["Category hierarchy<br/>[api.js]"]
  node_cakes["Cake catalog<br/>[api.js]"]
  node_identity["Accounts and roles<br/>[api.js]"]
  node_viewlogs["Cake view logs<br/>[api.js]"]
end

subgraph group_persistence["D1 persistence"]
  node_dbhelpers["Validation and auth helpers<br/>[db.js]"]
  node_init["Schema and seed<br/>[seed.js]"]
  node_d1[("D1 database")]
end

node_admin(("Administrator"))

node_admin -->|"manages catalog"| node_ui
node_ui -->|"requests API"| node_worker
node_worker -->|"routes API"| node_api
node_api -->|"uses helpers"| node_dbhelpers
node_api -->|"initializes schema"| node_init
node_api -->|"queries and writes"| node_d1
node_init -->|"uses ID and hash helpers"| node_dbhelpers
node_init -->|"creates and seeds"| node_d1

click node_ui "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/public/index.html"
click node_worker "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/worker.js"
click node_api "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js"
click node_catalog "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js"
click node_cakes "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js"
click node_identity "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js"
click node_viewlogs "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js"
click node_dbhelpers "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/db.js"
click node_init "https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/seed.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_ui toneBlue
class node_worker,node_api toneAmber
class node_catalog,node_cakes,node_identity,node_viewlogs toneMint
class node_dbhelpers,node_init,node_d1 toneRose
class node_admin toneIndigo
```

## Components

### Browser experience

- [Management UI](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/public/index.html): `public/index.html`

### Worker runtime

- [Worker router](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/worker.js): `src/worker.js`
- [API business logic](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js): `src/api.js`

### Catalog and access

- [Category hierarchy](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js): `src/api.js`
- [Cake catalog](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js): `src/api.js`
- [Accounts and roles](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js): `src/api.js`
- [Cake view logs](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/api.js): `src/api.js`

### D1 persistence

- [Validation and auth helpers](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/db.js): `src/db.js`
- [Schema and seed](https://github.com/a5-wjc/website-for-huiyihongbei/blob/main/src/seed.js): `src/seed.js`
- **D1 database**

### Other components

- **Administrator**

## Connections

- Administrator → Management UI: manages catalog (evidence: `README.md`)
- Management UI → Worker router: requests API (evidence: `README.md`)
- Worker router → API business logic: routes API (evidence: `src/worker.js`)
- API business logic → Validation and auth helpers: uses helpers (evidence: `src/api.js`)
- API business logic → Schema and seed: initializes schema (evidence: `src/api.js`)
- API business logic → D1 database: queries and writes (evidence: `src/api.js`)
- Schema and seed → Validation and auth helpers: uses ID and hash helpers (evidence: `src/seed.js`)
- Schema and seed → D1 database: creates and seeds (evidence: `src/seed.js`)
