Skip to main content

Units

Moduleโ€‹

Structural unit of the project

A module can be represented as specific file or directory (an abstraction in the context of a structure)

  • authorization module
  • page module
  • the module of the component in the feature
  • action module in the entity model
  • etc.

Layerโ€‹

Each project top level directory defines the scope of responsibility of modules, as well as the level of sensitivity to internal changes

โ””โ”€โ”€ src/
โ”œโ”€โ”€ app/ # Application initialization logic and static assets
โ”œโ”€โ”€ processes/ # (Optional) Page-independent workflows or workflows involving multiple pages
โ”œโ”€โ”€ pages/ # Complete application views
โ”œโ”€โ”€ widgets/ # Various combinations of abstract and / or business units from lower layers
โ”œโ”€โ”€ features/ # (Optional) User scenarios, which usually operate on business entities
โ”œโ”€โ”€ entities/ # (Optional) Business units in terms of which application business logic works
โ””โ”€โ”€ shared/ # Reusable non business specific modules

Sliceโ€‹

Each of the elements located at the top level of the layers

This level is poorly regulated is a methodology, but a lot depends on the specific project, stack and team

โ”œโ”€โ”€ app/
| # Application composition layer
| # Only contains abstract initialization logic and static assets, and thus mustn't contain any Slices
|
โ”œโ”€โ”€ processes/
| # Slices implementing page-independent workflows or workflows involving multiple pages
| โ”œโ”€โ”€ auth
| โ”œโ”€โ”€ payment
| โ”œโ”€โ”€ quick-tour
| โ””โ”€โ”€ ...
|
โ”œโ”€โ”€ pages/
| # Slices implementing complete application views
| โ”œโ”€โ”€ feed
| |
| โ”œโ”€โ”€ profile
| | # Due to routing specifics, this layer can contain nested structures
| | โ”œโ”€โ”€ edit
| | โ””โ”€โ”€ stats
| |
| โ”œโ”€โ”€ sign-up
| โ””โ”€โ”€ ...
|
โ”œโ”€โ”€ widgets/
| # Slices implementing various combinations of abstract and / or business units from lower layers,
| # to deliver isolated atomic User Interface fragments
| โ”œโ”€โ”€ chat-window
| โ”œโ”€โ”€ header
| โ”œโ”€โ”€ feed
| โ””โ”€โ”€ ...
|
โ”œโ”€โ”€ features/
| # Sliced implementing user scenarios, which usually operate on business entities
| โ”œโ”€โ”€ auth-by-phone
| โ”œโ”€โ”€ create-post
| โ”œโ”€โ”€ write-message
| โ””โ”€โ”€ ...
|
โ”œโ”€โ”€ entities/
| # Slices implementing business units in terms of which application business logic works
| โ”œโ”€โ”€ account
| โ”œโ”€โ”€ conversation
| โ”œโ”€โ”€ post
| โ”œโ”€โ”€ wallet
| โ””โ”€โ”€ ...
|
โ”œโ”€โ”€ shared/
| # This layer is a set of abstract Segments
| # It means that it must not contain any business units or business-related logic

Segmentโ€‹

Group of primitives serving as implementation details for business logic

This level determines the purpose of modules in the code and implementation, according to classical design models

{layer}/
โ”œโ”€โ”€ {slice}/
| โ”œโ”€โ”€ ui/ # User Interface components and UI related logic
| โ”œโ”€โ”€ model/ # Business logic (store, actions, effects, reducers, etc.)
| โ”œโ”€โ”€ lib/ # Infrastructure logic (utils/helpers)
| โ”œโ”€โ”€ config/ # Local configuration (constants, enums, meta information)
| โ””โ”€โ”€ api/ # Logic of API requests (api instances, requests, etc.)
note

Since some layers doesn't contain slices (app, shared):

  • Segments can be arranged according to their own rules shared/{api, config}
  • Or not to use segments al all (app/{providers, styles})

See alsoโ€‹