How nico-amsterdam/bun-htmx-crud works
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: index.ts Elysia app · productList.tsx Product list and search · product/index.tsx Product routes · auth/index.tsx Auth routes
Components 24
Server runtime
- Elysia app
src/index.ts - Request security
src/lib/security.ts - Security headers
src/routes/helper/securityHeaders.tsx
Authentication
- Auth routes
src/routes/auth/index.tsx - GitHub OAuth
src/routes/auth/github.tsx - Google OAuth
src/routes/auth/google.tsx - Identity providers
- Session validation
src/routes/auth/index.tsx
Product CRUD
- Product routes
src/routes/product/index.tsx - Product list and search
src/routes/product/productList.tsx - Add product
src/routes/product/addProduct.tsx - Edit product
src/routes/product/editProduct.tsx - Delete product
src/routes/product/delProduct.tsx - Product form
src/routes/product/productForm.tsx - Page state
src/routes/product/page.ts
HTML and interaction
- Base HTML shell
src/routes/helper/basePage.ts - Shared page body
src/routes/helper/body.tsx - HTMX interactions
client/src/hx-extension-helpers.ts - Language switcher
src/routes/helper/languageSwitcher.tsx
Data and localization
- Database access
src/db/index.ts - Products table
src/db/schema.ts - Language selection
src/i18n/lang.ts - Translations
src/i18n/translations.ts
Other components
- Browser user
Connections 28
- Browser user → Elysia app: requests pages
- Elysia app → Request security: checks requests
src/index.ts - Elysia app → Security headers: applies headers
src/index.ts - Elysia app → Auth routes: registers routes
src/index.ts - Elysia app → Product routes: registers routes
src/index.ts - Auth routes → GitHub OAuth: mounts provider
src/routes/auth/index.tsx - Auth routes → Google OAuth: mounts provider
src/routes/auth/index.tsx - GitHub OAuth → Identity providers: authenticates with
- Google OAuth → Identity providers: authenticates with
- Auth routes → Session validation: validates session
src/routes/auth/index.tsx - Product routes → Product list and search: mounts handler
src/routes/product/index.tsx - Product routes → Add product: mounts handler
src/routes/product/index.tsx - Product routes → Edit product: mounts handler
src/routes/product/index.tsx - Product routes → Delete product: mounts handler
src/routes/product/index.tsx - Product list and search → Database access: loads products
src/routes/product/productList.tsx - Edit product → Database access: updates product
src/routes/product/editProduct.tsx - Edit product → Product form: renders and validates
src/routes/product/editProduct.tsx - Edit product → Product list and search: returns to list
src/routes/product/editProduct.tsx - Product list and search → Page state: builds page state
src/routes/product/productList.tsx - Product list and search → Shared page body: renders full page
src/routes/product/productList.tsx - Product list and search → Base HTML shell: wraps full page
src/routes/product/productList.tsx - Shared page body → Language switcher: renders switcher
src/routes/helper/body.tsx - Base HTML shell → HTMX interactions: loads extensions
src/routes/helper/basePage.ts - Elysia app → Products table: configures ORM schema
src/index.ts - Database access → Products table: uses table schema
src/db/index.ts - Elysia app → Language selection: sets request language
src/index.ts - Language selection → Translations: selects locale
- Language switcher → Translations: uses locale text