A gallery of paintings and photographs, served at art.klaushofrichter.net.
Public — no login, no accounts, nothing to sign into. An Express/TypeScript
app that reads its content from the picture folders at boot and runs as a
Knative Service on a self-hosted single-node k3s
cluster (see klaushofrichter/kube-setup).
Full-height panels, one per room, moved by drag, wheel or arrow keys. A room's cover is cropped and drifts against the pointer under a soft white light — both driven by springs on an animation-frame loop rather than CSS transitions, which is what keeps the motion smooth rather than choppy.
On a phone there is no pointer to follow, so the light on the panel in view
wanders by itself — slowly, inside a box clear of the edges, easing in rather
than jumping, and repainting at most 30 times a second. It stops while a room
is open and is skipped entirely for anyone who asks for reduced motion.
AMBIENT = false at the top of public/app.js switches it off.
Entering a room is deliberate: the Enter the room button, the side menu, or
Return. Clicking a panel does nothing.
Each picture takes the whole screen — contained so nothing is ever clipped, but scaled up when the source is smaller so there is no dead space. When a picture's shape leaves a bar above and below it, that slack drops the picture clear of the navigation buttons rather than centring it behind them.
The full label shows by default; a click anywhere — or Return — clears it for
an unobstructed picture, and a click, Return or Esc brings it back.
Navigation always sits in the same place: a stack at the top left. In the lobby that is Rooms; in a room it is ← Lobby with Content underneath. The rooms menu is headed Lobby, and that heading is itself the way back to the front door — out of any room, onto the first panel, with the greeting played again. The tree is strict — a room's menu lists that room's pictures and offers no way sideways to another room.
Someone arriving at the bare front door — no fragment, no permalink — is met by a title card that names the gallery, holds for a few seconds and fades. The room's own caption waits until it has gone rather than sitting behind it. Any click, tap, key or scroll dismisses it at once, and it ignores the pointer, so it is never in the way. A visitor who followed a deep link or a permalink already knows where they are going and is not greeted.
The lobby also carries a full-screen control at the top right — the browser's own full screen, so the gallery fills the window and stays that way as you move through it. It is the one control that is not navigation, which is why it sits opposite the stack rather than in it.
A room with no works: one hero image and the artist's text. Because there is one picture and nothing to sell, it is not built like a picture room — no paging, no thumbnails, no full screen. The only navigation is leaving it.
The hero fills the frame without bars and keeps its ratio, pinned by its top right corner to the window's, so the crop is taken from the bottom left. It is shown as it is: none of the lobby's pointer light, drift or dimming follows it into the room, because no other room has those either. The text is carried by a band that fades away to the right instead.
| Key | |
|---|---|
↑ ↓ |
previous / next |
| drag, wheel | the same, with a throw |
Return |
in the lobby, enter the room you are looking at; in a room, in and out of full screen |
Space |
short label — title and date. Full screen only, where there is no full label for it to collide with |
R |
rooms (in the lobby) |
P |
content of the room you are in |
Esc |
back one level: menu → full screen → room → lobby |
| Form | Goes to |
|---|---|
/#dogs |
the lobby, on that room |
/#dogs/close |
straight to one picture |
/?id=bab5q6e3 |
permalink — a room or a picture, by its own id |
A permalink is the id from index.json, not a position or a title, so it
survives renaming and reordering. An id that no longer exists lands quietly in
the lobby; there is no error page, because there is nothing useful to say.
A picture's label carries two icons: its permalink, and a download of that picture at full resolution. The download is always the one picture on screen — there is no way to pull a whole room, by design.
A browser with an AI agent built in can drive the gallery through
WebMCP tools rather than
dragging the rail: list-rooms, find-works, describe-current-view,
show-room, show-work, next-view and open-purchase-page. They read the
same manifest the page already has, so a sold picture's price is not there to
give, and they move the page through its own navigation, so whatever the
agent does happens on screen. None of them buys, sends or submits anything:
the furthest one goes is opening a purchase page, and the enquiry is still the
visitor's to send.
For now they appear only in Chrome with about:flags#enable-webmcp-testing
turned on. Every other browser has no document.modelContext and never
notices. There is no origin-trial token yet, so ordinary visitors do not get
them. WEBMCP = false at the top of public/app.js removes them.
The pictures are not in this repository. It is public and the artwork is
not; the gallery reads its content from a directory given by ASSETS_DIR,
which in production is a Kubernetes volume. assets/ is git-ignored, so a
fresh clone has no content until you fetch some:
scripts/pull-assets.sh # copy what is live down into ./assets
# …edit…
scripts/sync-assets.sh # push it back; the site follows within ~10ssync-assets.sh validates before it touches the cluster, swaps the new tree
in atomically, and keeps the previous one as assets.old for a one-command
rollback. Content ships this way rather than through CI: code goes through
pull requests and checks, content does not.
The layout is one folder per room, each with an index.json beside its
pictures.
A flat scan cannot say how big a painting is, what the frame looks like, or
what the paint actually does. views adds further photographs of the same
work:
"views": [
{ "file": "IMG_8356.jpg", "kind": "framed", "caption": "Framed, on the wall" },
{ "file": "IMG_8358.jpg", "kind": "detail", "caption": "Detail — upper left" }
]A view is a picture in every mechanical sense — it gets the same width ladder
and the same WebP copies from make-derivatives.sh, so just drop the files in
the room folder beside everything else. It is not a work: no slug, no price,
no status, no permalink. It never appears in the lobby, never in the rail, and
never as the og:image of a link preview, all of which speak for the work as
a whole.
kind is framed, detail or other; caption is what the picture is, and
is worth writing, because it is both the alt text and the label on screen. A
view whose file is missing is dropped with a warning rather than throwing —
the same rule works follow, and a supporting photograph is worth even less of
an outage.
In a room, views live on the horizontal axis: left and right, a swipe sideways, or the two arrows at the edges of the picture. Up and down go on meaning the next work. A work with no views shows no arrows and no caption at all, so nothing suggests there is more where there is not. Moving to another work always returns to that work's own picture.
The arrows carry a second of warm colour as they arrive, so a visitor finds out there is more of this picture without being told. Only on the way up, though: paging from one work with views to another never takes the arrows away, and a control that lit up on every step would be a nag rather than a hint. Stepping past a work with none puts them away and earns the next appearance its moment. The class comes off again when the animation ends — left on, a filled animation would pin those colours over the hover state for as long as the room is open.
On the purchase page they are simply laid out under the picture, with their captions. No slider: this is the page someone reads while deciding whether to spend money, and a buyer wants the framed shot and the brushwork in front of them at once rather than behind a control they have to discover.
edition is a short free-text phrase — "Original · one of one", "Archival
print" — shown beside the price and again in the details. Colors is one-of-one
paintings and Dogs and Food are prints, and the difference matters more to a
buyer than anything else on the page; medium alone does not say it. It is
free text because only the person who made the work knows what is true of it.
The pictures are on the site, and the label offers the full-resolution file, so
a download is not what someone pays for. includes says what is — signing,
extras, anything a file cannot carry:
"collection": {
"includes": [
"Personally signed by the artist",
"Comes with the recipe and cooking instructions"
]
}It sits on the collection and applies to every work in it; a work may add its own with the same key, and the two are merged. It is shown only where the work can still be bought, because it reads as a promise rather than a description. The original paintings carry none — being one of one is the difference.
status |
Shown |
|---|---|
available |
price, and a link to the purchase page |
sold |
no price at all — the picture still hangs |
reserved |
price and what is included, in the room and on its purchase page, but no way to enquire |
nfs |
never for sale |
A sold or not-for-sale price is not merely hidden in the page: it is never sent to the browser.
A deliberately small subset — *italic* and **bold**, nothing else. Text is
escaped before the markup is applied, so a stray < stays text. Everything the
browser renders is built as DOM nodes rather than HTML strings, so content
cannot become markup.
- A picture — drop the file in the folder and add a block to
works, with a fresh 8-characteruid. - A room — a new folder with its own
index.json. - The About room —
"type": "about", abodyarray of paragraphs, acontact, and acoverused as its hero.
Content ships inside the container image, so changing it means a commit and a
redeploy. There is no database and nothing to back up separately. A picture
listed but missing on disk is skipped with a warning; a malformed index.json
throws, so the container fails its readiness probe rather than serving a
half-built gallery.
npm ci
npm run dev # http://localhost:8080| Command | |
|---|---|
npm run build |
compile TypeScript into dist/ |
npm start |
run the compiled server |
npm test |
unit tests (vitest + supertest) |
npm run test:e2e |
Playwright; builds and starts its own server on the test fixtures (BASE_URL= to aim it at one already running) |
| npm run dev:fixtures | the same, against the test fixtures |
Configuration is an optional PORT (default 8080), an optional
ASSETS_DIR (default ./assets), and CONTENT_WATCH_MS (default 10000,
0 to switch it off). The server re-reads its content when the directory
changes, so editing a title or dropping in a picture needs no restart — and
if the new content will not parse, it logs why and keeps serving what it
already had.
The suites run against test/fixtures/assets — three rooms of solid-colour
images with hand-written metadata, chosen to exercise the cases rather than to
look like art: a landscape, a portrait, a square, one deliberately low-resolution
file, a sold work, a reserved one, one that is not for sale, a room that
promises something with a purchase, and a room with no works at all.
Nothing in the suite refers to the gallery's real content, so changing a price or a title can never fail a build, and the fixtures are safe to publish.
GET /— the gallery (?id=resolves a permalink)GET /buy/:room/:slug— a single-picture purchase pageGET /terms,GET /privacy— the two documents a payment processor asks forGET /health—{"status":"ok","service":"art","version":"…","rooms":4,"works":15}GET /assets/*— the pictures
Two things matter and both are invisible: the text is gzipped (compression
in src/app.ts), and the typefaces are served from public/fonts/ rather
than fetched from Google Fonts. That request was render-blocking on a third
origin — about 1.4s before a font file even started — and it disclosed every
visitor's IP to Google, which the privacy policy then had to admit. The faces
are the same, latin subset only; public/fonts/LICENSE.md records the
licences.
The small uppercase mono labels are deliberately below Lighthouse's 12px threshold. That is the design, and the audit is a blunt instrument: contrast and tap targets both pass, and accessibility scores 100.
Every page carries a Demo ribbon across the top right corner — bone with
dark text, the one thing on the site allowed to be loud. It is written into
the shell in src/views/layout.ts, not added by the client, so it is in the
markup a crawler and a reader with no JavaScript both get, and no page can be
built without one. It stays up in full screen: the moment someone is most
absorbed in a picture is not the moment to stop saying the shop does not
work. It is pointer-events:none, so it can never swallow a click meant for
the picture behind it.
The fill-the-screen button sits below it rather than on top of it, and
that is not a preference. #app is position:fixed, which opens a stacking
context, so the button's z-index is trapped inside #app and can never
paint above a sibling of it however large the number — and lifting #app
instead would bury the ribbon under the whole gallery. The offsets on .c-tr
are fixed pixels because the ribbon is a fixed size too.
Take it out when the site can take money.
Browsing is limited to 300 requests per five minutes per visitor
(src/ratelimit.ts). A cold browse of the whole gallery is around 30 requests:
the page, the bundle, the fonts, and one picture per work — the widths are a
srcset, so a browser fetches one of them each, not all. Even the pathological
case of fetching every URL the page names, all 155 width variants and all 15
/buy/ pages, comes to about 170 and still fits. A returning visitor costs far
less again, because the fingerprinted assets are cached for a year. The window is per address, not global: a hundred
people browsing at once each spend a fifth of their own budget and never meet.
RateLimit-Limit and RateLimit-Remaining come back on every counted
response.
The interesting part is which address it counts. Nothing reaches this process
directly — Traefik hands to Kourier, Kourier to Knative's queue-proxy sidecar,
and only then to us — so without trust proxy, req.ip is the sidecar: one
in-cluster address, the same for every visitor on the site. A limiter keyed on
that is a single global bucket, and a busy afternoon would 429 people who had
loaded three pages. It would test perfectly and fail only under load.
So app.set('trust proxy', …) takes a CIDR list of the cluster's networks
rather than a hop count. A count resolves the same address today and silently
returns the wrong one the day the chain gains or loses a hop; a list walks past
anything in-cluster and stops at the first address that is not ours.
Because that is the one way this middleware could cause the outage it exists to prevent, it does not merely assume the setting is right. If the address it resolves is still one of ours, it skips the request rather than counting it and logs why once. Failing open costs nothing on a public gallery; failing closed would cost the site.
/health is mounted before the limiter and so never reaches it. The
readiness probe polls it from inside the cluster for the life of the pod, and a
429 there marks the pod unready and has Knative restart it.
A phone was being sent a 3000px original to show in a 400px frame.
scripts/make-derivatives.sh writes smaller copies beside each picture — one
directory per width, keeping the filename:
assets/colors/IMG_7281.jpg the original, untouched
assets/colors/w640/IMG_7281.jpg …the copies…
assets/colors/w640/IMG_7281.webp …and the same again in WebP
assets/colors/w1024/… w1536/… w2048/… w2560/…
WebP is written at quality 85, which was chosen by measuring rather than by habit: across the collection it is 9–24% smaller than the JPEG beside it and scores higher SSIM against a lossless reference, so it is strictly better rather than a size-for-quality trade. Above 90 WebP comes out larger than the JPEG; below 82 it drops under it on quality.
Work.webp is true only when a WebP exists at every width, so the browser
switches format wholesale rather than per width. Real <img> elements get a
<picture> with a WebP <source> and a JPEG <img> inside, which needs no
JavaScript; CSS backgrounds are chosen in JavaScript, which asks the canvas
once whether WebP encodes. Both paths are tested, including a browser that
answers no.
It runs from sync-assets.sh, before anything is uploaded — content is not
part of a deploy any more, so that is the equivalent moment. Copies at or
above a picture's own width are never made, so a small picture simply has
none and is served whole.
The server records which widths exist (Work.widths) and the manifest ships
those numbers; the browser builds the path itself, the same rule that
keeps a hand-edited index.json from putting javascript: behind an image.
Real <img> elements get a srcset and let the browser choose; CSS
backgrounds are picked in JavaScript, where devicePixelRatio is known.
Two rules are worth keeping:
- The top of the ladder is the ceiling for anything on screen. A display wanting more than 2560px gets the 2560 copy, not the original: past that the extra pixels are invisible on a photograph and cost half again as many bytes.
- The original is what the download link serves, always, at full resolution, and always the JPEG that was shot — it is never converted. There is a test for it.
The ambient wash behind a picture is blurred past recognition, so it always takes the smallest copy no matter the screen. Menu thumbnails are 62px and take the smallest too — they used to load full-resolution originals.
Roughly, for the lobby: 3960KB before, 964KB on a phone, 1563KB on a tablet, 2239KB on a 2x laptop.
Every page carries Open Graph tags, so a link pasted into a chat or a social
post shows the picture rather than a bare URL. og:image is absolute — a
crawler has no page to resolve a relative URL against — and carries
og:image:width/height so a card can be laid out before the image arrives.
Those dimensions are read from each file's header at content load
(src/imagesize.ts, JPEG and PNG); there is no image library in this project
and no reason to add one for four numbers.
The interesting case is ?id=. The gallery is a single page for the whole
site and the browser resolves the permalink itself — but a crawler runs no
JavaScript, so without help every shared picture would preview as the same
generic gallery card. The server therefore resolves ?id= too and serves a
variant whose only difference is the head; src/views/shares.ts pre-renders
one per permalink when the content loads, about twenty copies of a 12KB page.
An unknown id falls back to the gallery and points og:url at /, so a
mistyped link is not indexed as a page of its own.
scripts/check-assets.ts warns about a picture over 5MB or under 200px on its
short side — both make a crawler drop the preview image. Warnings, not errors:
such a picture is still worth showing.
Both live in src/legal.ts as data, not markup, so the two pages render the
same way and the facts sit beside the constants they have to agree with — the
enquiry window, for instance, is read from ENQUIRY_HOURS rather than typed
out again. Edit the text there and change the UPDATED date with it.
They are rendered once at startup: nothing on the content volume can change them. Tests assert the claims that the code has to keep true — that no page sets a cookie, that Google Fonts is disclosed because the pages really do request it, and that no page anywhere asks for a card number.
$ASSETS_DIR/<room>/ content, from a volume — not from the image
public/app.css, app.js the gallery itself, served as static files
src/content.ts loads and validates the folders
src/views/ server-rendered shell, purchase page
The browser gets a manifest of identifiers, not URLs — a filename and a
slug — and builds every src and href from a fixed prefix plus
encodeURIComponent, so no index.json can put a javascript: URL behind a
link.
public/app.css and public/app.js are served immutable for a year, so their
URLs carry a content hash; without it a deploy would never reach a returning
visitor.
The pictures carry one too, for a different reason. They live on a volume
and are replaced without a deploy, always under the same filename —
make-derivatives.sh rewrites a derivative in place — so nothing about the
path says the bytes changed. versionOf in src/content.ts builds a
ten-character token from the size and mtime of the original and of every
derivative of it, and each picture URL carries it as ?v=. Change a picture
and its URL changes with it, which is what makes a year of immutable
caching safe rather than a way of pinning the old one forever.
The derivatives are folded into the token because they can change alone: a
FORCE=1 rebuild or a different quality setting rewrites the copies and never
touches the original. And it is a cache key rather than a lookup — /assets
ignores the query, so an old link still serves the current file.
/assets serves pictures and nothing else. Only .jpg, .jpeg, .png
and .webp are answered; everything else in a room directory is a 404. That
directory is filled by a content sync rather than by this repository, and it
holds index.json — the whole manifest, every uid and purchase_url, the
contact address, and the prices of sold work that the page deliberately never
serialises. It is an allowlist rather than a rule about index.json, so an
editor backup or a stray note does not become public by being copied next to
a picture.
The pages themselves are Cache-Control: no-cache — cached, but revalidated
every time, which the ETag makes a 304 with no body. A page names the
fingerprinted assets it needs, so serving a stale one would point at stale
immutable assets and strand the visitor on an old build with no way to reload
out of it. Safari on iOS is the browser most likely to try.
Everything the pointer or a drag moves is a spring stepped once per
requestAnimationFrame. A CSS transition on a value that pointer events
already rewrite every frame is what makes an interface like this feel choppy.
Tuning constants are at the top of public/app.js.
Pictures are fetched one at a time, nearest first, so the one on screen is not
sharing the connection with the ones behind it. On a 5 Mbps connection that
takes the first cover from ~6.8s to ~2.6s. The no-JavaScript fallback lives in
a <noscript>, so a normal visit never requests it — it used to pull every
picture in the gallery on first load. The gallery is small by design (tens of
pictures), so a simple queue is enough.
main— development, unprotected. A push builds and pushesghcr.io/klaushofrichter/art:mainand nothing else, and does not deploy. The production tags —:<sha>,:v<version>and:latest— are written by the deploy alone, so nothing can move the image the cluster pins.production— protected, PR-only frommain, withtest,codeqlande2eas required checks, enforced for admins too. Merging deploys via an in-cluster self-hosted runner and cuts a release.
Release notes are whatever sits under ## [Unreleased] in CHANGELOG.md,
then the commits since the last release. After the release, the deploy takes
the lines it published out of that section on main ("Clear the changelog
after vX [skip ci]"); scripts/check-changelog.sh still fails a PR into
production that would republish the previous release's notes, in case that
push ever fails.
Versions are generated at deploy time as vYYYY.MM.DD.N and baked in as
APP_VERSION; package.json carries no version. The running build is shown at
the bottom of the About room, linked to this repository.
Payment is not implemented. /buy/<room>/<slug> is a real page showing the
picture, its details and its price, but the only way to buy is an email
enquiry — there is no cart, no checkout, no payment provider and no order
record. The enquiry opens a mail client with the picture named, a request to
hold it for 48 hours, and its permalink, so a reply can be about one specific
work.
Sending one marks that picture Sale pending — but only in the sender's own browser. There is no server-side state to write to. A second visitor still sees the picture as available, and two people can both enquire. It is a reminder to the person who asked, not a reservation, and it clears itself after the same 48 hours the email asks for. A real hold needs persistence the site does not have.
Deciding what to do about that is the next piece of work. The intent is one
picture at a time rather than a basket, so the options are roughly: a payment
link per picture (Stripe Payment Links or similar, no server state), a hosted
checkout session (needs a secret and a webhook to mark a picture sold), or
keeping the enquiry-and-invoice flow as it is. The first of those is already
wired: every work carries a purchase_url, and /buy/:room/:slug redirects
to it whenever it differs from the canonical path, so pointing one at a real
payment link is a content edit and nothing else. Today they all hold the
canonical path, so nothing redirects.
Whichever is chosen, status in index.json stays the source of truth for
what is still for sale — and marking something sold is an edit on the content
volume, not a commit. The server re-reads the directory every
CONTENT_WATCH_MS (10s by default) and re-renders in place, so a sale takes
effect without a deploy.
Also open:
- One low-resolution source.
assets/food/IMG_8275.jpgis 269 × 202 — smaller than the narrowest derivative width, so it is the one picture with no sized copies at all and the only one still served as its original. It is visibly soft wherever it is scaled up, and wants re-exporting. - Placeholder metadata. Titles, dates and prices are invented and want replacing with real ones.
- No analytics or error reporting, deliberately, so nothing is known about how the site is used.
{ "collection": { "id": "colors", // must match the folder name "uid": "8ul97ls7", // permalink id, never change it "title": "Colors", "subtitle": "Acrylic on canvas", "description": "Small framed abstracts. Each is **one of one**.", "cover": "IMG_7281.jpg", // fronts the room in the lobby "order": 1 // position in the lobby }, "works": [ { "file": "IMG_7281.jpg", // the only link between JSON and image "uid": "leyb1brb", // permalink id, never change it "title": "Undertow", "date": "2024-03", // YYYY-MM or YYYY-MM-DD; shown as "March 2024" "artist": "Klaus Hofrichter", "medium": "Acrylic on canvas, gilt frame", "dimensions": "10 × 8 in", "description": "Worked *wet into wet*…", "edition": "Original · one of one", // optional, see below "price": 340, "currency": "USD", "status": "available", "purchase_url": "/buy/colors/undertow", // optional, see below "views": [ // optional, see below { "file": "IMG_8356.jpg", "kind": "framed", "caption": "Framed, on the wall" } ] } ] }