Markdown Editor

Frontend Architecture Document Template

Web frontend architecture: rendering per route, state, data caching, design system, Core Web Vitals budgets, a11y, i18n, CSP, RUM

Architektur & SystemdesignVollständigCore Web Vitals (web.dev); WCAG 2.2 AAfrontendmath

Anleitung: Use for a new web application or a major frontend re-architecture. Start with users, devices and networks, then choose a rendering strategy per route and set performance budgets before building. The main pitfall is unenforced budgets; gate them in CI and re-check Core Web Vitals thresholds on web.dev.

Vorschau

Frontend Architecture: [Web application name]

Frontend architecture document for a web application: rendering strategy, framework and state management, routing, data fetching and caching, component architecture and design system, micro-frontends, performance budgets with Core Web Vitals targets, accessibility, internationalisation, security, testing, build and deployment, observability and browser support. Based on common industry practice, Google's Core Web Vitals (LCP, INP and CLS, as published on web.dev, checked October 2026) and WCAG 2.2 level AA. Replace every [bracketed] value and every row marked Example; the examples follow a retail web shop with a logged-in account area.

Document control

FieldValue
Document ID[FEA-001]
Application[Name and URL]
Version[0.1]
Status[Draft / In review / Approved / Superseded]
Author(s)[@frontend-architect]
Reviewers[@design-system-lead], [@security], [@accessibility-lead], [@sre]
Last updatedYYYY-MM-DD
Classification[Internal]
Related[System design], [Design system docs], [ADRs], [Performance budget dashboard]

Approvals

