How markkitz/notion-htmx works
Project’s Purpose and Type
• From the README and file tree, this is a tutorial/demo full-stack data-table web app.
• Tech stack: Bun (server runtime), ElysiaJS (HTTP framework), HTMX + Hyperscript (front-end interaction), UnoCSS/Tailwind (styling).
File Structure to Extract Layers
• Top-level “public/” → static files (index.html, CSS/JS bundles).
• Entry point “main.tsx” → bootstraps the ElysiaJS server, sets up routes.
• “src/components/” + “src/context/” → UI component library and front-end state.
• “src/controllers/” → HTTP handlers (e.g. tableController.tsx).
• “src/database/” → database connection and persistence logic.
• “src/schema/” → data models/schema definitions.
• Build/config: package.json, tsconfig.json, Dockerfile, bun scripts.
Sketch the Main System Components
a. Client Browser
• Renders HTML (public/index.html)
• Loads HTMX and Hyperscript for dynamic requests and client-side behaviors
• Applies CSS from UnoCSS/Tailwind
• Uses the generated bundle (public/dist/scripts.js, unocss.css)
b. HTTP Server (Bun + ElysiaJS)
• main.tsx – sets up routes & middleware
• Controllers (tableController) expose endpoints for CRUD operations
• Injects rendered TSX components if partial-HTML responses are used
c. Database Layer
• src/database/index.ts – initializes the DB (could be SQLite or in-memory)
• src/schema/dataTable.ts – defines the table schema and validations
d. External/Build Tools
• Bun – package manager + runtime
• UnoCSS/Tailwind – styling engine
• Dockerfile/.dockerignore – containerization
Component Relationships & Data Flows
• User Action (click, form edit) → HTMX triggers an HTTP request (GET/POST)
• ElysiaJS Router → dispatches to tableController
• Controller → reads/writes via database module (using schema definitions)
• Controller → returns HTML fragments or JSON
• HTMX → swaps in the returned HTML fragment into the DOM
• Hyperscript → binds inline client-side logic (event handlers, UI updates)
Architectural Patterns
• Server-Driven UI: HTMX replaces typical SPA, fetching HTML snippets from the server.
• MVC-style separation:
• View = TSX components + HTMX templates
• Controller = tableController.tsx
• Model = schema + database module
• Layered architecture: Static assets | Presentation (TSX + HTMX) | API/Controllers | Persistence
Final Checklist
• Callouts for key technologies (Bun, ElysiaJS, HTMX, UnoCSS)
• Annotations describing the MVC-style flow and server-driven UI
• Optional: include Docker build and runtime on the side if deployment context is needed