Angular Project Structure
After creating an Angular application, Angular CLI generates a standard project structure containing source files, configuration files, dependencies and other resources.
What is Angular Project Structure?
Angular project structure defines how the files and folders of an Angular application are organized.
Understanding the project structure is important because different files have different responsibilities in an Angular application.
Angular Project Structure
CIITStudentApp
│
├── node_modules
│
├── public
│
├── src
│ ├── app
│ ├── assets
│ ├── index.html
│ ├── main.ts
│ └── styles.css
│
├── angular.json
├── package.json
├── package-lock.json
├── tsconfig.json
└── README.md
1. Project Root Folder
The project root folder is the main folder of the Angular application.
CIITStudentApp
All Angular source files, configuration files and installed dependencies are organized inside this project folder.
2. node_modules
The node_modules folder contains the packages and dependencies required by the Angular application.
node_modules/
Important
Developers normally do not modify files inside the node_modules folder manually.
3. public Folder
The public folder can contain static resources that need to be served as part of the application.
public/
├── images
├── icons
└── other-static-files
4. src Folder
The src folder contains the main source code of the Angular application.
src/
├── app/
├── assets/
├── index.html
├── main.ts
└── styles.css
5. app Folder
The app folder contains the main Angular application code.
src/
└── app/
├── app.component.ts
├── app.component.html
├── app.component.css
└── app.config.ts
Components, services, routing and other application-related code are commonly organized under this area.
6. Component Files
An Angular component contains the logic and user interface required for a particular part of the application.
TypeScript
Contains component logic and data.
student.component.ts
HTML Template
Defines the component user interface.
student.component.html
Styles
Defines component styling.
student.component.css
7. assets Folder
The assets folder is used for application resources such as images, icons and other static files, depending on the project configuration.
src/assets/
├── images/
├── icons/
└── logos/
8. index.html
The index.html file is the main HTML document loaded by the browser.
<!doctype html>
<html lang="en">
<head>
<title>CIIT Student App</title>
</head>
<body>
<app-root></app-root>
</body>
</html>
Purpose
It provides the main HTML page in which the Angular application is loaded.
9. main.ts
The main.ts file acts as an entry point for starting the Angular application.
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent)
.catch((err) => console.error(err));
In Simple Words
main.ts helps Angular bootstrap and start the application.
10. styles.css
The styles.css file contains global styles that can be applied across the Angular application.
body {
font-family: Arial, sans-serif;
margin: 0;
}
h1 {
color: #4c1d95;
}
11. angular.json
The angular.json file contains Angular CLI workspace and project configuration.
12. package.json
The package.json file contains information about the project, npm scripts and dependencies.
{
"name": "ciit-student-app",
"scripts": {
"start": "ng serve"
}
}
13. package-lock.json
The package-lock.json file records detailed information about the installed npm dependencies.
Purpose
It helps npm maintain consistent dependency versions during installation.
14. tsconfig.json
Angular applications use TypeScript. The tsconfig.json file contains TypeScript compiler configuration.
tsconfig.json
15. README.md
The README.md file is used to provide documentation and information about the project.
Important Files and Folders
| File / Folder | Purpose |
|---|---|
node_modules |
Contains installed npm dependencies. |
public |
Contains public static resources. |
src |
Contains Angular source code. |
src/app |
Contains application-related Angular code. |
index.html |
Main HTML document. |
main.ts |
Application bootstrap entry point. |
angular.json |
Angular CLI configuration. |
package.json |
Project dependencies and npm scripts. |
package-lock.json |
Records dependency installation details. |
tsconfig.json |
TypeScript configuration. |
README.md |
Project documentation. |
Angular Project Structure Flow
Project Root
CIITStudentApp
src
Application source code
app
Components and application logic
Browser
Angular Application
Common Mistakes
1. Editing node_modules manually
Avoid manually changing files inside the node_modules folder.
2. Working from the wrong folder
Make sure you are inside the Angular project folder before running Angular CLI commands.
3. Confusing project root and src
The project root contains configuration files, while src mainly contains application source code.
Summary
An Angular application contains different folders and configuration files, each having a specific purpose.
The most important development area is src, which contains the Angular application source code.
Important files such as main.ts, angular.json, package.json and tsconfig.json help configure and run the Angular application.