New architecture
Since our app architecture hasn't really made sense for a long time, it should be restructured.
Current problems:
- Components are scattered everywhere
- Folder hiearchy doesn't make sense (e.g. components/creator/content-list)
- Lazy loading is only rudimentarily used and all features loaded always
-
EssentialsModule
doesn't make sense here - All services are provided in
AppModule
Solution:
- Have a better file structure:
- Use a
core
folder for all core services, components, models, guards etc. which are needed always. - Use a
shared
folder andSharedModule
for components which are used by multiple components - Use folders for every role (admin, editor, participant, presentation) which each contain modules for every feature for the role. Advantages of this structure is that lazy loaded can be extended easily and the hierarchy matches the routing tree of the app. Also role specific services can be specified here or extend shared services.
-
Implement lazy loading for every role and feature. This should lead to better over all performance, especially if features are disabled or not used at all.
-
Move essential material modules to
CoreModule
which is imported byAppModule
. -
Provide services only in modules where there are used.
This solution has already been successfully tested with a POC including extensions.
Note: There is another solution for the role-feature folder hierarchy: Instead of role/feature
, feature/role
could be used. The only advantage compared to the other solution is that feature specific services and models could be created on feature directory level. Since there are almost no services/models which are only used at a single page/component it is more or less negligible. On the other hand this structure would be a little bit inconsistent because not every feature is used from multiple roles.