Backend
Go: standard library first
net/http handles routing and serving. No Gin, no Echo, no Chi. The standard library multiplexer gained method and wildcard routing in Go 1.22, removing the last practical justification for a routing framework in most applications.
The html/template package provides auto-escaping that prevents XSS by construction. This project uses templ instead, for compile-time type safety across the many htmx partials. The compiled output is standard Go.
SQLite via modernc.org/sqlite
Pure Go SQLite: no cgo, no external shared library. The database is compiled into the binary. Deployment is a single file copy. SQLite is the reference implementation choice. It is not a requirement of the SAUI pattern.
WAL mode is enabled at startup. WAL allows concurrent reads without blocking writes, which is appropriate for a read-heavy content site with occasional state mutations. A single writer is enforced; the SQLite concurrency model requires it and the append-only event log is naturally sequential.
What SAUI requires from a persistence layer
Three things. An append-only event log: events are inserted, never updated or deleted. Sequential projection reads: SELECT ... ORDER BY id ASC to derive current state from the log. Serialised writes: concurrent mutations must be ordered so no two events are applied simultaneously to the same session.
SQLite satisfies the third by construction. Any database satisfies it explicitly. The event log schema, the Action interface, and all projection queries are plain SQL and are database-agnostic.
Adapting to Postgres
Replace modernc.org/sqlite with pgx. Remove WAL setup. In the gateway Dispatch method, acquire a Postgres advisory lock before the action is applied and release it after the event is appended. Everything else is unchanged.
-- Serialise writes per session; released automatically on transaction commit
SELECT pg_advisory_xact_lock(hashtext($1)); -- $1 = session_id
-- Event log schema: same structure, database-native types
CREATE TABLE events (
id BIGSERIAL PRIMARY KEY,
session_id TEXT NOT NULL,
type TEXT NOT NULL,
payload JSONB NOT NULL,
occurred_at TIMESTAMPTZ NOT NULL DEFAULT now()
);MySQL and MariaDB use GET_LOCK() for the same purpose. The lock scope changes; the gateway contract does not. Any database that supports row-level locking or advisory locks can satisfy the SAUI write model.
SSE for real-time
Server-Sent Events over standard net/http. No WebSocket unless a use case genuinely requires bidirectional framing. SSE is unidirectional, trivial to implement, and reconnects automatically. It is sufficient for pushing projection updates to the client.
Frontend
htmx
htmx intercepts form submissions and link clicks, sends them as AJAX requests, and swaps the returned HTML fragment into the DOM. The server decides what HTML to return. The client decides where to put it.
This is the only JS dependency. It is loaded from a local file with no CDN dependency for functionality, pinned to a specific version and verified with a subresource integrity hash.
Vanilla JS: Baseline 2023
No framework. No build step. No bundler. JS files are served directly. ES modules via type="module". JSDoc type annotations for IDE inference without a compilation step.
Target: modern evergreen browsers. The audience is developers. No polyfills.
Vanilla CSS
CSS custom properties as design tokens. Grid and Flexbox for layout. Container queries for component-level responsiveness. No CSS-in-JS. No preprocessor. No utility framework.
Deployment
A single Go binary. SQLite database on a persistent volume. Fly.io manages TLS. No external runtime dependencies. No database server. No cache layer. No CDN required for correctness.
# build
go build -o saui .
# deploy
fly deployThe entire production stack fits in one process. Operational complexity is proportional to what the application actually requires, not to what the architecture assumes.