Frontend Development
Application Pattern
xTrakt web frontends run on two frameworks. Angular applications use standalone components, service-owned state, reactive forms, and scoped SCSS. Vue applications use single-file components with <script setup>, composables for shared state, and scoped CSS.
Before starting work, check which stack the target application uses — see Frontend Architecture for the inventory.
Required Conventions — Both Stacks
- Take design tokens from
@cogneris-ai/design-tokens; take auth from@cogneris-ai/frontend-auth. Both are framework-agnostic. - Take components from
@cogneris-ai/ui-angularor@cogneris-ai/ui-vue, matching the application's stack. - Write tests with Vitest.
- Parse backend
text/plainJSON responses withsafeJsonParse<T>(). - Prefer canonical theme tokens:
--color-primary,--surface-page,--surface-card,--text-muted,--radius-md,--shadow-card.
Required Conventions — Angular
- Use standalone components, no NgModules.
- Store shared state in
BehaviorSubjectvalues insideprovidedIn: 'root'services. - Use Reactive Forms with
FormBuilder. - Keep translations in
src/assets/i18n/<locale>.json, loaded by Transloco.
Required Conventions — Vue
- Use
<script setup>single-file components. - Store shared state in composables under
src/composables/use*.ts. Do not introduce Pinia. - Keep translations in
src/locales/<locale>.json, loaded byvue-i18n. - Use
axiosfor HTTP andvue-routerfor routing.
API Response Pattern
Backends may return JSON bodies with Content-Type: text/plain. Frontends should request text and parse manually.
Angular:
this.http.post(url, body, { responseType: 'text' as 'json' });
Vue applications reach the same outcome through src/core/parsing/safeJsonParse.ts and normalizeApiResponse.ts.