@ai-coach/vault-view-data-access
Frontend-owned DTOs, typed HTTP API services, browser platform adapters, and focused Angular signal stores for the vault view. It owns every HTTP call to the local view server and holds reactive state for the shell, Graph, Plans, and Climb features.
What it does not do
- No components, templates, or CSS. Presentational components live in
libs/vault-view/uiand smart containers live inlibs/vault-view/feat-*. - No direct backend or vault imports.
@nx/enforce-module-boundariesrestrictstype:data-accessinsidescope:vault-viewtotype:data-access,type:util, andscope:shared. All payloads are defined here as frontend-owned DTOs. - No
HttpClientor rawglobalThisaccess in stores. Stores delegate HTTP calls to typed*Apiservices and read/write browser state exclusively throughUrlHashServiceor injectedDOCUMENT.
Architecture fit
- Scope:
scope:vault-view - Style:
architecture:layered(type:data-access) - Depends on:
@ai-coach/vault-view-util - Used by:
@ai-coach/vault-view,@ai-coach/vault-view-feat-graph,@ai-coach/vault-view-feat-plans,@ai-coach/vault-view-feat-climb
[feat-graph / feat-plans / feat-climb / app shell]
│
▼
[Focused Signal Stores + Facades] ──▶ [UrlHashService / DOCUMENT]
│
▼
[GraphApi / PlansApi / ClimbApi] ──HTTP + vaultTokenInterceptor──▶ [vault-view-server]
Internal architecture & rules
- Domain-grouped folders: Internals are grouped under
src/lib/http/(error normalization, latest-request cancellation, CSRF token interceptor),src/lib/shell/(app-wideShellStore,UrlHashService),src/lib/graph/(graph, distill, and distill toasts),src/lib/plans/, andsrc/lib/climb/, each re-exported throughsrc/index.ts. - Transport separated from state:
GraphApi,PlansApi, andClimbApiare pureprovidedIn: 'root'HTTP clients returning typedObservable<T>. Stores never injectHttpClient. - Focused, feature-scoped stores:
ShellStoreis app-scoped (providedIn: 'root'), while feature stores (PlansStore,ClimbStore, andprovideGraphStores()composingGraphDataStore,GraphFilterStore,DistillStore,ToastStore, and the thinGraphStorefacade) are provided at their lazy page components so state and subscriptions tear down on route exit. - Latest-request cancellation: Every store
load()runs throughcreateLatestRequestRunner(destroyRef), unsubscribing stale in-flight HTTP requests on rapid reloads and on destroy. - Centralized error normalization & CSRF token:
normalizeHttpErrorandextractHttpErrorPayloadstandardize API error handling;vaultTokenInterceptorreadsmeta[name="vault-token"]via injectedDOCUMENTand attachesx-vault-tokenon mutating requests. - Code hygiene: Explicit
public/privatemember accessibility on every class member and zero comments in source code (DEC-AIC-0011).
Public surface
- HTTP & platform infrastructure:
GraphApi,PlansApi,ClimbApi,vaultTokenInterceptor,readVaultToken,UrlHashService,normalizeHttpError,extractHttpErrorPayload. - App-wide store:
ShellStore(theme, presentation mode, global refresh signal). - Graph stores & facade:
provideGraphStores,GraphDataStore,GraphFilterStore,DistillStore,ToastStore,GraphStore. - Feature stores:
PlansStore,ClimbStore. - Frontend-owned DTOs: Graph, Plans, Climb, and shared vault note/error DTO types.
How to extend it
- Define the request and response DTO interfaces in the matching
*.dto.tsfile. - Add the typed endpoint method to
GraphApi,PlansApi, orClimbApi(returning anObservable). - Wire the call into the owning focused store using
normalizeHttpErrorandcreateLatestRequestRunnerfor cancelable loads, then export any new public symbol fromsrc/index.ts. - Add Vitest unit tests covering the API call, error normalization, and store state transitions, then run
npm exec nx lint @ai-coach/vault-view-data-access,npm exec nx typecheck @ai-coach/vault-view-data-access, andnpm exec nx test @ai-coach/vault-view-data-access.
Running & testing
Unit tests run in Vitest with Angular's zoneless TestBed, HttpTestingController, and injected fake DOCUMENT/UrlHashService stubs—no real browser or server is required.
npm exec nx test @ai-coach/vault-view-data-access
npm exec nx lint @ai-coach/vault-view-data-access
npm exec nx typecheck @ai-coach/vault-view-data-access
Key ADRs
- DEC-AIC-0059 — Establishes the Angular layered layout and frontend-owned DTOs for the vault view.
- DEC-AIC-0062 — Codifies
data-accesslayer boundaries, store/API separation, and Nx lint/typecheck/test guardrails. - DEC-AIC-0051 — Defines workspace tags and
@nx/enforce-module-boundariesrules. - DEC-AIC-0060 — Governs the eight-section package README structure and Docusaurus ingestion.