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