# nico-amsterdam/bun-htmx-crud architecture

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

- Interactive diagram: https://gitdiagram.com/nico-amsterdam/bun-htmx-crud
- Repository: https://github.com/nico-amsterdam/bun-htmx-crud

## Overview

This is a server-rendered HTMX product CRUD application with OAuth login, backed by SQLite/Cloudflare D1. A browser requests a page or HTMX fragment; Elysia applies request checks and language handling, authentication protects product routes, and product handlers read or mutate records before returning HTML. The interface supports filtering, paging, forms, and language switching. The README also documents Google/GitHub login, migrations, accessibility, and Cloudflare deployment; deployment mechanics are not part of the runtime map. Some CRUD handlers and client extensions are indexed but not excerpted, so uncertain links are omitted.

Main entry points: [`src/index.ts`](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/index.ts) (Elysia app), [`src/routes/product/productList.tsx`](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/productList.tsx) (Product list and search), [`src/routes/product/index.tsx`](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/index.tsx) (Product routes), [`src/routes/auth/index.tsx`](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/index.tsx) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_elysia["Elysia app<br/>[index.ts]"]
  node_security["Request security<br/>[security.ts]"]
  node_headers["Security headers"]
end

subgraph group_auth["Authentication"]
  node_authroutes["Auth routes<br/>[index.tsx]"]
  node_github["GitHub OAuth<br/>[github.tsx]"]
  node_google["Google OAuth<br/>[google.tsx]"]
  node_providers["Identity providers"]
  node_session["Session validation<br/>[index.tsx]"]
end

subgraph group_products["Product CRUD"]
  node_productroutes["Product routes<br/>[index.tsx]"]
  node_productlist["Product list and search<br/>[productList.tsx]"]
  node_addproduct["Add product<br/>[addProduct.tsx]"]
  node_editproduct["Edit product<br/>[editProduct.tsx]"]
  node_deleteproduct["Delete product<br/>[delProduct.tsx]"]
  node_productform["Product form<br/>[productForm.tsx]"]
  node_page["Page state<br/>[page.ts]"]
end

subgraph group_presentation["HTML and interaction"]
  node_html["Base HTML shell<br/>[basePage.ts]"]
  node_body["Shared page body<br/>[body.tsx]"]
  node_client["HTMX interactions"]
  node_switcher["Language switcher"]
end

subgraph group_state["Data and localization"]
  node_dbaccess["Database access<br/>[index.ts]"]
  node_productschema[("Products table<br/>[schema.ts]")]
  node_language["Language selection<br/>[lang.ts]"]
  node_translations["Translations<br/>[translations.ts]"]
end

node_browser(("Browser user"))

node_browser -->|"requests pages"| node_elysia
node_elysia -->|"checks requests"| node_security
node_elysia -->|"applies headers"| node_headers
node_elysia -->|"registers routes"| node_authroutes
node_elysia -->|"registers routes"| node_productroutes
node_authroutes -->|"mounts provider"| node_github
node_authroutes -->|"mounts provider"| node_google
node_github -.->|"authenticates with"| node_providers
node_google -.->|"authenticates with"| node_providers
node_authroutes -->|"validates session"| node_session
node_productroutes -->|"mounts handler"| node_productlist
node_productroutes -->|"mounts handler"| node_addproduct
node_productroutes -->|"mounts handler"| node_editproduct
node_productroutes -->|"mounts handler"| node_deleteproduct
node_productlist -->|"loads products"| node_dbaccess
node_editproduct -->|"updates product"| node_dbaccess
node_editproduct -->|"renders and validates"| node_productform
node_editproduct -->|"returns to list"| node_productlist
node_productlist -->|"builds page state"| node_page
node_productlist -->|"renders full page"| node_body
node_productlist -->|"wraps full page"| node_html
node_body -->|"renders switcher"| node_switcher
node_html -->|"loads extensions"| node_client
node_elysia -->|"configures ORM schema"| node_productschema
node_dbaccess -->|"uses table schema"| node_productschema
node_elysia -->|"sets request language"| node_language
node_language -.->|"selects locale"| node_translations
node_switcher -.->|"uses locale text"| node_translations

