JST documentation

Architecture recipes

These are ownership recipes, not dependencies that every product must install. Add a recipe only when the use case exists.

Authentication and authorization

Test expired credentials, refresh failure, concurrent refresh, forbidden capability, and SSR request isolation.

Forms

Keep server errors, validation errors, and transport failures distinct.

Feature flags

Delete flags and dead branches after rollout. A permanent flag is configuration and should be named accordingly.

Internationalization

Query and cache strategy

Choose per use case and record it beside the repository/service:

The state library is an implementation detail. Cache keys, invalidation, optimistic transaction, and rollback behavior are part of the use-case contract and require tests.

Optimistic updates, undo, and event sourcing

Test success, duplicate submission, rollback, late failure, retry, and undo after navigation when the product promises it.

Cross-domain workflows

Prefer, in order:

  1. a higher composition root coordinating two narrow contracts;
  2. a consumer-owned facade with pure anti-corruption mapping;
  3. a typed fact event for real one-to-many fan-out.

Events must describe facts (orderSubmitted), not commands aimed at another module (refreshBilling). Do not introduce a global event bus for a single consumer.

Generated API clients

Generated OpenAPI/Orval code stays at the repository boundary:

generated transport DTO/client
  → repository adapter
  → runtime validation when the generator cannot guarantee trust
  → pure mapper
  → domain model

Never export generated DTOs from an entity/module public API or pass them to UI. Regeneration must be deterministic and checked in CI.

Local-first

Adopt local-first only when offline work, latency, or collaborative editing is a product requirement. Define identity, conflict resolution, persistence durability, sync ownership, and recovery before choosing a database or CRDT. Keep the sync engine behind a port so feature view models consume domain state rather than replication details.