Angular Folder Structure Best Practices

In this tutorial, we learn how best to organize the folder structure of an Angular Application. Finding the right folder structure for your real-life Angular application is very important. As you add more and more features to your App locating a certain component or file becomes messy if you do not have the proper structure in place.

Applies to: Angular 2 to the latest edition of i.e. Angular 8. Angular 9, Angular 10, Angular 11

Folder for each Angular Module

The Angular uses the concept of Angular Modules to group together the related features. This gives us a nice starting point to organize the folder structure. Each Module should get its own folder named after the Module Name.

The Angular does not make any distinction between the Modules. but based on how we make use of modules, we can classify our modules into the following four categories

  1. Root Module
  2. Feature Module
  3. Shared Module
  4. Core Module

Root Module

The Angular requires one module to be loaded as the application starts. We call this as root module. The root module loads the root component and all other modules

 The root module is conventionally called as AppModule and created under the  /src/app.folder

Best Angular Books
The Top 8 Best Angular Books, which helps you to get started with Angular  

Feature Modules

The Features module implements a specific feature of the Application. All the components, pipes & directives which implement the feature become part of the module.

Further Reading on Angular Modules

All the components belonging to Feature Modules must be placed inside a directory named after the module. For Example /src/app/<ModuleName>.  By doing so, we make it easy to search a component belonging to the module

You can create subfolders for directives, pipes under the module folder

You can create a components folder and put all your components there. Or create a subfolder for each component under the components folder

Another option to create a pages folder. Each route is a page. The folder is named after the route path. The route might contain more than one component. All of them placed under that page folder. The shared components can be placed under the separate components folder.

The idea of pages is borrowed from this article on Medium

Shared Module

There are many components, directives & pipes, which we may like to share across various modules. All these components should go into the shared module. 

The shared module and must declare the components, pipes, and directives using the declarations metadata and export it using the exports metadata

Other Modules can import the shared modules and use the exported components, directives & pipes

The Services must not be defined here. Since the shared modules are imported everywhere, it may create a new instance of the service if it is imported in the lazy loaded modules.

The Shared module must be created under the folder /src/app/shared folder.

The Shared module should not have any dependency on any of the other modules in the application.

The commonly required angular modules like ( CommonModule, FormsModule, etc) or third party modules can be imported here and re-exported. The other module importing the shared module does not have to import those modules.

You can follow the following folder structure, where each shared feature is created in its own own folder. 

Or you can create folders like components, pipes, directives as shown below

Core Module

The Services shared across the application must become part of the CoreModule. The user authentication services, services that fetch data are examples of such services.

The Services usually needs to be Singleton, Only one instance of the Service must exist. Providing it in CoreModule ensures that the services remain singleton

The core module must be imported only in the root module. Other modules must not import the core modules. You can use the following code to stop the other modules from importing the core module.

The CoreModule must be created under the folder /src/app/core folder.

Under the core folder, you can create subfolders for each service under the services folder.

Folder Structure Example 

Let us build a simple with shared, core and feature module

Create a new application using ng new

Feature Modules

Now let us create three feature modules AdminModule, GthubModule & HomeModule

Admin Module

Create the admin folder under /src/app folder

Under the /src/app/admin folder create the admin.module.ts 



AdminModule has four pages. A admin page is the root page. You can create it under the pages folder.



The admin page has three pages under it. dashboard, rights & user. Hence create a subfolder for all these under the pages folder.






Github Module

The GithubModule retrieves the list of repos from the GitHub repository for a given user. The module is created under the folder github. The components is created under the the pages folder.







Home Module

This module contains three components, HomeComponent, ContactUsComponent and AboutUsComponent








Core Module

The CoreModule contains application-wide singleton services. In this example app, it contains a GitHubService which retrieves the list of repositories of a given user.The CoreModule is created under the folder src/app/core.

All services are created under the src/app/core/services folder. You may also create subfolder for each service.







Shared Module

Our Shared Module contains HeaderComponent & FooterComponent, which is used by the root module.









Final Folder Structure

The following list shows the final structure of our application. You can change/fine-tune them as per the requirement of your project.


Style Guide

8 thoughts on “Angular Folder Structure Best Practices”

  1. Luciano Carreiro

    Thank you for sharing your knowledg!
    I think here would be:
    Instead of:

  2. Cheers!

    You put some files from core and services under “/modules” in core. The final structure shows it correctly, but the detailed explaination is not alwas correct.

  3. Hi,
    Nice article. It gives more knowledge on angular folder structure.
    I have question.
    In this same file structure if we have different header and footer for each module, how can we implement routing. Can you pls provide suggestion.

    1. TekTutorialsHub

      Remove footer & Header from the shared module.
      Add them to each module.
      In the top-level component of each module add them

  4. Hi,
    Thank you very much for sharing,
    Maybe i’m wrong but I think there is a small mistake instead of:


    put :

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top