ADR-035: Server-Enriched SPA Shell for SEO
Context
The site is a client-rendered React SPA, so every URL returned the same index.html: one title, an empty root element, lang="en" on Spanish pages and status 200 for any path. Search engines, link-preview scrapers, recruiters' tools and AI assistants mostly read that raw HTML. Full server rendering would mean rewriting the app for a handful of routes.
Decision
Keep the SPA and enrich the shell per request in Express (every path reaches Cloud Run through the Firebase Hosting rewrite).
1. One URL table (src/routes.ts) shared by browser and server for paths, the /es prefix and page titles.
2. Correct status codes: 301 to the canonical form, a real 404 for unknown pages, and a plain 404 for missing asset files.
3. Per-route head: title, description, Open Graph and Twitter cards, canonical and hreflang links, JSON-LD, the right html lang, noindex on staging and 404s, with flag-aware wording.
4. A crawler digest: real per-route HTML inside the root element for clients without JavaScript, replaced when React mounts.
5. A generated sitemap with language alternates.
6. HTML revalidates within a minute; hashed assets are cached for a year. Tests keep the static fallback and the injected meta in sync.
Amended 2026-10-22: every ADR has its own page, /architecture/<adr-id>, with its own title, description, canonical and hreflang links, structured data and sitemap entry; readers without JavaScript get the full record.
Amended 2026-10-28: each section page and each ADR, in both languages, has its own link-preview card (label, title, status or detail line, name and headline), rendered at build time from src/data by satori and resvg into dist/og; og:image and twitter:image point at it, and the home page keeps the generic card.
Consequences
Benefits:
* Each page has its own title, preview card, language and status code, at little runtime cost.
* Readers without JavaScript, including AI assistants, get real content.
* No framework migration.
Trade-offs:
* Two renderings of the same content (React and the digest), both fed by src/data.
* A new route needs entries in the route table, the meta builder and the digest.
* HTML requests reach Cloud Run rather than a static CDN cache.
Alternatives considered
1. Full SSR or a framework such as Next.js: Rejected — a rewrite of routing, data loading and hydration for a few routes.
2. Static pre-rendering at build time: Rejected — content depends on feature flags that change without a rebuild, and it gives no real 404s or redirects.
3. Client-only head management: Rejected — most scrapers never run JavaScript.