Src Folder Structure

The src folder


src/
├── app/
|   ├── app.component.css
|   ├── app.component.html
|   ├── app.component.spec.ts
|   ├── app.component.ts
|   └── app.module.ts
├── assets/
|   └── .gitkeep
├── environments/
|   ├── environment.prod.ts
|   └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
└── tsconfig.spec.json
            
# File Purpose
1 app/app.component.{ts,html,css,spec.ts} Defines the AppComponent along with an HTML template, CSS stylesheet, and a unit test. It is the root component of what will become a tree of nested components as the application evolves.
2 app/app.module.ts Defines AppModule, the root module that tells Angular how to assemble the application. Right now it declares only the AppComponent. Soon there will be more components to declare.
3 assets/* A folder where you can put images and anything else to be copied wholesale when you build your application.
4 environments/* This folder contains one file for each of your destination environments, each exporting simple configuration variables to use in your application. The files are replaced on-the-fly when you build your app. You might use a different API endpoint for development than you do for production or maybe different analytics tokens. You might even use some mock services. Either way, the CLI has you covered.
5 favicon.ico Every site wants to look good on the bookmark bar. Get started with your very own Angular icon.
6 index.html The main HTML page that is served when someone visits your site. Most of the time you'll never need to edit it. The CLI automatically adds all js and css files when building your app so you never need to add any <script> or <link> tags here manually.
7 main.ts The main entry point for your app. Compiles the application with the JIT compiler and bootstraps the application's root module (AppModule) to run in the browser. You can also use the AOT compiler without changing any code by passing in --aot to ng build or ng serve.
8 polyfills.ts Different browsers have different levels of support of the web standards. Polyfills help normalize those differences. You should be pretty safe with core-js and zone.js, but be sure to check out the Browser Support guide for more information.
9 styles.css Your global styles go here. Most of the time you'll want to have local styles in your components for easier maintenance, but styles that affect all of your app need to be in a central place.
10 test.ts This is the main entry point for your unit tests. It has some custom configuration that might be unfamiliar, but it's not something you'll need to edit.
11 tsconfig.{app|spec}.json TypeScript compiler configuration for the Angular app (tsconfig.app.json) and for the unit tests (tsconfig.spec.json).

Root Folder Structure

The root folder

The src/ folder is just one of the items inside the project's root folder. Other files help you build, test, maintain, document, and deploy the app. These files go in the root folder next to src/.



apex/
├── app/
|   ├── app.e2e-spec.ts
|   ├── app.po.ts
|   └── tsconfig.e2e.json
├── node_modules/...
├── src/...
├── angular.json
├── .editorconfig
├── .gitignore
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── README.md
├── tsconfig.json
└── tslint.json
            
# File Purpose
1 e2e/ Inside e2e/ live the end-to-end tests. They shouldn't be inside src/ because e2e tests are really a separate app that just so happens to test your main app. That's also why they have their own tsconfig.e2e.json.
2 node_modules/ Node.js creates this folder and puts all third party modules listed in package.json inside of it.
3 angular.json Configuration for Angular CLI. In this file you can set several defaults and also configure what files are included when your project is built. Check out the official documentation if you want to know more.
4 .editorconfig Simple configuration for your editor to make sure everyone that uses your project has the same basic configuration. Most editors support an .editorconfig file. See http://editorconfig.org for more information.
5 .gitignore Git configuration to make sure autogenerated files are not commited to source control.
6 karma.conf.js Unit test configuration for the Karma test runner, used when running ng test.
7 package.json npm configuration listing the third party packages your project uses. You can also add your own custom scripts here.
8 protractor.conf.js End-to-end test configuration for Protractor, used when running ng e2e.
9 README.md Basic documentation for your project, pre-filled with CLI command information. Make sure to enhance it with project documentation so that anyone checking out the repo can build your app!
10 tsconfig.json TypeScript compiler configuration for your IDE to pick up and give you helpful tooling.
11 tslint.json Linting configuration for TSLint together with Codelyzer, used when running ng lint. Linting helps keep your code style consistent.