angularangular-ui-routerangular-cliangular16

What is the optimal folder structure for a an enterprise Angular 16 project that helps with scalability and maintainability in a long term?


I'm about to start a fairly substantial Angular project that will implement several features and modules.

I'm currently uncertain about the optimal folder structure to choose in order to make the project highly scalable and easily maintainable in the long term.

I'm providing the following information that might help define the best project structure: This project will consist of approximately three modules. Two of these modules should each have about three features, while one should have around 15 features.

For my smaller projects, I've typically used the following structure:

└───src
    ├───app
    │   ├───modules
    │   │   ├───module1
    │   │   │   ├───components
    │   │   │   ├───models
    │   │   │   ├───services
    │   │   │   ├───helpers
    │   │   ├───module2
    │   │   │   ├───components
    │   │   │   ├───models
    │   │   │   ├───services
    │   │   │   ├───helpers
    │   │   ├───module3
    │   │   │   ├───components
    │   │   │   ├───models
    │   │   │   ├───services
    │   │   │   ├───helpers
    │   │   ├───...
    │   │   
    │   ├───shared
    │   │   ├───components
    │   │   ├───modules
    │   │   ├───interceptors
    │   │   ├───services
    │   │   ├───enums
    │   │   ├───...

I am considering whether to structure the folders by module, as I've done before. However, I've also come across suggestions to structure folders by feature. Given that my project could potentially have a significant number of features, I am unsure if I should opt for the second option or explore alternative solutions.

I would greatly appreciate your recommendations or suggestions!


Solution

  • This video is very helpful regarding the topic of project architecture https://www.youtube.com/watch?v=SaNO6ubhYyg

    I think you can use the NX library even with a polyrepo. It helps a lot in organizing your folder structure.