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โ
Was this page helpful?
Your feedback helps us improve the docs