I’m studying angular’s style guide and I got some doubts while developing a simple app! The app is to control user’s stock exchange shares. So it’s needed:
- a module to authenticate user (signin, signup and reset password)
- a module with a component to show all user’s stocks and another one to add new stocks
- a module to edit user’s profile
Authentication module will have a different layout from the rest of app (authentication will have just a centralised form while rest of app will have a nav-bar as menu).
Question 1: I’ll create a component called Layout inside Auth module and use it only for authentication views; Where do I create the Layout component or module (I don’t know which one) to use with the rest of app? Should I create a Core module and inside this module a Layout module? Should I create a core module and a layout module (outside of core)?
Question 2: where should I create the guard for authentication? This guard will be used for Stocks and Profile modules to avoid users that aren’t logged in
Question 3: how would you structure this simple project regarding folders and files?
Currently, I'm using this article to organize my Angular folder structure. Basically, we have three main folders - core, shared, views.
CoreModule
which provides all app common services. It's imported only once inAppModule
. In this folder, I have services and guards subfolders because they are injectables (question 2 answer). guards I don't provide atCoreModule
, I provide them at routing modules, i.eAppRoutingModule
.SharedModule
which declare and exports all app common components, pipes, enums, classes and directives (all classes expect services and guards).SharedModule
is imported byviews
module.The structure is (question 3 answer):
In your case, could have three views folders/modules: authenticate, user-stock and user-edit. Each one will have the structure similar to the
view-X
folder example (question 1 answer).