Build a Web App

Build a notes app from scratch — a JSON API backed by SQLite, then server-rendered HTML with HTMX for instant interactions. One server handles everything: API endpoints, HTML pages, and database queries.

Before you start

You should have installed Kestrel and worked through at least one tour. This guide assumes you're comfortable with structs, enums, match, and Optional.

Libraries you'll use

  • Perch — a web framework for routing HTTP requests and composing middleware.
  • Talon-SQLite — a SQLite driver with parameterized queries and row mapping.
  • Quill — a JSON value type with serialization and deserialization protocols.
  • http — content types (Html, Text) and cookies.
  • html-builder — a type-safe HTML builder with automatic escaping.
  • datetime — dates, times, timestamps, and durations.
  • crypto — SHA-256 password hashing and secure random token generation.

Pages

  1. Project Setup — create the project, add dependencies, serve your first endpoint.
  2. Database & Models — define the schema, build a model that maps between database rows and JSON.
  3. JSON API — wire up request parsing, handlers, and a CRUD API you can test with curl.
  4. HTML Frontend — render HTML pages with the html-builder library.
  5. HTMX Interactions — add HTMX so the app updates without full page reloads.
  6. Authentication (optional) — protect routes with SHA-256 password hashing and middleware.

Each page produces working code. You can stop after any page and have something that runs. Authentication is optional — the first five pages build a complete app.