DEC-AIC-0059: Migrate the vault view to an Angular layered application with frontend-owned DTOs
Status: draft · 2026-11-25
Context
The vault view UI under libs/vault/adapter-view/assets/ grew to roughly 7,400 lines across three separate vanilla HTML/JS pages (vault-view, plans-view, climb-view), duplicating CSS tokens, header chrome, theme state, and keyboard shortcut handling, while apps/climb-board already uses Angular 21 inside the same workspace.
At the same time, DEC-AIC-0051 established two distinct architectural styles enforced by @nx/enforce-module-boundaries: architecture:hexagonal (type:domain, type:application, type:adapter) for the core and server libraries, and architecture:layered (type:feat, type:ui, type:data-access, type:util) for frontend apps. libs/vault/adapter-view/src/view.ts already exposes a clean JSON/HTTP boundary (/graph.json, /plans.json, /climb.json, /page.json, /note.json, /api/*) under a strict loopback CSP.
Decision
- Introduce
scope:vault-viewunderarchitecture:layered.apps/vault-view(type:app) is an Angular 21 zoneless standalone application hosting the shared shell, router (/,/plans,/climb), theme, Present mode (P), andx-vault-tokenHTTP interceptor.- Layered internal libraries live under
libs/vault-view/:util(type:util, pure TypeScript tested with Vitest),data-access(type:data-access, signal stores, HTTP clients, and frontend-owned DTOs),ui(type:ui, presentational components), and feature libraries (feat-plans,feat-climb,feat-graph,type:feat) added in subsequent PRs. eslint.config.mjsconstrainsscope:vault-viewtoscope:vault-viewandscope:shared, keepingarchitecture:layeredstrictly separated fromarchitecture:hexagonal.
- Keep HTTP DTOs strictly frontend-owned.
libs/vault-view/data-accessdefines the JSON response and request types it consumes rather than importing backend domain or application types, preserving full decoupling across the HTTP boundary.
- Wire
@ai-coach/vault-view:buildas an Nx task dependency of@ai-coach/vault-adapter-view:build.- Built browser assets are produced into
apps/vault-view/dist/browser/and served bylibs/vault/adapter-view/src/view.tsunder the existing strict CSP, without committing compiled JS bundles to git.
- Built browser assets are produced into
- Migrate incrementally across six PRs.
- PR 1: Shell, routing, theme, shortcuts, API token interceptor, Nx build dependency, served at
/appalongside legacy pages. - PR 2: Plans page (
/plans). - PR 3: Climb page (
/climb) absorbingapps/climb-board. - PR 4: Vault graph filters, overview, detail panels, and note reader.
- PR 5: Interactive SVG force graph canvas.
- PR 6: Distill editor (passage marking and focus reader) and removal of legacy vanilla assets.
- PR 1: Shell, routing, theme, shortcuts, API token interceptor, Nx build dependency, served at
Consequences
libs/vault/adapter-viewbecomes a pure hexagonal HTTP driving adapter once the legacy assets are retired, while the UI gains TypeScript safety, signals, component reuse, and Vitest unit testing.- Building
vault-adapter-view,vault-server, orcliautomatically buildsvault-viewvia Nx caching, with no generated bundles checked into git. - Because DTOs are frontend-owned, backend JSON contract changes must be reflected in
libs/vault-view/data-accessand verified by integration tests.
Alternatives Considered
- Continue extending the vanilla HTML/JS assets. Rejected: ~7,400 lines of untyped imperative DOM code with three duplicated page shells slows down new UI work and makes refactoring error-prone.
- Share backend types via a
libs/shared/view-contractlibrary. Rejected: the team prefers strict frontend-owned DTOs so the Angular app remains completely decoupled from backend library changes. - Commit built Angular bundles into
libs/vault/adapter-view/assets/likeapps/climb-board. Rejected: committing compiled bundles creates noisy PR diffs on every UI change; an Nx build dependency gives clean diffs and cached builds.