click node_elysia "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/index.ts"
click node_security "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/lib/security.ts"
click node_headers "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/securityHeaders.tsx"
click node_authroutes "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/index.tsx"
click node_github "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/github.tsx"
click node_google "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/google.tsx"
click node_session "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/index.tsx"
click node_productroutes "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/index.tsx"
click node_productlist "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/productList.tsx"
click node_addproduct "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/addProduct.tsx"
click node_editproduct "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/editProduct.tsx"
click node_deleteproduct "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/delProduct.tsx"
click node_productform "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/productForm.tsx"
click node_page "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/page.ts"
click node_html "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/basePage.ts"
click node_body "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/body.tsx"
click node_client "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/client/src/hx-extension-helpers.ts"
click node_dbaccess "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/db/index.ts"
click node_productschema "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/db/schema.ts"
click node_language "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/i18n/lang.ts"
click node_translations "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/i18n/translations.ts"
click node_switcher "https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/languageSwitcher.tsx"

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_elysia,node_security,node_headers,node_browser toneBlue
class node_authroutes,node_github,node_google,node_providers,node_session toneAmber
class node_productroutes,node_productlist,node_addproduct,node_editproduct,node_deleteproduct,node_productform,node_page toneMint
class node_html,node_body,node_client,node_switcher toneRose
class node_dbaccess,node_productschema,node_language,node_translations toneIndigo
```

## Components

### Server runtime

- [Elysia app](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/index.ts): `src/index.ts`
- [Request security](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/lib/security.ts): `src/lib/security.ts`
- [Security headers](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/securityHeaders.tsx): `src/routes/helper/securityHeaders.tsx`

### Authentication

- [Auth routes](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/index.tsx): `src/routes/auth/index.tsx`
- [GitHub OAuth](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/github.tsx): `src/routes/auth/github.tsx`
- [Google OAuth](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/google.tsx): `src/routes/auth/google.tsx`
- **Identity providers**
- [Session validation](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/auth/index.tsx): `src/routes/auth/index.tsx`

### Product CRUD

- [Product routes](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/index.tsx): `src/routes/product/index.tsx`
- [Product list and search](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/productList.tsx): `src/routes/product/productList.tsx`
- [Add product](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/addProduct.tsx): `src/routes/product/addProduct.tsx`
- [Edit product](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/editProduct.tsx): `src/routes/product/editProduct.tsx`
- [Delete product](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/delProduct.tsx): `src/routes/product/delProduct.tsx`
- [Product form](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/productForm.tsx): `src/routes/product/productForm.tsx`
- [Page state](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/product/page.ts): `src/routes/product/page.ts`

### HTML and interaction

- [Base HTML shell](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/basePage.ts): `src/routes/helper/basePage.ts`
- [Shared page body](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/body.tsx): `src/routes/helper/body.tsx`
- [HTMX interactions](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/client/src/hx-extension-helpers.ts): `client/src/hx-extension-helpers.ts`
- [Language switcher](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/routes/helper/languageSwitcher.tsx): `src/routes/helper/languageSwitcher.tsx`

### Data and localization

- [Database access](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/db/index.ts): `src/db/index.ts`
- [Products table](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/db/schema.ts): `src/db/schema.ts`
- [Language selection](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/i18n/lang.ts): `src/i18n/lang.ts`
- [Translations](https://github.com/nico-amsterdam/bun-htmx-crud/blob/cloudflare-d1/src/i18n/translations.ts): `src/i18n/translations.ts`

### Other components

- **Browser user**

## Connections

- Browser user → Elysia app: requests pages
- Elysia app → Request security: checks requests (evidence: `src/index.ts`)
- Elysia app → Security headers: applies headers (evidence: `src/index.ts`)
- Elysia app → Auth routes: registers routes (evidence: `src/index.ts`)
- Elysia app → Product routes: registers routes (evidence: `src/index.ts`)
- Auth routes → GitHub OAuth: mounts provider (evidence: `src/routes/auth/index.tsx`)
- Auth routes → Google OAuth: mounts provider (evidence: `src/routes/auth/index.tsx`)
- GitHub OAuth → Identity providers: authenticates with
- Google OAuth → Identity providers: authenticates with
- Auth routes → Session validation: validates session (evidence: `src/routes/auth/index.tsx`)
- Product routes → Product list and search: mounts handler (evidence: `src/routes/product/index.tsx`)
- Product routes → Add product: mounts handler (evidence: `src/routes/product/index.tsx`)
- Product routes → Edit product: mounts handler (evidence: `src/routes/product/index.tsx`)
- Product routes → Delete product: mounts handler (evidence: `src/routes/product/index.tsx`)
- Product list and search → Database access: loads products (evidence: `src/routes/product/productList.tsx`)
- Edit product → Database access: updates product (evidence: `src/routes/product/editProduct.tsx`)
- Edit product → Product form: renders and validates (evidence: `src/routes/product/editProduct.tsx`)
- Edit product → Product list and search: returns to list (evidence: `src/routes/product/editProduct.tsx`)
- Product list and search → Page state: builds page state (evidence: `src/routes/product/productList.tsx`)
- Product list and search → Shared page body: renders full page (evidence: `src/routes/product/productList.tsx`)
- Product list and search → Base HTML shell: wraps full page (evidence: `src/routes/product/productList.tsx`)
- Shared page body → Language switcher: renders switcher (evidence: `src/routes/helper/body.tsx`)
- Base HTML shell → HTMX interactions: loads extensions (evidence: `src/routes/helper/basePage.ts`)
- Elysia app → Products table: configures ORM schema (evidence: `src/index.ts`)
- Database access → Products table: uses table schema (evidence: `src/db/index.ts`)
- Elysia app → Language selection: sets request language (evidence: `src/index.ts`)
- Language selection → Translations: selects locale
- Language switcher → Translations: uses locale text
