ADR-0004: Web Frontend Stack — Static TypeScript SPA + Go BFF (stravin-web)¶
- Status: Accepted (Stack Defaults Locked)
- Date: 2026-11-26
- Scope: Web application runtime architecture, browser authentication boundary, real-time streaming proxy, modular frontend workspace structure, security headers, public SEO/OpenGraph unfurling, and local development parity across Stravin Core, Stravin Review, Stravin Run, Stravin Index, Stravin Gate, Stravin Auth, Stravin Notify, and Stravin Webhooks.
Context¶
Stravin's backend platform is written in Go and operates on a strict set of infrastructure and security boundaries established in prior ADRs and UI specifications:
- ADR-0001 established Cilium (eBPF) sidecarless SPIFFE mTLS for pod-to-pod workload identity, NATS JetStream for internal async events, Stravin Webhooks (
stravin-webhooks) for outbound customer delivery, and Temporal for Run and Gate durable workflows. - ADR-0002 defined the external runner seam, OIDC App authentication, and short-lived scoped tokens.
- ADR-0003 introduced
stravin-authas the sole token issuer with local JWKS verification, Valkeyjtideny-list revocation, andSTRAVIN_AUTHrevocation events. - UI Design Overview & Shell defines a GitHub-familiar, high-density developer experience spanning Pull Requests (
Stravin Review), Actions & Workflows (Stravin Run), Merge Queues (Stravin Gate), inline code intelligence (Stravin Index), and Settings (Auth,Gate,Webhooks,Notify,Runners).
Building the Stravin web application introduces five competing architectural requirements:
- Zero Node.js / Bun Runtime Fleet in Production: Operating, patching, and autoscaling a dedicated server-side JavaScript runtime tier solely to render an authenticated developer application adds operational overhead and failure modes that conflict with Stravin's lightweight, Go-first footprint (including single-host self-hosted and local Docker Compose parity).
- High-Interactivity Client Workflows: Core developer workflows—virtualized 10,000-line side-by-side diffs, inline review comment editors,
Stravin Indexsymbol hover/go-to-definition popovers, Stacked PR navigation strips, interactive Temporal Job DAG canvases, and instant tab switching (Conversation | Commits | Checks | Files Changed)—require rich client-side state and persistent WebSocket/SSE streams that must not tear down on navigation. - Browser-Safe Authentication & Multi-Tenant Isolation: Browser clients must never hold bearer tokens in
localStorageor JavaScript-accessible storage. Every backend request must cross Cilium mTLS with verified user identity and mandatory app-leveltenant_idpropagation. - Product Team Ownership Without MFE Fragmentation: Teams owning Review, Run, Gate, Index, and Settings need clear code ownership and small initial bundles without paying the runtime duplication, version skew, and shared-state fragmentation tax of Micro Frontends.
- Public Link Unfurling & SEO Without SSR Overhead: Public repositories, pull requests, and workflow pages still need accurate
<title>, meta descriptions, and OpenGraph (og:*) cards when shared in Slack, chat tools, or search engines.
Decision¶
We adopt a Static TypeScript SPA (React 19 + TypeScript + Vite + Tailwind CSS + @pierre/diffs, with lazy-loaded route modules) inside the stravin-dev/platform monorepo, paired with a Thin Go Backend-for-Frontend (stravin-web) using Protobuf + ConnectRPC (buf) contracts and running zero Node.js or Bun processes in production.
flowchart TB
subgraph Browser["Browser — Static React 19 SPA (Vite + Tailwind CSS, Zero Prod Node.js)"]
Shell["Unified Stravin Shell\n(Top Nav, Repo Header, Shortcuts,\nTheme Tokens, Live Toast/Inbox WS)"]
subgraph LazyModules["Lazy-Loaded Feature Packages (stravin-dev/platform Monorepo)"]
PkgReview["packages/review/\n(@pierre/diffs Virtualized Diffs,\nInline Comments, Stacked PR Strip)"]
PkgRun["packages/run/\n(Temporal DAG Canvas,\nLive Step Logs)"]
PkgGate["packages/gate/\n(Merge Queue, Policy Checks)"]
PkgIndex["packages/index-client/\n(Hover & Go-to-Def Popovers)"]
PkgSettings["packages/settings/\n(Auth, Gate, Webhooks, Notify)"]
end
Shell --> PkgReview
Shell --> PkgRun
Shell --> PkgGate
Shell --> PkgIndex
Shell --> PkgSettings
end
CDN["CDN or Go embed.FS\n(Immutable Hashed JS/CSS Assets)"]
subgraph WebBFF["stravin-web (Thin Go BFF — Protobuf + ConnectRPC)"]
AuthTerm["Cookie Session Termination\n(HttpOnly, Secure, SameSite=Lax + CSRF)"]
Aggregator["ConnectRPC Proxy & Read Aggregator\n(Mandatory App-Level tenant_id)"]
StreamProxy["WebSocket / SSE Stream Proxy\n(Logs, DAG, Queue, In-App Notify)"]
MetaInject["Thin Go HTML Meta / OpenGraph Injector\n(Public Repo & PR URLs)"]
SecHeaders["Strict CSP (Nonce/Hash), nosniff,\nReferrer-Policy, Markdown Sanitization"]
end
subgraph InternalMesh["Internal Platform Services (Cilium eBPF SPIFFE mTLS)"]
Auth["stravin-auth\n(Session Validation, JWKS, Valkey jti)"]
Notify["stravin-notify\n(In-App Inbox & WS/SSE Fan-Out)"]
Core["Stravin Core\n(Git Data / Diff / Metadata)"]
Review["Stravin Review\n(PRs, Threads, Stacked Diffs)"]
Run["Stravin Run\n(Workflows, Temporal DAG, Logs)"]
Index["Stravin Index\n(Symbol Hover, Definitions, Search)"]
Gate["Stravin Gate\n(Merge Queue, Branch Protection)"]
Webhooks["stravin-webhooks\n(Delivery History & Redelivery)"]
end
Browser -->|"Static Assets (HTTPS)"| CDN
Browser <-->|"HTTPS ConnectRPC /api/* (Cookie + CSRF)"| AuthTerm
Browser <-->|"WSS / SSE /ws/*"| StreamProxy
Browser -->|"GET Public Repo/PR HTML"| MetaInject
AuthTerm --> SecHeaders
AuthTerm --> Aggregator
AuthTerm <-->|"Session & Token Exchange"| Auth
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Core
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Review
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Run
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Index
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Gate
Aggregator <-->|"Cilium mTLS gRPC + tenant_id"| Webhooks
StreamProxy <-->|"Live CI Logs & DAG Events"| Run
StreamProxy <-->|"Merge Queue Updates"| Gate
StreamProxy <-->|"Live Inbox & Toast Stream"| Notify
1. Locked Frontend Stack & Zero Node.js Runtime in Production¶
- Build-Time Bundling Only: All TypeScript, CSS, and static assets are compiled once at CI time with Vite targeting React 19, strict TypeScript, and Tailwind CSS, with code-split lazy route modules.
- Code Diff Engine (
@pierre/diffs): The defaultCodeDiffRendereris powered by@pierre/diffs(diffs.com, Apache-2.0) providing Shiki syntax highlighting and virtualized split/unified diffs inside the lazy-loadedDiffRendererregistry. - Static Asset Delivery: Compiled assets are content-hashed and served either from a CDN edge (SaaS) or directly from Go's
embed.FScompiled into thestravin-webbinary (self-hosted and local Docker Compose). - Zero Production JS Server: No Node.js, Deno, or Bun runtime is deployed, patched, or scaled in production clusters. Every production web tier pod is a single static Go binary (
stravin-web).
2. Modular Monorepo (stravin-dev/platform) & Protobuf + ConnectRPC (buf)¶
Rather than splitting the UI into independently deployed Micro Frontends or maintaining hand-written OpenAPI specs across repositories, all upper platform services and the web workspace live in one stravin-dev/platform monorepo alongside standalone stravin-dev/core:
- Single API / BFF Contract (
bufProtobuf + ConnectRPC): One canonicalproto/schema generates both Go gRPC servers/clients (internal Cilium mTLS) and typed TypeScript ConnectRPC clients for React 19—eliminating hand-written OpenAPI drift betweenstravin-weband the browser. - Unified Stravin Shell: Owns the global top navigation bar, repository header, command palette and keyboard shortcuts, canonical Stravin theme/brand tokens (Tailwind CSS), and a single shared
stravin-notifyWebSocket/SSE connection for live in-app toasts and inbox counts. - Lazy-Loaded Product Feature Packages: Product domains live in isolated workspace packages loaded on demand per route:
packages/review/— Pull request list, virtualized@pierre/diffscode diffs, pluggableDiffRendererregistry, inline comment threads, and Stacked PR navigation strip.packages/run/— Workflow runs, runner pool badges, interactive Temporal DAG canvas, and streaming step log viewer.packages/gate/— Merge queue status, speculative batch views, and branch protection summaries.packages/settings/— Repository and organization settings forAuth,Gate,Webhooks,Notify, andRunners.packages/index-client/— Lightweight code intelligence client for symbol hover, go-to-definition popovers, and code search queries.
- Ownership Without Runtime Tax: Each package has explicit
CODEOWNERS, independent unit tests, and generated ConnectRPC client interfaces while sharing one framework version (React 19), one router, one design system (Tailwind CSS), and one client cache—avoiding MFE bundle duplication, shared-state fragmentation, and cross-team version skew.
3. Thin Go BFF (stravin-web) Responsibilities¶
stravin-web is a stateless, thin Go Backend-for-Frontend that sits between the browser and the Cilium eBPF service mesh. It owns four focused responsibilities and zero product domain business logic:
- Browser Authentication Termination & CSRF Protection:
- Terminates browser login flows with
stravin-auth(ADR-0003) and issuesHttpOnly,Secure,SameSite=Laxsession cookies. - Access tokens, refresh tokens, and internal JWTs are NEVER stored in
localStorage,sessionStorage, or any JavaScript-readable cookie or DOM attribute. - Enforces strict CSRF protection on all state-changing HTTP requests (
POST,PUT,PATCH,DELETE) viaOrigin/Sec-Fetch-Siteverification paired with a per-session CSRF token header.
- Terminates browser login flows with
- Read Aggregation & Mandatory
tenant_idPropagation:- Aggregates read-heavy composite views (for example, PR header + checks summary + merge-queue status + review threads) over Cilium eBPF mTLS gRPC/HTTP to
Core,Review,Run,Index,Gate,Auth,Notify, andWebhooks. - Validates the user session locally via
stravin-authJWKS + Valkeyjtideny-list checks and propagates verifiedprincipal_idand mandatory app-leveltenant_idon every downstream RPC.
- Aggregates read-heavy composite views (for example, PR header + checks summary + merge-queue status + review threads) over Cilium eBPF mTLS gRPC/HTTP to
- Real-Time WebSocket / SSE Stream Proxying:
- Proxies authenticated WebSocket and Server-Sent Events (SSE) streams from internal services to the browser for:
- Live
Stravin RunCI step logs and Temporal Job DAG state transitions. Stravin Gatemerge-queue position and speculative batch updates.stravin-notifyreal-time in-app inbox updates and toast popups.
- Live
- Subscribes to
STRAVIN_AUTHrevocation events (principal.revoked,principal.role_changed) so compromised or deprovisioned browser streams are terminated within seconds.
- Proxies authenticated WebSocket and Server-Sent Events (SSE) streams from internal services to the browser for:
- Thin Go HTML Meta-Tag / OpenGraph Injection:
- For public repository and pull request URLs,
stravin-webperforms a lightweight metadata lookup and injects<title>,<meta name="description">, and OpenGraph (og:title,og:description,og:url,og:image) tags directly into the staticindex.htmltemplate in Go before flushing the response. - Private or unauthenticated repository URLs emit generic non-leaking metadata only, preventing repository or PR title disclosure to unfurling bots.
- For public repository and pull request URLs,
4. High-Interactivity Client Capabilities & Responsive Breakpoints¶
The SPA architecture directly supports the dense interactive surfaces specified in the UI Design docs:
- Virtualized Diffs & Review (
Stravin Review): Windowed side-by-side and unified diff rendering for 10,000+ line changes, inline review comment threads, draft batching, and the Stacked PR navigation strip. - Inline Code Intelligence (
Stravin Index): Low-latency hover cards, go-to-definition popovers, and cross-file reference jumps triggered directly inside diff and blob views. - Interactive Temporal DAG Canvas (
Stravin Run): Pan/zoom job dependency graph with live node status updates and streaming ANSI step logs without page reloads. - Full-Width Responsive Breakpoints: Layout adapts cleanly across four canonical viewport tiers without horizontal overflow:
<768px(mobile: collapsed nav drawer, unified diff default, stacked summary cards).768-1023px(tablet: compact header, collapsible metadata rail).1024-1439px(compact desktop: standard two-column PR/run layouts).>=1440px(wide desktop: full-width side-by-side diffs and expanded DAG canvas).
Pluggable Diff Renderer Seam (packages/review/src/diff/)¶
To support code diffs at launch, image diffs in Phase 2, and future rich file types (Markdown, CSV/tabular, structural JSON/YAML, sandboxed SVG, notebooks, PDF) without modifying the PR Review shell or Core Git API, packages/review/src/diff/ defines a priority-ordered DiffRenderer registry:
export interface DiffFileDescriptor {
path: string;
oldPath?: string;
changeKind: "add" | "modify" | "delete" | "rename";
mimeType: string;
extension: string;
isBinary: boolean;
oldBlobOid?: string;
newBlobOid?: string;
oldSizeBytes: number;
newSizeBytes: number;
hunks: DiffHunk[]; // empty ([]) for binary / non-text files
}
export interface DiffRendererProps {
file: DiffFileDescriptor;
viewMode: string;
blobUrl: (blobOid: string) => string; // stravin-web BFF blob proxy URL
onComment: (anchor: LineAnchor | RegionAnchor | FileAnchor) => void;
}
export interface DiffRenderer {
id: string;
priority: number; // highest matching priority wins; BinaryMetadataRenderer is lowest fallback
matches: (file: DiffFileDescriptor) => boolean;
capabilities: {
inlineComments: "line" | "region" | "file-only";
viewModes: string[];
};
load: () => Promise<{ default: ComponentType<DiffRendererProps> }>;
}
- Zero-Cost Lazy Chunks (Vite Code-Splitting): Each
DiffRenderer.load()wraps a dynamicimport()so Vite emits an isolated chunk per renderer. Pure code PRs never download image diffing, notebook, or PDF codec bundles. - Uniform Shell Chrome: The Review shell owns the file-card header (path,
+N / -Mor byte delta,capabilities.viewModespill,Viewedcheckbox,Rawlink) and mounts the matched renderer inside the body slot. - Security Invariant (BFF Blob Proxy & Sandboxed Rendering): Binary, image, SVG, and document blobs are fetched exclusively through
stravin-web's authenticated blob proxy (GET /api/v1/repos/{tenant}/{repo}/blobs/{oid}backed byGitData.GetBlob) withX-Content-Type-Options: nosniff, strict CSP (default-src 'none'; sandbox), and sandboxed rendering (<img />,<canvas>, orsandbox=""iframe) so inline<script>inside SVGs or HTML files can never execute in the application origin.
5. Strict Security Headers & Content Boundaries¶
stravin-web enforces defense-in-depth browser security controls on every response:
- Strict
Content-Security-Policy: Per-request cryptographic nonce or build-time hash-based script policy with zerounsafe-inlinescripts,object-src 'none',base-uri 'self', and strictframe-ancestors 'none'(clickjacking protection). - Hardened Standard Headers:
X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-origin, andStrict-Transport-Securityon TLS origins. - Untrusted User Content Sanitization: All user-authored Markdown (PR descriptions, review comments, READMEs) and diff content pass through strict HTML sanitization with safe URL scheme allowlists (
https,http,mailto) before rendering, preventing stored XSS and CSS exfiltration.
6. Local Development Parity¶
- UI developers run
vite devlocally, which proxies/api/*and/ws/*directly to the localstravin-webGo BFF running inside Docker Compose (alongsidestravin-auth, Floci, Valkey, and Core/product daemons). - This delivers sub-second Hot Module Replacement (HMR) for frontend iteration while exercising the exact same Go BFF auth cookies, CSRF checks, API aggregation, and WebSocket/SSE proxy code paths that run in production—with zero Kubernetes or Node.js production parity gap.
Alternatives Considered¶
| Alternative | Summary | Why Rejected |
|---|---|---|
| Micro Frontends (Module Federation / Single-SPA / iframes) | Deploy Review, Run, Gate, and Settings as separate runtime frontend bundles composed in the browser. | Premature org-scaling tax; fragments shared shell state (auth session, repo header, live notifications, keyboard shortcuts), duplicates framework/design-system bundles, and introduces cross-team runtime version skew. |
| SSR Meta-Framework (SvelteKit / TanStack Start / React Router SSR on Node/Bun) | Run a production Node.js or Bun SSR server tier in front of the Go backend services. | Deferred / not chosen as default; introduces a separate Node/Bun runtime fleet to operate, secure, and autoscale when an authenticated developer tool only needs thin Go OpenGraph/SEO meta injection on public URLs. |
| AstroJS with Server Islands (MPA + Islands) | Multi-page HTML architecture with isolated interactive islands hydrated per page. | Rejected for the core app; full-page navigations drop persistent WebSocket/SSE connections (live CI logs, notifications) and degrade high-interactivity tab switching (Conversation \| Commits \| Checks \| Files Changed). Ideal for stravin.dev marketing and docs (stravin-dev/website), not the main application. |
Go-Native HTML (templ + HTMX / Datastar) |
Render all application views as server-driven HTML fragments from Go with minimal client JavaScript. | Rejected for the full app; strong fit for Settings and simple tables, but virtualized 10k-line diffs, inline review editors, Stravin Index symbol popovers, and interactive Temporal DAG canvases require a rich client-side TypeScript runtime anyway. |
Consequences¶
Positive¶
- Single-language production operations: Production clusters run only Go services (
stravin-web+ Core/platform daemons) and static CDN/embedded assets—zero Node.js/Bun pods to size, monitor, or patch. - Persistent real-time UX: Client-side routing keeps WebSocket/SSE connections alive across tab switches (
Conversation | Commits | Checks | Files Changed) and repository navigation. - Strong browser security posture:
HttpOnly/Secure/SameSite=Laxcookies keep credentials out of JavaScript reach, whilestravin-webcentralizes CSRF enforcement, strict CSP headers, andtenant_idpropagation. - Fast local iteration with prod parity:
vite devHMR + Docker Composestravin-weblets frontend and backend engineers iterate locally without Kubernetes or separate SSR servers. - Clean team scaling: Modular workspace packages (
packages/review/,packages/run/,packages/gate/,packages/settings/,packages/index-client/) provide clear ownership and small initial bundles without MFE complexity.
Negative / Trade-offs¶
- No full HTML SSR for complex dynamic pages: Public repository and PR pages get rich
<title>and OpenGraph meta tags via thin Go HTML injection, but full interactive page rendering happens client-side after the initial JS bundle loads (mitigated by route-level code splitting and CDN caching). - Thin BFF maintenance surface:
stravin-webmust stay strictly a thin aggregation/auth/proxy layer; discipline is required so product domain rules remain inReview,Run,Gate,Index, andCorerather than leaking into BFF handlers. - Client bundle discipline: A unified SPA requires CI bundle-size budgets and strict lazy-loading boundaries so heavy surfaces (such as the Temporal DAG canvas or diff highlighter) never bloat the initial shell payload.
Undo / Rollback Path¶
- Future SSR Adoption Without Backend Churn: Because
stravin-webterminates browser auth and communicates with all backend products over typed Cilium mTLS gRPC/HTTP contracts, introducing a Node.js/Bun SSR frontend (e.g., SvelteKit, TanStack Start, or React Router SSR) later—either globally or for specific public-facing routes—requires zero changes to any backend product contract (Core,Review,Run,Index,Gate,Auth,Notify,Webhooks). - Framework or Asset-Hosting Flexibility: Static assets are decoupled behind
stravin-web/ CDN routing, allowing independent migration betweenembed.FSand external CDN origins or incremental UI framework changes without altering API or auth boundaries.
Related Documents¶
- ADR-0001: Platform Transport, Internal Events, External Webhooks, and Durable Workflows — Cilium eBPF mTLS, NATS JetStream,
stravin-webhooks, and Temporal boundaries. - ADR-0002: External Runner Seam, State-Machine Ownership, and OIDC App Authentication — External runner pools, OIDC App control plane, and scoped token boundaries.
- ADR-0003: Platform IAM, Authentication, STS, and Pluggable SSO Seam (
stravin-auth) — Standalone-first IAM, local JWKS + Valkeyjtideny-list, andSTRAVIN_AUTHrevocation events consumed bystravin-web. - UI Design Overview & Shell — Canonical Stravin brand tokens, shell architecture, and GitHub ⟷ Stravin UX mapping.
- Platform Products ⟷ Stravin Auth Interface — Session, JWKS, and revocation contracts used by
stravin-web. - Platform Events ⟷ Stravin Notify Interface — In-app inbox and WebSocket/SSE notification delivery proxied through
stravin-web. - Full-Stack Build Waves — 4-wave implementation plan taking Stravin from
stravin-dev/corev1.12.1to the fullstravin-dev/platformstack and React 19 web UI.