セクション 3 / 17

1ページで見るアーキテクチャ

目次
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

覚えておくべき6つの文です。

  1. どのライブラリもドメインを1つ、型を1つ持ちます。 それはタグとして書かれ、タグが何をインポートしてよいかを決めます。
  2. インポートは型の階段を下へ向かいます。 feature → ui、data-access → model → util。上へは決して向かわず、feature同士で横にも向かいません。
  3. ドメインが別のドメインを見るのは、そのapiライブラリを通してだけです。 ドメインのそれ以外はすべて非公開です。
  4. sharedはどのドメインも知りません。 「共有」のファイルに作業指示(work order)が出てくるなら、それは整備ドメインに属します。
  5. コンポーネントはHTTPと話しません。 データはdata-accessを通って流れます。featureが見るのはファサードかセレクターであり、URLではありません。
  6. アプリケーションは薄く保ちます。 アプリはルートとプロバイダーを配線するだけです。機能はライブラリにあるので、2つ目のアプリのコストはほぼゼロです。