I'm working on an Angular project with 6 other people. The application will be able to handle 4 types of users: 'administrators', 'partners', 'students'...
I've noticed that when structuring an Angular application, the goal is to modularize the most important parts of the application. For example, a Class module, an Exam module, etc. And within those modules, access to those views on the client side is managed using guards.
For instance, students and partners can access the Class module, but if you're a PARTNER within the Class module, you can access some extra classes. Guards are used to manage access to that web page.
My main question is: Can an Angular application be modularized by roles?
So, instead of modularizing by Class module, Exam module, etc., you can modularize by roles: Student module, Partner module, Admin module with its own routing module. With lazy loading, you only send to the user what they need, and then protect that lazy loading afterwards with a Node server. As it generates a js file (23rwf234asd.js), I understand that you can implement security.
But if you modularize by roles, for example, admin.Module, Student.module, Partner.module... Is this possible or is it frowned upon? And when the user logs in, you later send them the corresponding js file. That is, when you run the ng build command, Angular generates specific files for the module configured for lazy loading, for example, 23ksf23ajd3asd.js. What I'm saying is, the user logs in, and you redirect them to their corresponding role module.
Also, I would like to resolve this doubt I have. I know that lazy loading is used to improve the performance of the web application by sending the user only what they need.
But studying Angular, I realize that you can also block the sending of the generated js file when running the ng build command if the user doesn't have the corresponding jwt... What do you think of this last thing I'm saying? That is, in Angular, you will have a RESTful service that will communicate with the corresponding server to deliver data from the database to the user. If you protect the lazy loading, you can protect the RESTful service...
For example, the AdminModule has its own RestAdminService...which in turn contains http://201.201.34.21:3000...that URL would only be known to the admin.
The user has to log in to be able to know which server is used to get data from the database, and the only way to know that other server is by going through the login.