# maiphh/poet architecture

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

- Interactive diagram: https://gitdiagram.com/maiphh/poet
- Repository: https://github.com/maiphh/poet

## Overview

POET is a community-support site with a public donation flow, PayOS payment processing, a public gift wall, and an admin area for donation moderation and settings. Donors submit a gift through the static site; the Worker validates it, creates a pending record and PayOS checkout, then settles verified webhook events and exposes donation status and wall data. Admins authenticate to review donations and control visibility and donation availability. The frontend excerpts show the donation UI and admin client; Worker excerpts establish routing and backend calls. Other documented-by-tree site sections are included, but their internal interactions are not inferred.

Main entry points: [`worker/src/index.js`](https://github.com/maiphh/poet/blob/master/worker/src/index.js) (API router), [`worker/src/routes-donations.js`](https://github.com/maiphh/poet/blob/master/worker/src/routes-donations.js) (Donation routes), [`ung-ho/donate.js`](https://github.com/maiphh/poet/blob/master/ung-ho/donate.js) (Donation form), [`worker/src/store.js`](https://github.com/maiphh/poet/blob/master/worker/src/store.js) (D1 access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_site["Static Site"]
  node_home["Home content<br/>[app.js]"]
  node_shared_ui["Shared UI"]
  node_team["Team page<br/>[index.html]"]
  node_partners["Partner page<br/>[index.html]"]
end

subgraph group_donor["Donation Experience"]
  node_donor_ui["Donation form<br/>[donate.js]"]
  node_gift_catalog["Gift options<br/>[items.js]"]
  node_payment_card["Payment display<br/>[card.js]"]
  node_donation_result["Payment result<br/>[result.js]"]
  node_donation_pages["Donation pages<br/>[index.html]"]
end

subgraph group_worker["Donation Worker"]
  node_worker_router["API router<br/>[index.js]"]
  node_donation_routes["Donation routes"]
  node_webhook_routes["Payment webhook<br/>[routes-webhook.js]"]
  node_pages_routes["Return redirects<br/>[routes-pages.js]"]
  node_payos["PayOS client<br/>[payos.js]"]
  node_callback_urls["Callback validation<br/>[callback-urls.js]"]
  node_validation["Gift validation<br/>[validation.js]"]
  node_http_helpers["HTTP helpers<br/>[http.js]"]
end

subgraph group_admin["Admin Operations"]
  node_admin_ui["Admin console<br/>[admin.js]"]
  node_admin_routes["Admin routes<br/>[routes-admin.js]"]
  node_auth["Admin sessions<br/>[auth.js]"]
end

subgraph group_storage["Persistence"]
  node_db_layer["D1 access<br/>[store.js]"]
  node_d1[("D1 database<br/>[schema.sql]")]
end

node_visitor(("Site visitor"))
node_payos_service["PayOS"]

node_visitor -->|"visits"| node_home
node_visitor -->|"opens"| node_donation_pages
node_visitor -.->|"visits"| node_team
node_visitor -.->|"visits"| node_partners
node_donation_pages -.->|"hosts"| node_donor_ui
node_donor_ui -->|"uses"| node_gift_catalog
node_donor_ui -->|"requests"| node_worker_router
node_donor_ui -.->|"uses"| node_payment_card
node_donor_ui -.->|"uses"| node_donation_result
node_home -.->|"uses"| node_shared_ui
node_worker_router -->|"dispatches"| node_donation_routes
node_worker_router -->|"dispatches"| node_webhook_routes
node_worker_router -->|"dispatches"| node_admin_routes
node_worker_router -->|"dispatches"| node_pages_routes
node_donation_routes -->|"validates with"| node_validation
node_donation_routes -->|"resolves URLs"| node_callback_urls
node_donation_routes -->|"creates checkout"| node_payos
node_donation_routes -->|"reads/writes"| node_db_layer
node_webhook_routes -->|"verifies signature"| node_payos
node_webhook_routes -->|"settles gift"| node_db_layer
node_webhook_routes -->|"purges cache"| node_donation_routes
node_admin_ui -.->|"calls API"| node_worker_router
node_admin_routes -->|"requires session"| node_auth
node_admin_routes -->|"reads/writes"| node_db_layer
node_admin_routes -->|"rate limits"| node_donation_routes
node_auth -->|"checks sessions"| node_db_layer
node_db_layer -->|"queries"| node_d1
node_payos -->|"HTTP calls"| node_payos_service
node_worker_router -->|"uses"| node_http_helpers
node_pages_routes -->|"redirects to"| node_donation_pages

click node_home "https://github.com/maiphh/poet/blob/master/app.js"
click node_shared_ui "https://github.com/maiphh/poet/tree/master/components"
click node_team "https://github.com/maiphh/poet/blob/master/team/index.html"
click node_partners "https://github.com/maiphh/poet/blob/master/dong-hanh/index.html"
click node_donor_ui "https://github.com/maiphh/poet/blob/master/ung-ho/donate.js"
click node_gift_catalog "https://github.com/maiphh/poet/blob/master/ung-ho/items.js"
click node_payment_card "https://github.com/maiphh/poet/blob/master/ung-ho/card.js"
click node_donation_result "https://github.com/maiphh/poet/blob/master/ung-ho/result.js"
click node_donation_pages "https://github.com/maiphh/poet/blob/master/ung-ho/index.html"
click node_worker_router "https://github.com/maiphh/poet/blob/master/worker/src/index.js"
click node_donation_routes "https://github.com/maiphh/poet/blob/master/worker/src/routes-donations.js"
click node_webhook_routes "https://github.com/maiphh/poet/blob/master/worker/src/routes-webhook.js"
click node_pages_routes "https://github.com/maiphh/poet/blob/master/worker/src/routes-pages.js"
click node_payos "https://github.com/maiphh/poet/blob/master/worker/src/payos.js"
click node_callback_urls "https://github.com/maiphh/poet/blob/master/worker/src/callback-urls.js"
click node_validation "https://github.com/maiphh/poet/blob/master/worker/src/validation.js"
click node_http_helpers "https://github.com/maiphh/poet/blob/master/worker/src/http.js"
click node_admin_ui "https://github.com/maiphh/poet/blob/master/admin/admin.js"
click node_admin_routes "https://github.com/maiphh/poet/blob/master/worker/src/routes-admin.js"
click node_auth "https://github.com/maiphh/poet/blob/master/worker/src/auth.js"
click node_db_layer "https://github.com/maiphh/poet/blob/master/worker/src/store.js"
click node_d1 "https://github.com/maiphh/poet/blob/master/worker/schema.sql"

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_home,node_shared_ui,node_team,node_partners toneBlue
class node_donor_ui,node_gift_catalog,node_payment_card,node_donation_result,node_donation_pages toneAmber
class node_worker_router,node_donation_routes,node_webhook_routes,node_pages_routes,node_payos,node_callback_urls,node_validation,node_http_helpers toneMint
class node_admin_ui,node_admin_routes,node_auth toneRose
class node_db_layer,node_d1,node_visitor,node_payos_service toneIndigo
```

## Components

### Static Site

- [Home content](https://github.com/maiphh/poet/blob/master/app.js): `app.js`
- [Shared UI](https://github.com/maiphh/poet/tree/master/components): `components`
- [Team page](https://github.com/maiphh/poet/blob/master/team/index.html): `team/index.html`
- [Partner page](https://github.com/maiphh/poet/blob/master/dong-hanh/index.html): `dong-hanh/index.html`

### Donation Experience

- [Donation form](https://github.com/maiphh/poet/blob/master/ung-ho/donate.js): `ung-ho/donate.js`
- [Gift options](https://github.com/maiphh/poet/blob/master/ung-ho/items.js): `ung-ho/items.js`
- [Payment display](https://github.com/maiphh/poet/blob/master/ung-ho/card.js): `ung-ho/card.js`
- [Payment result](https://github.com/maiphh/poet/blob/master/ung-ho/result.js): `ung-ho/result.js`
- [Donation pages](https://github.com/maiphh/poet/blob/master/ung-ho/index.html): `ung-ho/index.html`

### Donation Worker

- [API router](https://github.com/maiphh/poet/blob/master/worker/src/index.js): `worker/src/index.js`
- [Donation routes](https://github.com/maiphh/poet/blob/master/worker/src/routes-donations.js): `worker/src/routes-donations.js`
- [Payment webhook](https://github.com/maiphh/poet/blob/master/worker/src/routes-webhook.js): `worker/src/routes-webhook.js`
- [Return redirects](https://github.com/maiphh/poet/blob/master/worker/src/routes-pages.js): `worker/src/routes-pages.js`
- [PayOS client](https://github.com/maiphh/poet/blob/master/worker/src/payos.js): `worker/src/payos.js`
- [Callback validation](https://github.com/maiphh/poet/blob/master/worker/src/callback-urls.js): `worker/src/callback-urls.js`
- [Gift validation](https://github.com/maiphh/poet/blob/master/worker/src/validation.js): `worker/src/validation.js`
- [HTTP helpers](https://github.com/maiphh/poet/blob/master/worker/src/http.js): `worker/src/http.js`

### Admin Operations

- [Admin console](https://github.com/maiphh/poet/blob/master/admin/admin.js): `admin/admin.js`
- [Admin routes](https://github.com/maiphh/poet/blob/master/worker/src/routes-admin.js): `worker/src/routes-admin.js`
- [Admin sessions](https://github.com/maiphh/poet/blob/master/worker/src/auth.js): `worker/src/auth.js`

### Persistence

- [D1 access](https://github.com/maiphh/poet/blob/master/worker/src/store.js): `worker/src/store.js`
- [D1 database](https://github.com/maiphh/poet/blob/master/worker/schema.sql): `worker/schema.sql`

### Other components

- **Site visitor**
- **PayOS**

## Connections

- Site visitor → Home content: visits (evidence: `app.js`)
- Site visitor → Donation pages: opens
- Site visitor → Team page: visits
- Site visitor → Partner page: visits
- Donation pages → Donation form: hosts
- Donation form → Gift options: uses (evidence: `ung-ho/donate.js`)
- Donation form → API router: requests (evidence: `worker/src/index.js`)
- Donation form → Payment display: uses
- Donation form → Payment result: uses
- Home content → Shared UI: uses
- API router → Donation routes: dispatches (evidence: `worker/src/index.js`)
- API router → Payment webhook: dispatches (evidence: `worker/src/index.js`)
- API router → Admin routes: dispatches (evidence: `worker/src/index.js`)
- API router → Return redirects: dispatches (evidence: `worker/src/index.js`)
- Donation routes → Gift validation: validates with (evidence: `worker/src/routes-donations.js`)
- Donation routes → Callback validation: resolves URLs (evidence: `worker/src/routes-donations.js`)
- Donation routes → PayOS client: creates checkout (evidence: `worker/src/routes-donations.js`)
- Donation routes → D1 access: reads/writes (evidence: `worker/src/routes-donations.js`)
- Payment webhook → PayOS client: verifies signature (evidence: `worker/src/routes-webhook.js`)
- Payment webhook → D1 access: settles gift (evidence: `worker/src/routes-webhook.js`)
- Payment webhook → Donation routes: purges cache (evidence: `worker/src/routes-webhook.js`)
- Admin console → API router: calls API
- Admin routes → Admin sessions: requires session (evidence: `worker/src/routes-admin.js`)
- Admin routes → D1 access: reads/writes (evidence: `worker/src/routes-admin.js`)
- Admin routes → Donation routes: rate limits (evidence: `worker/src/routes-admin.js`)
- Admin sessions → D1 access: checks sessions (evidence: `worker/src/auth.js`)
- D1 access → D1 database: queries (evidence: `worker/src/store.js`)
- PayOS client → PayOS: HTTP calls (evidence: `worker/src/payos.js`)
- API router → HTTP helpers: uses (evidence: `worker/src/index.js`)
- Return redirects → Donation pages: redirects to
