Abschnitt 3 von 17

Die Architektur auf einer Seite

Inhalt
maintenancefleetbookingbillingsharedapiapiapiapiapifeaturefeature-*feature-*feature-*feature-*uiui-*ui-*ui-*ui-*ui-*data-accessdata-accessdata-accessdata-accessdata-accessdata-accessmodelmodelmodelmodelmodelmodelutilutil-*util-*util-*util-*util-*
apps/<app>/                         thin: bootstrap, root routes, root providers
libs/<domain>/feature-<use-case>/   smart components for one use case (a page or a flow)
libs/<domain>/ui-<name>/            presentational components: inputs in, events out
libs/<domain>/data-access/          state, effects, HTTP, facade
libs/<domain>/model/                types and pure domain functions, no framework
libs/<domain>/util-<name>/          technical helpers for this domain
libs/<domain>/api/                  the only thing other domains may import
libs/<domain>/feature-shell/        the domain's routes and providers
libs/shared/<type>-<name>/          used by every domain, knows none of them

Sechs Sätze zum Merken:

  1. Jede Bibliothek hat eine Domäne und einen Typ, als Tags notiert, und die Tags entscheiden, was sie importieren darf.
  2. Imports zeigen die Typ-Leiter hinunter: feature → ui, data-access → model → util. Nie nach oben, nie seitwärts zwischen Features.
  3. Eine Domäne sieht eine andere Domäne nur über deren api-Bibliothek. Alles andere in einer Domäne ist privat.
  4. shared kennt keine Domäne. Wenn eine „gemeinsame“ Datei Arbeitsaufträge erwähnt, gehört sie zu Maintenance.
  5. Komponenten sprechen nie mit HTTP. Daten fließen über data-access; das Feature sieht eine Facade oder Selectors, nie eine URL.
  6. Anwendungen sind dünn. Eine App verdrahtet Routen und Provider; Features liegen in Bibliotheken, also kostet eine zweite App nichts.