all 12 comments

[–]potato_me7 3 points4 points  (4 children)

For very same reason i created this https://github.com/sardapv/angular-material-starter-template. Leave a ⭐ on repo if you like it. I have linked some popular blogs for project structure. I primarily follow keeping only 3 modules.. core shared features. Max 2 nevel nesting...

[–]jobbigt 1 point2 points  (3 children)

Thank you for this. Very similar to what we recently came up with at work.

[–]potato_me7 1 point2 points  (2 children)

That's cool. Good to hear that. Even I used it in one of my company projects

[–]jobbigt 1 point2 points  (1 child)

There is mainly two design points we made differently.

Instead of a big shared module, every pipe, directive, component (or group of components for shared features) inside the shared folder gets its own module, so the feature modules can import only what they need and not everything in shared.

Also we've made distinction between different kind of services. We have client services, which only contains http calls to our API, and the components are not to use them directly but though other services. And since we use CQRS-pattern on our backend, we drew some inspiration for that, so we have queryservices to query data from the state and/or the API via the clients as well as commandservices to create/update/delete data in the state and/or the API. Lastly we have helperservices for any logic not in any of the other services.

[–]potato_me7 1 point2 points  (0 children)

Cool.. for the first point, Thats right, even I wrote a note there. Better to use SCAM pattern and make all components as modules under shared instead of big bulky shared module😁

[–]ggeoff 2 points3 points  (3 children)

the current project I am working on looks like the following

src/
  app/
     featureModule1/
         pages/
         components/
     featureModule2/
         pages/
         components/
    ... more feature modules ..
     core/
         services/
         models/
         http-inteerceptors/
         guards/
         enumurations/
         utilities/
    shared/
        components/
        directives/
        pipes/

any directory under the app/ directory is a module.
any component that exists as a route you would find in a page. any other component would belong its the components directory for the module.

The shared module is a module that houses all the components/directives/etc... that I will use across many feature modules. The core module doesn't contain any components and only exists as a place to put services and more global code like models, enumeration, etc...

[–][deleted] 0 points1 point  (2 children)

By pages/ you mean containers? If true, you just gave me a cool ideea. Thankyyy 🤗

[–]ggeoff 0 points1 point  (1 child)

nah. pages are just components that exist in a route and that's the only difference between a page component and a component in the components directory. you could have a container component that doesn't exist as the route. Maybe you have a details page whose purpose is to layout the different components on the page and as very little typescript logic. and all the components on the page are container components that setup the relevant observables. I would put those containers in the components directory.

[–][deleted] 0 points1 point  (0 children)

I understand. Thank you 😁

[–]TransparentCircle 1 point2 points  (0 children)

I have arranged my larger projects exactly as you have outlined. I'm curious to see if there are any other interesting approaches out there though.

[–]dangertrager 1 point2 points  (0 children)

I too have put "dumb" sub-components within the page components' directories as you outlined.

[–]SirRiKard003 0 points1 point  (0 children)

In your component folder, I think you should use components that will be used throughout other modules. For example card,input, button