RoleNameDecisionDate
Engineering lead[@name][Approved / Changes requested]YYYY-MM-DD
Design lead[@name][Decision]YYYY-MM-DD
Security[@name][Decision]YYYY-MM-DD
Accessibility[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft
0.2YYYY-MM-DD[@name]Example: Product pages moved from SSR to ISR after cache-hit analysis
1.0YYYY-MM-DD[@name]Example: Approved

Contents

1. Introduction

1.1 Purpose and scope

This document defines the frontend architecture of [Application]: how pages are rendered and delivered, how code is organised, and the quality targets every team building on it must meet. It covers [scope]. Example: the public shop (home, category, product, search, cart, checkout) and the account area; the internal back office is out of scope.

1.2 Context

The diagram shows the frontend in its environment.

1.3 Users, devices and networks

SegmentShare of sessionsTypical deviceNetworkNotes
Example: Mobile shoppers68%Mid-range Android, 4 GB RAM4G, variablePrimary design target
Example: Desktop shoppers27%Laptop, recent Chrome or SafariBroadbandLarger baskets
Example: Tablet5%iPadWi-Fi
[Segment][%][Device][Network][Notes]

2. Architectural drivers

IDDriverTargetPriority
FE-01Example: Search engine visibility of product and category pagesFull HTML on first response; structured dataMust
FE-02Example: Core Web Vitals "good" for 75% of mobile page loadsSee section 9Must
FE-03Example: AccessibilityWCAG 2.2 level AAMust
FE-04Example: Independent releases by 4 product teamsDeploy without cross-team coordinationShould
FE-05Example: 6 languages, 4 currenciesSee section 11Must
FE-06Example: Price changes visible within 60 sCache invalidationMust
[FE-nn][Driver][Target][Priority]

3. Rendering strategy

3.1 Options

StrategyHow it worksStrengthsWeaknesses
CSR (client-side rendering)Browser downloads JavaScript that renders the pageSimple hosting; rich interactivitySlow first content on weak devices; weak SEO without extra work
SSR (server-side rendering)Server renders HTML per request, then the client hydratesFresh, personalised, crawlable HTMLServer cost per request; time to first byte depends on back end
SSG (static generation)HTML built at build time and served from CDNFastest delivery; cheapestContent stale until rebuild; build time grows with pages
ISR (incremental regeneration)Static pages regenerated after a time or on demandNear-static speed with freshnessBrief staleness; framework-specific behaviour
Streaming SSRServer sends HTML in chunks as data resolves; slow parts arrive laterEarly first paint with dynamic dataMore complex error and loading states

3.2 Decision per route

RouteStrategyRevalidationReason
Example: / homeISR5 min and on CMS publishMostly editorial, high traffic
Example: /c/[category]ISR10 min and on catalogue eventSEO; many pages
Example: /p/[product]ISR plus client fetch for stock and priceOn price or stock event (60 s target)SEO with fresh commercial data
Example: /searchStreaming SSRn/aQuery-dependent; results stream after header
Example: /cart, /checkoutSSR, no cachingn/aPersonal and transactional
Example: /account/*CSR inside SSR shelln/aBehind login; no SEO
[Route][Strategy][Rule][Reason]

4. Framework and state management

ItemChoiceRationale
FrameworkExample: [React meta-framework] with server componentsSupports all strategies in section 3 per route
LanguageTypeScript, strict modeType safety across API contracts
StylingExample: Design system tokens plus CSS modulesNo runtime CSS-in-JS cost
State typeWhere it livesExample
Server stateServer components or data-fetching cacheProduct, prices, orders
URL statePath and query stringFilters, sort, page number
Form stateForm library, local to the formCheckout address
UI stateComponent stateOpen menus, tabs
Global client stateExample: Small store for cart count and session flagsCart badge

Rule: do not copy server data into a global store; read it from the cache so there is one source of truth.

5. Routing

TopicDesign
Route definitionExample: File-system routing; one folder per route segment
Locale in URL/{locale}/..., for example /de/p/blue-shirt-1042
Canonical URLsOne canonical per product; hreflang alternates per locale
RedirectsManaged in a redirect table; permanent redirects for retired URLs
Error routesCustom 404 and 500 pages, server-rendered, under 50 KB
Code splittingAutomatic per route; heavy widgets loaded on interaction
PrefetchingLinks in viewport prefetched on fast connections only

6. Data fetching and caching

LayerWhat is cachedLifetimeInvalidation
CDNExample: ISR HTML, static assetsAssets 1 year (hashed names); HTML per section 3Purge by tag on catalogue events
Frontend serverFetch results per request and per tag60 s for pricesTag revalidation from webhook
Browser HTTP cacheStatic assets1 year, immutableNew hash per build
Client data cacheAPI responses in the data-fetching libraryStale after 30 s; refetch on focusMutation updates cache

API access: all client calls go to the backend for frontend (BFF), which shapes responses for screens and keeps tokens server-side. Errors follow a single problem-details format and map to user-facing messages.

7. Component architecture and design system

LayerContentRules
Design tokensColour, spacing, typography, motionOnly source of visual values
PrimitivesExample: Button, Input, Dialog from the design system packageAccessible by default; no product logic
PatternsProduct card, price, address formBuilt from primitives; shared across teams
FeaturesCart drawer, product galleryOwned by one team; may fetch data
PagesRoute componentsCompose features; minimal logic

Design system: [package name and version policy]. Example: published as a versioned package; product teams upgrade within two minor versions; visual regression tests on every component; components documented with usage, accessibility notes and do and don't examples.

8. Micro-frontends

Decision: [Used / Not used]. Example: Not used for the shop. The four teams work in one repository with route-level ownership (CODEOWNERS) and independent feature flags, which meets FE-04 without the duplicated dependencies and integration cost of runtime composition. Revisit if the number of teams exceeds eight or if a separately released partner area is added.

If used: aspectDesign
Composition[Build-time packages / server-side composition / runtime module federation]
Shared dependencies[Framework singleton policy]
Cross-app communication[URL and custom events only]
Consistency[Shared design system version range]

9. Performance budgets and Core Web Vitals

9.1 Core Web Vitals targets

Thresholds for "good" as published on web.dev at the time of writing, measured at the 75th percentile of page loads:

MetricMeasuresGoodOur target (mobile p75)
LCP (Largest Contentful Paint)Loading: when the main content is visible<= 2.5 sExample: <= 2.0 s
INP (Interaction to Next Paint)Responsiveness to user input across the visit<= 200 msExample: <= 150 ms
CLS (Cumulative Layout Shift)Visual stability<= 0.1Example: <= 0.05

Supporting metrics: TTFB (time to first byte) Example: <= 0.8 s and FCP (first contentful paint) Example: <= 1.5 s, used for diagnosis.

9.2 Resource budgets

Page typeJS (compressed)CSS (compressed)Images above the foldRequests before LCP
Example: Product page170 KB40 KB120 KB15
Example: Category page150 KB40 KB200 KB18
Example: Checkout200 KB40 KB20 KB12
[Page][KB][KB][KB][n]

Budget reasoning: download time for a resource of size SS kilobytes on bandwidth BB kilobits per second is

t=8 SBt = \frac{8\,S}{B}

Example: 170 KB of JavaScript on a 1.6 Mbit/s connection takes t=8×170/1,600=0.85t = 8 \times 170 / 1{,}600 = 0.85 s before parsing and execution, which is why the JavaScript budget is the tightest constraint on LCP and INP.

Enforcement: [tool and gate]. Example: bundle size check and lab performance run on every pull request; build fails above budget; field data reviewed weekly.

10. Accessibility

TopicPractice
TargetWCAG 2.2 level AA
Built inAccessible design system primitives; semantic HTML first; visible focus; target sizes meet WCAG 2.2 minimums
Automated testsExample: axe-core in component and end-to-end tests; zero serious or critical violations allowed
Manual testsKeyboard-only and screen reader (NVDA, VoiceOver) passes on key journeys each release
ContentAlt text rules; heading structure; link text guidelines
StatementPublic accessibility statement with contact route

11. Internationalisation

TopicDesign
LocalesExample: en, de, fr, nl, pl, es
Message formatICU message syntax with plurals and placeholders
FormattingIntl APIs for numbers, currency, dates
Translation workflowKeys extracted in CI; translation platform; missing keys fail release for Must locales
LayoutAllow 40% text expansion; no text in images; right-to-left ready (logical CSS properties)
InputHandle IME composition events in search and forms

12. Security

TopicDesign
Content Security PolicyExample: Nonce-based script-src with strict-dynamic; object-src 'none'; frame-ancestors 'none'; report endpoint
XSS preventionFramework escaping by default; raw HTML only through a sanitiser with an allow-list; lint rule bans unsafe APIs
AuthenticationSession in HttpOnly, Secure, SameSite=Lax cookies; no tokens in local storage
CSRFSameSite cookies plus CSRF token on state-changing requests
Third-party scriptsAllow-list reviewed by security; loaded with integrity where static; none on checkout except payment provider
Dependency policyLockfile committed; automated vulnerability scanning; new dependencies reviewed for maintenance and licence
Other headersHSTS, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, Permissions-Policy

13. Testing strategy

LayerScopeToolingGate
UnitUtilities, hooks, formattersExample: VitestEvery pull request
ComponentComponents with interactions and accessibilityTesting Library, axe-coreEvery pull request
Visual regressionDesign system and key pagesScreenshot comparisonEvery pull request
ContractBFF responses match frontend typesSchema testsEvery pull request
End-to-endSearch, add to cart, checkout, loginPlaywright, 3 browser enginesBefore production
PerformanceLab vitals and budgetsLab performance runnerEvery pull request

14. Build and deployment

TopicDesign
BuildExample: Single pipeline; type check, lint, tests, build, budgets
ArtefactContainer image for the frontend server plus hashed static assets uploaded to CDN
EnvironmentsPreview per pull request; staging; production
ReleaseCanary to 5% of traffic for 30 minutes, automatic rollback on error-rate or vitals regression
Feature flagsServer-evaluated flags for unfinished features
RollbackRedeploy previous image; static assets of previous build kept for 30 days

15. Observability

SignalCollectedUse
RUM Core Web VitalsExample: LCP, INP, CLS per route, device class and country, sampled 10%Field performance tracking against section 9
JavaScript errorsMessage, stack (source-mapped), route, releaseError budgets per release
Server telemetrySSR duration, cache hit rate, upstream latencyDiagnose TTFB
Business signalsFunnel steps (aggregated)Detect checkout regressions

Privacy: [rules]. Example: no personal data in RUM payloads; IP addresses truncated; collection follows the consent settings; data retained 13 months.

16. Browser and device support

TierBrowsersCommitment
Full supportExample: Last 2 versions of Chrome, Edge, Firefox, Safari (macOS and iOS); Samsung Internet latestAll features; tested in CI
FunctionalOlder versions with > 0.5% of our trafficCore journeys work; visual differences accepted
UnsupportedBrowsers without ES2020 modulesPlain upgrade message; checkout still reachable as HTML form where possible

Review: browser list updated each quarter from analytics; build targets generated from the same list.

17. Decisions, risks and open questions

IDItemTypeStatus or mitigationOwner
ADR-021Example: ISR for product pages with client-side price and stockDecisionAccepted[@name]
ADR-022Example: No micro-frontends for the shopDecisionAccepted[@name]
R-01Example: Third-party tag growth breaks the JavaScript budgetRiskTag governance and budget gate[@name]
OQ-01Example: Should search use edge rendering in the next phase?QuestionPrototype in Q2[@name]
[ID][Item][Decision / Risk / Question][Status][@name]

Standard and licence note

Based on common industry practice for frontend architecture. Core Web Vitals metrics and "good" thresholds are as published by Google on web.dev (LCP, INP and CLS; checked October 2026), and accessibility targets refer to W3C WCAG 2.2 level AA; verify both before each revision. Original text written for this collection; examples are illustrative. Template licence: MIT.

Ähnliche Vorlagen