Skip to main content

Overview

Layer - the first level of application partitioning, according to the scope of influence of the module

layers-flow-themed

Structure

โ””โ”€โ”€ src/
โ”œโ”€โ”€ app/ # Initializing application logic
โ”œโ”€โ”€ processes/ # (Optional) Application processes running over pages
โ”œโ”€โ”€ pages/ # Application pages
โ”œโ”€โ”€ widgets/ # Independent and self-contained blocks for pages
โ”œโ”€โ”€ features/ # (Optional) Processing of user scenarios
โ”œโ”€โ”€ entities/ # (Optional) Business entities that domain logic operates with
โ””โ”€โ”€ shared/ # Reused modules, non business specific

Rules

  • Each layer is located only at the topmost level, and cannot occur again at another nesting level

    // Bad
    - pages/../features/..
    - features/../entities/..
    // Good
    + pages/**
    + features/**
  • Each layer can use (import) only the underlying layers
  • The higher the layer is located, the higher the level of its responsibility and knowledge about other layers (from top to bottom)
    • app > (processes) > pages > (widgets) > features > entities > shared
  • The lower the layer is located , the more it is used in the upper layers, and therefore the more dangerous it is to make changes to it (from bottom to top)
    • shared > entities > features > (widgets) > pages > (processes) > app
LayerCan useCan be used by
appshared, entities, features, widgets, pages, processes-
processesshared, entities, features, widgets, pagesapp
pagesshared, entities, features, widgetsprocesses, app
widgetsshared, entities, featurespages, processes, app
featuresshared, entitieswidgets, pages, processes, app
entitiessharedfeatures, widgets, pages, processes, app
shared-entities, features, widgets, pages, processes, app

How to use?

  1. First, decompose by main layers relevant to almost any application:

    • app - for initializing application logic
    • pages - for application screens
    • shared - for abstract commonly used logic (UIKIT / helpers / API)
  2. Then, add the remaining layers as needed:

    • widgets - if the logic on the pages starts to grow and duplicate
    • entities - if the amount of deunified logic is growing in the project
    • features - if it becomes difficult to find the boundaries of specific user scenarios in the project, and control them
    • processes - if a lot of "end-to-end logic" grows over the page

Layers

note

It should be understood that not all of the above layers are mandatory, but are needed only when the complexity of the project and the swelling responsibility in the existing structure require it

app

app-themed-bordered

processes

processes-themed-bordered

pages

pages-themed-bordered

widgets

widgets-themed-bordered

features

features-themed-bordered

entities

entities-themed-bordered

shared

shared-themed-bordered

See also

[01/12] logo-mini