Code Structure
Learn how this Angular project is structured and where are the files you need to modify.
Last updated
Learn how this Angular project is structured and where are the files you need to modify.
Last updated
In the root of the project we have the following important files and folders:
File/Folder | Purpose |
| This folder is where our end to end tests will live. This template doesn't include e2e tests, just the default configuration that is included in a new Angular project. |
| The npm packages installed in the project with the |
| The most important folder. Here we have all the files that make our Angular app and is the location where we will spend most of our time coding. |
| Configuration for code editors. See EditorConfig. |
| Specifies intentionally untracked files that Git should ignore. |
| |
| It provides workspace-wide and project-specific configuration defaults for build and development tools provided by the Angular CLI. For details, see Angular Workspace Configuration. |
| Under the hood, the Angular CLI uses Autoprefixer to add vendor prefixes when parsing CSS rules. This way we ensure compatibility with different browser and browser versions. Internally, Autoprefixer relies on a library called Browserslist to figure out which browsers to support with prefixing. This file has the configuration for the supported browsers. |
| To ensure code quality, we follow and enforce the Angular Commit Message Guidelines. These guidelines define a Commit Message Format and certain rules that will help teams achieve consistency with version control and source code management practices. That's why we included the |
| This is the Karma test runner configuration file. We use Karma to run our tests.
|
| Provides version information for all packages installed into |
| As every modern web application, we need a package system and package manager to handle all the third-party libraries and modules used by our app. Inside this file you will find all the dependencies and some other handy stuff like the npm scripts that will help us a lot to orchestrate the development (bundling/compiling) workflow. |
| A super simple yet complete Node.js Express server to serve your Angular app with server side rendering support. Learn more about ssr in this project. |
| You may notice there are a few The root
In particular, this config file provides the options used when working with code in the |
| Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the |
| Specific tsconfig options used when compiling the app for Server Side Rendering. This configuration file is referenced in the |
| Specific tsconfig options used when compiling the tests for your app. This configuration file is referenced in the |
|
|
| Default webpack config used by the Angular CLI build/bundling workflow. |
Now let's dive in the details of the /src
folder.
/src
Inside of the /src
directory we find our raw, uncompiled code. This is where most of the work for your Angular app will take place.
File/Folder | Purpose |
| Has all the components, modules, pages, services and styles you will use to build your project. |
| In this folder you will find sample images, sample-data json, and any other asset you may require in your project. |
| Under this folder are configuration files used by the Angular CLI to manage the different environment variables. For example we could have different database configurations for both local and production environment. |
| It includes all the theming, variables and sass mixins to be used in our Angular project. |
| The icon of our app. |
| This is the main entry point for the app. We won’t spend much of our time in this file as all the scripts (javascript) and styles (css) for our Angular app are dynamically injected in the compiled version of our |
| Entry point for the Server Side Rendering environment. |
| This is the entry point of your application, and is responsible of bootstrapping the application.
As Angular can be bootstrapped in multiple environments we need to import a module specific to the environment.
That's why we have both
|
| When you create a project with the For more information check Angular polyfills documentation. |
| This file is required by |
| Extends lint rules from |
Note: testing is not implemented for this template. If you want to add testing check this guide.
src/app
The /app
folder is the largest folder because it contains all the code of our Angular app. It has all the components, modules, pages, services and styles you will use to build your project.
This is the core of the project. Let’s have a look at the structure of this folder so you get an idea where to find things and where to add your own modules to adapt this project to your particular needs.
We designed this Angular project with a modular approach.
We strive to showcase an advanced app module architecture so you get a better idea on how to structure and scale your project. Again, modules are great to achieve scalability.
Both /core
and /shared
folders include auxiliar modules that provide structure and organization to our source code and follow Angular best practices.
The other folders you will find inside /app
are feature modules that include the different pages of the app.
File/Folder | Purpose |
| Feature module that includes |
| Feature module that includes different charting libraries examples grouped in three different pages (one for each charting library: |
| Feature module that includes pages showcasing |
This folder contains the | |
| Feature module that includes the main dashboards pages. One CRM Dashboard page and one E-commerce Dashboard page. |
| Feature module that includes many different form examples, layouts, pages, and functionalities. |
The | |
| Shared module that includes a comprehensive set of App Shell components to add loading indications and placeholders to your app content. Read more about the importance of skeleton screens in our Improved UX with Skeleton Loading Screens post. |
| Feature module that includes many different |
| Feature module that includes |
| Config file with an interface to interact and set default color palette. |
| Config file with an interface to interact and set default dynamic layout. |
| Here we define the main routes. Child routes of other lazy modules are defined inside those modules. These routes are registered to the Angular |
| This serves as the skeleton of the app. Typically has a In our case we have implemented a dynamic layout functionality so we are using those layouts to include headers, menus and footers that live in every page. |
| It’s the Angular component that provides functionality to the html file I just mentioned above. |
| This is the main module of the project. |
| Similar to the previous one, this one wraps the main |
| Angular Http interceptor to ensure internal links work properly with Server Side Rendering. |
src/app/core
We will be expanding this documentation ASAP.
src/app/shared
We will be expanding this documentation ASAP.
src/assets
In this folder you will find sample images, sample-data json, and any other asset you may require in your project.
src/theme
Here you will find all the variables, mixins, shared styles, etc, that will make your app customizable and extendable.
Please read the Theming section for more information.