문제: 경로 정본은 계약의 `routes[*].path`인데, 샘플 페이지가 같은 경로를
문자열로 8곳에 다시 적는다(목록 2, 상세 1, 폼 3, 상태 1, 실패 행동 1).
route 입력은 `routeInput.search as ReferenceListFilters`와
`String(route.params.resourceId)`로 cast한다. 계약에서 경로만 바꾸면 tsc는
통과하고 링크는 NOT_FOUND로 간다. 문서(routing-pages-and-patterns 4.2절,
10절 4단계)는 codec 기반 builder와 cast 금지를 권하는데, 샘플이 반대
패턴을 보여 주고 복사되는 기능이 그 습관을 가져간다.
고른 방법: 이미 있는 URL builder를 쓴다.
- `buildRouteUrl(routeId, input, featureCodecs)`(`src/presentation/routes/
route-codecs.ts`)가 route ID로 계약 `path`를 찾고, 라우터가 parse에 쓰는
같은 codec으로 직렬화한다. canonical redirect도 이 함수를 쓴다.
`src/platform`에는 URL builder가 없다. 그래서 플랫폼에 새 공개 헬퍼를
더하지 않았다.
- 기능 쪽 helper는 `presentation/reference-routes.ts`에 둔다.
- `referenceRouteUrl(routeId, input)`: `buildRouteUrl`에 이 기능의
codec을 넘기는 한 줄 래퍼다. routeId는 이 기능 계약의 키로 좁힌다.
- `useReferenceListFilters()`, `useReferenceResourceId()`: 라우터가 이미
통과시킨 route 입력을 같은 codec으로 다시 parse해서 codec의 출력
타입을 얻는다. cast가 없다. 목록 필터는 `useMemo`로 묶어 route 입력이
그대로면 같은 객체를 준다.
- `REFERENCE_FEATURE_ROUTE_CODECS`를 `reference-feature-runtime.ts`에서
새 `presentation/reference-route-codecs.ts`로 옮겼다.
- runtime 파일이 페이지를 lazy import하므로, 페이지 쪽이 runtime 파일에서
codec을 가져오면 순환 의존이 된다.
- codec 표를 helper 파일에 같이 두지 않은 이유: 그러면
`context-routes.ts`가 router의 builder·hook까지 끌어와 초기 JS가
585 B 늘었다(204,809 B로 예산 204,800 B 초과). 분리하면 475 B다.
- `context-routes.ts`와 `reference-contract.test.ts`는 새 위치에서
가져온다.
- 페이지 8곳을 route ID 호출로 바꿨다. 기능 presentation에 `"/examples/`
문자열이 0건, route 입력 cast가 0건이다. 남은 `"/examples/` 4건은 계약의
`path`(정본)다.
- 기능 README에 helper 위치와 쓰는 법을 적었다.
버린 대안:
- 리뷰 (b)처럼 기능 안에 경로 치환·직렬화를 새로 쓰는 헬퍼: 라우터와 같은
일을 두 번 구현한다. 플랫폼 builder가 이미 route ID와 기능 codec을 받는다.
- 리뷰 (c)처럼 `buildRouteUrl`의 input 타입을 route ID별로 좁히기: 플랫폼은
기능 codec 타입을 모른다(15-01 이후 codec은 지연 적재). 라우터 API
변경이라 이 발견 범위를 넘는다.
- 플랫폼 `useRouteInput`을 제네릭으로 바꿔 타입 단언하기: 런타임 검사 없는
단언이라 cast를 다른 이름으로 옮길 뿐이다.
위험·한계:
- 목록 링크가 이제 정식 URL(`/examples/reference-resources?limit=20`)을
가리킨다. 전에는 `?limit` 없는 주소로 갔다가 라우터가 같은 URL로
replace했다. 도착 URL과 history 항목 수는 같다. 폼의 "목록을 새로
불러와 확인" 링크 href 기대값을 이 값으로 바꿨다.
- `buildRouteUrl`은 codec이 거절하는 입력에 예외를 던진다. 백엔드가
공백만 있는 id를 주면(DTO는 `min(1)`, route codec은 trim 후 `min(1)`)
목록 렌더가 기능 오류 경계로 간다. 전에는 링크가 잘못된 주소 화면으로
갔다. DTO와 route codec의 id 규칙 차이는 이 변경 전부터 있다.
- route 입력을 한 번 더 parse한다. 값이 작아 비용은 무시할 만하다.
- 초기 JS gzip이 204,224 B에서 204,699 B로 475 B 늘었다(예산 204,800 B,
여유 576 B → 101 B). 새 코드가 초기 청크에 들어간 것이 아니다.
`route-codecs.ts`는 원래 초기 청크에 있었다. 페이지가 이 모듈을 import하자
rolldown이 `boot` 청크에 있던 것을 공유 청크(`route-input`)로 옮기고,
`route-input`과 `server-state-scope-provider`를 두 청크로 나눴다. 늘어난
양은 청크 분리 비용이다. 예산 값은 바꾸지 않았다.
- 페이지 테스트의 진입 URL 문자열은 그대로 뒀다. 테스트가 경로를 적는
것은 이 발견의 완료 기준 밖이다.
- 상태 페이지의 `(state as ReferenceSupportState)`는 history state 처리라
route 입력 cast가 아니다. 그대로 뒀다.
검증:
- RED(수정 전): 새 `tests/features/reference-feature/
reference-route-links.test.tsx`는 계약의 네 경로를 모두 옮긴(vi.mock)
상태로 목록→상세→목록→폼→목록, 목록→지원 페이지→목록을 걷는다.
2개 모두 실패했다. 상세 링크가 `href=".../items/reference-1"`(기대
`.../entries/reference-1`), 지원 페이지 대신 NOT_FOUND가 나왔다.
- GREEN(수정 후): 같은 테스트 2개 통과. `tests/features/reference-feature`
18 files 89 tests 통과(href 기대값 1곳 변경 뒤).
- 회귀: tests/features, tests/component, tests/architecture, tests/scale,
관련 unit 3개, generator 테스트 81 files 464 tests 통과. 첫 실행에서는
부하(평균 23~35)로 타임아웃 2건(app-build-input,
global-local-independence)이 났고, 단독 재실행과 최종 재실행에서 통과했다.
- 초기 JS gzip(`scripts/build-frontend.ts` 후 check-bundle과 같은 분류로
측정): 수정 전 204,224 B, 수정 후 204,699 B.
- `tsc` app·test·node 통과. 바꾼 파일 `eslint --max-warnings=0` 통과.
- `check-architecture.ts`(pnpm 대신 exec 전용 shim): 381 modules,
순환·위반 없음, rc=0. `verify-documentation-readiness` PASS_SCOPED,
`check-i18n` PASS.
- 페이지 테스트 harness(`renderReference`, `inputWith`)는 새 테스트와
함께 쓰도록 `reference-page-harness.tsx`로 옮겼다. 내용은 그대로다.
Refs: docs/reviews/2026-11-01-maturity-review/16-structure-patterns.md 16-04
Clean Architecture Frontend Template
A React/Vite reference implementation where architecture boundaries, integration behavior, release coherence, accessibility, performance, and operations are executable contracts rather than conventions.
Start locally
Requirements: the exact Node.js version in .nvmrc (currently 24.14.0) and
Corepack. The repository pins pnpm in package.json.
Product source, tests, build/quality scripts, and supported tool configuration
are TypeScript/TSX. allowJs is disabled. Node-side .ts scripts run directly
on the pinned Node 24 runtime and are checked with NodeNext resolution plus
erasable-syntax enforcement. Project-owned executable source contains no
JavaScript-family files; negative architecture, security, and type-compatibility
fixtures are TypeScript/TSX as well.
corepack pnpm install --frozen-lockfile
corepack pnpm dev
Runtime configuration
Runtime-public settings are validated against one schema before the product
tree mounts (runtimeConfigV2ArtifactSchema in
src/contracts/release-artifacts.ts). Client secrets are forbidden.
The source of truth is config/runtime/<profile>.json, one file per
environment: local, development, staging, production. corepack pnpm build writes dist/config.json from the selected profile
(scripts/generate-runtime-config.ts). public/config.json is only the local
profile for corepack pnpm dev; the build replaces it, so settings put there
never reach a deployment. Keep it equal to config/runtime/local.json plus
BUILD_ID: local-build and RELEASE_ID: local-release;
tests/unit/deployment-admission.test.ts fails when the two differ.
Build and deploy variables, lowest precedence first:
| Variable | Sets | Default |
|---|---|---|
APP_PROFILE |
which config/runtime/<profile>.json is used |
local; an empty value fails the build |
RUNTIME_API_BASE_URL |
API_BASE_URL, overriding the profile; the CI workflow cannot pass it (see below) |
the profile value |
RUNTIME_TELEMETRY_ENDPOINT |
TELEMETRY_ENDPOINT, overriding the profile; the CI workflow cannot pass it (see below) |
the profile value |
VITE_BUILD_ID |
BUILD_ID in the runtime config and the release manifest |
local-build |
RELEASE_ID |
RELEASE_ID in the runtime config and the release manifest |
local-release |
RELEASE_TARGET |
the environment FE-GATE-027 admits the build to; must equal APP_PROFILE |
none; admission refuses without it |
verify:documentation fails if this table stops naming a variable the build or
admission reads (scripts/verify-documentation-readiness.ts).
Only the two RUNTIME_* values can differ from the reviewed profile. Anything
else changes by editing the profile file. Staging and production reject demo
auth, non-HTTPS endpoints and the names reserved for examples and tests
(example.com, example.net, example.org and their subdomains, .example,
.invalid, .test). The shipped staging and production profiles use
*.example.com, so admission refuses them until a project sets its own
endpoints.
In CI the only way to set the endpoints is to commit them to
config/runtime/<profile>.json. The CI contract binds just APP_PROFILE and
RELEASE_TARGET to the build job (scripts/contracts/ci-gates.ts), so a
RUNTIME_* repository variable never reaches the build.
A local production build and its admission check:
APP_PROFILE=production \
RUNTIME_API_BASE_URL=<your-api-origin>/ \
RUNTIME_TELEMETRY_ENDPOINT=<your-telemetry-endpoint> \
VITE_BUILD_ID=<unique build id> RELEASE_ID=<unique release id> \
corepack pnpm build
APP_PROFILE=production RELEASE_TARGET=production corepack pnpm check:release-admission
With CI=true the gate runner (corepack pnpm ci:gate) also requires
VITE_COMMIT_SHA, SOURCE_DATE_EPOCH and CI_RUNNER_IMAGE before it runs a
gate (scripts/lib/build-environment.ts, scripts/run-ci-gate.ts). The CI variable
list is in docs/operations/ci-quality-gates.md.
Included starter experience
The default build mounts a domain-neutral application shell with a header,
responsive sidebar, route focus management, session integration status, a
persistent system / light / dark theme selector, and a language selector.
The route list is ROUTE_REGISTRY (src/features/installed-feature-contracts.ts):
the platform routes of src/contracts/routes.ts plus the routes of every
installed feature, the removable reference feature included. The platform
overview page (/examples/platform) shows the composed list at runtime, so
this README keeps no copy of it and adding a feature does not edit it.
AUTH_MODE=demo is credential-free and accepted only in local/development
environments. Deployments use AUTH_MODE=external and provide the opaque auth
owner described in
docs/architecture/starter-experience.md.
The client route policy is user experience only; server authorization remains
authoritative.
Support scope
Four tiers. The status words on the right are the ones the catalogs and design documents use; the next table maps them.
| Tier | What it covers | Status words |
|---|---|---|
| Default | In the default build and covered by the merge gates: the application shell and example routes, the REST HTTP executor, TanStack Query server state, Local/Session Storage registries, cross-tab invalidation, runtime config profiles and the release manifest check, AUTH_MODE=external (demo only in local/development), the typed message catalog, and the removable reference feature. dist/ is served by a static host (docs/architecture/static-delivery.md) |
COMPOSED |
| Optional (recipe) | Not installed. A project copies one of the recipes in config/recipes/frontend-capability-recipes.json and narrows it (docs/architecture/optional-adapter-recipes.md). realtime, offline-indexeddb, service-worker-pwa and file-transfer also ship a tested reference runtime that the default build leaves out |
RECIPE_AVAILABLE, NOT_INSTALLED, AVAILABLE_NOT_COMPOSED |
| Experimental | Designed and decided, but the runtime is missing or unfinished; finish it before building on it. GraphQL, gRPC-Web, Connect-Web and Protobuf adapters, Range resumable download, IndexedDB query persistence, the local preview decode-safety probe. src/features/local-draft-feature is an architecture sample, not installed |
DESIGNED_NOT_IMPLEMENTED |
| Not supported | Deliberately not selected, or browsers cannot guarantee it: SSR, app-managed background upload and download, directory selection, persistent file handles, product query persistence, exactly-once delivery between tabs | NOT_SELECTED, PLATFORM_LIMITED |
The rows come from
docs/architecture/browser-data-capability-completion-ledger.md,
docs/architecture/client-cache-and-storage.md
and
docs/architecture/api-contract-schema-mapper-and-server-state.md.
| Status word | Where it appears | Meaning | Tier |
|---|---|---|---|
COMPOSED |
capability ledger, design documents | wired into the default production path | Default |
INSTALLED |
a project's own recipe catalog (step 10 of the recipe procedure) | the project added the recipe | Default, for that project |
RECIPE_AVAILABLE |
recipe catalog status |
a recipe exists to copy; nothing is installed | Optional |
NOT_INSTALLED |
recipe catalog defaultStatus; a src/features/<id>/NOT_INSTALLED marker file |
not part of the build | Optional (recipe) or Experimental (feature) |
AVAILABLE_NOT_COMPOSED |
capability ledger; recipe referenceRuntime.status |
code and tests exist; the default build leaves it out | Optional |
DESIGNED_NOT_IMPLEMENTED |
capability ledger, design documents | design approved, runtime missing | Experimental |
NOT_SELECTED |
capability ledger, design documents | deliberately not chosen | Not supported |
PLATFORM_LIMITED |
capability ledger | browsers cannot guarantee it; offered only behind a probe and a fallback, if at all | Not supported as a guarantee |
Gate results (PASS, PASS_SCOPED, UNVERIFIED, FAIL_UNVERIFIED) are
verdicts on evidence, not support tiers.
Browsers: the build targets Chrome and Edge 111, Firefox 128, and Safari and
iOS 16.4. That is the higher of Vite 8's default JavaScript target
(baseline-widely-available; vite.config.ts sets no build.target) and
the CSS targets of Tailwind CSS 4. There is no browserslist. The end-to-end
suite runs on the desktop Chromium, Firefox and WebKit builds that Playwright
1.62 pins, plus one Chromium phone-size smoke (playwright.config.ts). Older
versions inside the target range and real mobile browsers are not tested.
Architecture
This repository is a Frontend Application Foundation: a starter/composition skeleton plus a reusable capability platform. Platform capabilities stay horizontal while product business features use vertical slices.
src/ has nine top-level folders. The descriptions match the table in
docs/architecture/layers.md, which also names every import rule:
src/bootstrap— the composition root: runtime configuration, concrete adapter construction and the React mountsrc/apps— deployable apps: eachapp-module.tsdeclares an app and its context budget;template-app.tsis the app this build producessrc/contexts— bounded contexts: eachcontext-module.tsdeclares its app, route root and feature budgetsrc/features— removable vertical slices (src/features/<id>/{domain,application,contracts,adapters,presentation}) and the installed-feature catalogs (src/features/*.ts)src/presentation— generic UI and the inbound adapter: routes, layouts, the design system, pages and providerssrc/adapters— reusable capability runtimes that implement application ports: HTTP, auth, storage, query cache, telemetry, workers and moresrc/application— generic use cases, ports, policies and view-modelssrc/contracts— shared vocabulary and registries read by several layers, the workers and the build and release scriptssrc/platform— product-neutral primitives any folder may use: budgets, execution context, resilience, the telemetry pipeline, error envelopes and release coherence
Dependencies point inward. Every folder may also import contracts and
platform:
presentation -> application -> contracts -> platform
adapters -----^
bootstrap composes concrete adapters
apps -> contexts -> features (an app deploys contexts; a context owns features)
feature use case -> feature port <- feature-owned capability binding
Domain code lives inside each feature; there is no top-level domain folder.
See
docs/architecture/frontend-application-foundation.md,
docs/architecture/overview.md, docs/architecture/layers.md, and
docs/architecture/starter-experience.md. The removable vertical slice is
under src/features/reference-feature; its domain, application input, HTTP
binding, contracts, route runtime, and presentation own their contributions.
The central installed catalogs only aggregate selected contributions. The
generic starter routes continue to typecheck, test, and build after that
feature is removed.
Platform capability review
The starter shell is implemented, but the repository review also records the remaining work required before feature teams can use every declared contract through one end-to-end application path:
- platform capability review
- ports, adapters, and feature boundaries
- REST, GraphQL, Connect/gRPC-Web, Schema, Mapper, and Server State
- Protobuf browser transports and REST Gateway
- backend API and Server State handoff contract
- TypeScript, state ownership, and data flow
- routing, page templates, and reusable patterns
- browser data capability completion ledger
- browser file and origin-storage platform
- client cache and storage
- realtime events, Web Push, and bounded polling
- presigned transfer, resumable upload, streaming download, and Image CDN
- server file capability infrastructure
- design-system platform
- frontend platform testing strategy
- implementation roadmap
These documents distinguish repository defaults from opt-in adapters and project-owned integrations. They are target designs and review findings; a capability is not treated as implemented until its branch acceptance criteria and executable gates pass.
Documentation
docs/README.md sorts the documents into current contracts,
target designs and work history.
Files you can delete after copying
These record how the template was built. Nothing in the build or the gates
reads them, except the one file noted below
(tests/unit/deletable-history-documents.test.ts checks this).
| Path | Contents |
|---|---|
docs/superpowers/ |
past plans and specs |
docs/reviews/ |
reviews and the review guide. Keep docs/reviews/adapters/INVENTORY.md: check:adapter-inventory (FE-GATE-010) reads it |
SPEC.md, tasks/ |
requirements and task list of the 2026-09-25 review fix round |
CLAUDE.md |
review instructions for the template repository itself; replace it with your own |
PRODUCT.md |
product context of the template itself (users, purpose, principles) for design tools; replace it with your product's |
The reference feature is not in this list: deleting its directory alone
leaves tests, policy entries and CI scripts behind that fail the gates.
scripts/test-sample-removal.ts removes it from a copy of
the repository and lists everything that has to go with it (its header comment
and SAMPLE_EXTRAS); do the same in your project and run the gates.
Verification
Common local checks:
corepack pnpm lint
corepack pnpm check:types
corepack pnpm check:types:app
corepack pnpm check:types:node
corepack pnpm check:types:test
corepack pnpm check:architecture
corepack pnpm test:all
corepack pnpm test:contract
corepack pnpm test:e2e
corepack pnpm test:a11y
corepack pnpm build
corepack pnpm check:bundle
corepack pnpm test:performance
corepack pnpm verify:compatibility
corepack pnpm verify:release
corepack pnpm check:registries
corepack pnpm drill:runbooks
corepack pnpm check:ci
drill:runbooks stops at the first drill that is not PASS. Without provider
evidence every drill ends UNVERIFIED (exit 3), because a drill never reports
a check it could not run locally as PASS; see "Runbook jobs" in
docs/operations/ci-quality-gates.md.
test:all is the ordinary product-development loop and intentionally excludes
host-level CI-runner assurance. Run corepack pnpm test:system only on the
compatible Linux assurance host described in
docs/testing/taxonomy.md.
check:types는 source, Node scripts/config와 tests를 분리된 TypeScript
project로 모두 검사한다. type/architecture/security/registry의 invalid
fixture는 config/ci/gates.json에서 “실패해야 통과”하는 negative gate로
실행된다. 도구 호환성 결정은
VD-01에 기록돼
있다.
Application feature input은 module augmentation으로 닫힌 ID와 정확한 input
shape를 제공하며, 공통 Result<Value, Failure = AppFailure>는 error registry의
failure kind만 application/presentation 경계를 통과시킨다. Architecture gate는
TypeScript/TSX의 static, dynamic, type import를 별도 정적 그래프로 분석하고
runtime/source 영역의 JavaScript 재유입도 거절한다. 해석되지 않은 import,
parse failure, 금지 계층 edge와 순환 의존은 모두 fail-closed이며 전용
TypeScript/TSX negative fixture로도 검증된다.
Install the pinned Playwright browser engines before the first cross-browser run:
corepack pnpm exec playwright install --with-deps chromium firefox webkit
Two gates intentionally need external evidence:
review:a11y-manual(release gate FE-GATE-028) needs a signed human keyboard/focus/screen-reader review of every registered route, one record per route atartifacts/tests/a11y-manual/<ROUTE_ID>.md. The routes areROUTE_REGISTRY;verify:documentationfails, naming the route ID, when a registered route has no record. The merge gate FE-GATE-009 runs onlyreview:a11y-manual -- --format-only, which checks that every route record keeps the template's fields, reviewed or still pending.collect:web-vitals-evidencestaysFAIL_UNVERIFIEDuntil a reviewed minimum eligible-sample threshold and 28 days of production data exist.
Live hosting verification (FE-GATE-019, production stage) requires
HOSTING_BASE_URL and the promoted release deployed by the workflow's
deployment job. That job is an empty slot until the project fills it
(docs/operations/ci-quality-gates.md);
until then the result is UNVERIFIED, not PASS. A host serving another
release fails.
CI and evidence
The gate registry is config/ci/gates.json; the Gitea workflow is
.gitea/workflows/quality-gates.yml. It follows:
MERGE_READY -> RELEASE_READY -> PROD_PROMOTION_READY -> FIELD_SLO_READY
DOCUMENTATION_READY is independent. No gate is downgraded to a warning.
The workflow runs on pull requests, pushes to main and develop, and v*
tags. The Git host of this repository may not have Actions enabled, so a pull
request can show no gate status at all; no status is not a pass. Until the
host runs the workflow and marks the merge gates as required checks, run the 13
merge gates locally before merging (FE-GATE-008 and 009 need Playwright
browsers):
for gate in 001 002 003 004 005 006 007 008 009 010 011 013 020; do
corepack pnpm ci:gate -- "FE-GATE-$gate" || break
done
Machine-readable evidence is written below artifacts/; generated evidence is
ignored by Git while .gitkeep files preserve the taxonomy.
Operational details are in docs/operations/, with incident procedures in
docs/runbooks/.
Updating a copied project
Template versions are Git tags vX.Y.Z. CHANGELOG.md lists
the changes between tags, marks security fixes [보안] and contract changes
[계약] (backend, deployment, CI or feature code must change too), and names
the affected paths.
Record where you started. Right after copying, commit a one-line
.template-origin file at the root of your project with the template tag (or
commit) you copied and the date, for example v0.2.0 2026-09-26.
Take a template fix with Git. cherry-pick works even when your repository
does not share the template's history, because it merges against the picked
commit's parent:
git remote add template <template repository URL>
git fetch template --tags
git log --oneline <your origin>..template/main # what changed since you copied
git cherry-pick -x <commit> # one fix; -x records its origin
When the files have moved or diverged too far for a clean pick, read the change as a diff and apply it by hand:
git diff <commit>^ <commit> -- <paths from CHANGELOG>
Afterwards run the local merge gates from "CI and evidence", apply the
backend or deployment change a [계약] row names, and update
.template-origin once you have caught up to a tag. git revert undoes a pick.
Defects: if a problem reproduces on an unmodified checkout of your
.template-origin commit, it is a template defect. Report it on the template
repository with that commit and the reproduction; the template maintainer
classifies it and ships the fix with a CHANGELOG entry. A problem that needs
your changes to reproduce belongs to your project, and applying a template fix
to your copy is your project's job.