Lesson Goal
After creating an Angular app, many students see many folders and files and become confused. This lesson explains the purpose of every important folder and file.
1. Level 0 Idea
An Angular project is not one single file. It is a complete workspace. The workspace contains configuration files, source code, assets, dependencies, and build output.
| Area | Simple Meaning | Beginner Should Edit? |
|---|---|---|
src/app |
Your Angular components, pages, routes, and logic. | Yes |
src/styles.css |
Global CSS for the whole app. | Yes |
public |
Static public files like favicon, images, or CNAME. | Sometimes |
angular.json |
Angular build and project configuration. | Carefully |
package.json |
Project scripts and dependencies. | Carefully |
node_modules |
Downloaded packages. | No |
dist |
Final build output. | No manual editing |
2. Big Picture Diagram
This diagram shows the Angular project as a complete system.
3. Angular Folder Tree
A fresh Angular project may look similar to this. Exact files can vary slightly depending on Angular version, routing, CSS choice, SSR choice, and selected tools.
programmers-picnic-angular-demo/
│
├── .angular/
├── .vscode/
├── node_modules/
├── public/
│ ├── favicon.ico
│ └── CNAME
│
├── src/
│ ├── app/
│ │ ├── app.config.ts
│ │ ├── app.css
│ │ ├── app.html
│ │ ├── app.routes.ts
│ │ ├── app.spec.ts
│ │ └── app.ts
│ │
│ ├── index.html
│ ├── main.ts
│ └── styles.css
│
├── angular.json
├── package.json
├── package-lock.json
├── tsconfig.json
├── tsconfig.app.json
├── tsconfig.spec.json
├── README.md
└── .gitignore
app.component.ts,
app.component.html, and app.module.ts.
In newer standalone Angular projects, you may see app.ts,
app.html, app.css, app.config.ts, and app.routes.ts.
4. Root-Level Files and Folders
Root-level files live directly inside the project folder. They control the whole Angular project.
| File or Folder | Purpose | Edit Level |
|---|---|---|
angular.json |
Main Angular workspace configuration. It controls build options, assets, styles, scripts, output path, and project targets. | Intermediate to Expert |
package.json |
Contains project dependencies and npm scripts like start, build, and test. |
Beginner to Expert |
package-lock.json |
Locks exact package versions installed by npm. | Do not manually edit |
tsconfig.json |
Main TypeScript configuration for the workspace. | Advanced |
tsconfig.app.json |
TypeScript configuration specifically for the Angular app build. | Advanced |
tsconfig.spec.json |
TypeScript configuration for test files. | Advanced |
.gitignore |
Tells Git which files and folders should not be committed. | Sometimes |
README.md |
Project notes and instructions. | Yes |
5. The src Folder
The src folder contains the actual application source code.
This is where most real Angular development happens.
src/
├── app/
├── index.html
├── main.ts
└── styles.css
| File or Folder | Purpose | Beginner Meaning |
|---|---|---|
src/app |
Main Angular app code: components, routes, services, pages. | Your app lives here. |
src/index.html |
Main HTML shell loaded by the browser. | The outer HTML page. |
src/main.ts |
Application starting point. It bootstraps Angular. | Angular starts here. |
src/styles.css |
Global styles for the complete app. | CSS for whole website. |
src/index.html
This is the browser’s first HTML file. It usually contains one important Angular root tag.
<app-root></app-root>
index.html. Then Angular takes control and fills the page inside <app-root>.
src/main.ts
This file starts Angular. It connects the Angular application component with browser rendering.
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { App } from './app/app';
bootstrapApplication(App, appConfig)
.catch((err) => console.error(err));
src/styles.css
This file is for global CSS. Use it for body style, fonts, common classes, and layout rules that should affect the whole website.
body {
margin: 0;
font-family: Arial, sans-serif;
background: #fff7ed;
color: #241407;
}
6. The src/app Folder
The src/app folder is the heart of an Angular application.
Most beginner edits happen here.
src/app/
├── app.config.ts
├── app.css
├── app.html
├── app.routes.ts
├── app.spec.ts
└── app.ts
| File | Purpose | Simple Explanation |
|---|---|---|
app.ts |
Main root component TypeScript file. | Controls the main app component. |
app.html |
Main root component template. | Write visible HTML here. |
app.css |
CSS only for the root component. | Style the root app page. |
app.routes.ts |
Route configuration. | Maps URLs to pages. |
app.config.ts |
Application-level providers and configuration. | Add router, HTTP, animations, etc. |
app.spec.ts |
Test file for the root component. | Used for automated testing. |
7. Component Files
Angular apps are built using components. A component usually has three main parts.
Example Component
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
imports: [],
templateUrl: './app.html',
styleUrl: './app.css'
})
export class App {
title = 'Programmers Picnic Angular Demo';
}
What Each Part Means
| Part | Meaning | Example |
|---|---|---|
@Component |
Decorator that tells Angular this class is a component. | @Component({...}) |
selector |
HTML tag name for the component. | <app-root></app-root> |
templateUrl |
HTML file attached to the component. | ./app.html |
styleUrl |
CSS file attached to the component. | ./app.css |
export class App |
The TypeScript class for the component. | title = 'Demo' |
8. How an Angular App Starts
When the browser opens the Angular website, files are loaded in a specific flow.
Start Flow in Simple Words
- The browser opens
index.html. index.htmlcontains<app-root>.main.tsstarts Angular.- Angular loads the root component.
- The root component uses its HTML and CSS.
- If routes exist, Angular loads the page for the current URL.
9. Assets and Public Files
Angular projects may use a public folder for static files that should be copied as-is during build.
public/
├── favicon.ico
├── logo.png
├── banner.jpg
└── CNAME
CNAME file in public.
During build/deploy, it should be copied to the final site output.
Correct Image Path
<img src="logo.png" alt="Logo">
Common GitHub Pages Mistake
<img src="/logo.png" alt="Logo">
/ means root path. This can break on repository-based GitHub Pages deployment.
For custom domain root, it is usually okay, but beginners should still prefer simple relative paths.
10. Configuration Files
Configuration files tell Angular, TypeScript, npm, and Git how the project should work.
angular.json
This is the main Angular workspace configuration file.
{
"projects": {
"programmers-picnic-angular-demo": {
"architect": {
"build": {
"options": {
"outputPath": "dist/programmers-picnic-angular-demo",
"index": "src/index.html",
"browser": "src/main.ts",
"styles": [
"src/styles.css"
],
"assets": [
{
"glob": "**/*",
"input": "public"
}
]
}
}
}
}
}
}
angular.json tells Angular where the main entry file, styles, assets, and output folder are.
package.json
{
"scripts": {
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"deploy:github": "ng deploy --base-href=/"
},
"dependencies": {
"@angular/core": "...",
"@angular/common": "...",
"@angular/router": "..."
},
"devDependencies": {
"@angular/cli": "...",
"typescript": "..."
}
}
tsconfig.json
TypeScript configuration controls how TypeScript code is checked and compiled.
{
"compilerOptions": {
"strict": true,
"target": "ES2022"
}
}
angular.json or tsconfig.json.
A small wrong comma or path can break the project.
11. Automatically Generated Folders
Some folders are created by tools. You normally do not edit them manually.
| Folder | Created By | Purpose | Commit to Git? |
|---|---|---|---|
node_modules |
npm install |
Stores downloaded packages. | No |
dist |
ng build |
Final website build output. | Usually no, except deployment branches/tools |
.angular |
Angular CLI | Cache for faster builds. | No |
Install Packages Again
If node_modules is missing, run:
npm install
Create Build Output
ng build
12. Beginner Editing Map
Beginners should know exactly which files to edit for common tasks.
| Task | File to Edit | Example |
|---|---|---|
| Change visible text | src/app/app.html |
Edit headings, paragraphs, buttons. |
| Change page style | src/app/app.css |
Change colors, spacing, cards. |
| Change global body style | src/styles.css |
Set body font and background. |
| Add app title variable | src/app/app.ts |
title = 'My App' |
| Add images | public |
Put logo.png in public. |
| Add deploy command | package.json |
Add deploy:github script. |
Beginner Rule
app.html, app.css, app.ts, and styles.css.
13. Intermediate Angular Structure
As an Angular app grows, you should not keep everything inside only one component. You should divide the app into pages, components, services, and models.
src/app/
├── core/
│ ├── services/
│ └── guards/
│
├── shared/
│ ├── components/
│ └── pipes/
│
├── pages/
│ ├── home/
│ ├── courses/
│ ├── students/
│ └── contact/
│
├── models/
│ └── course.model.ts
│
├── app.config.ts
├── app.routes.ts
└── app.ts
| Folder | What Goes Inside |
|---|---|
core |
Services used across the whole app, authentication, guards, interceptors. |
shared |
Reusable buttons, cards, pipes, directives, layout components. |
pages |
Home page, dashboard page, login page, courses page. |
models |
TypeScript interfaces and types, such as Student or Course. |
14. Expert-Level Angular Structure
Expert Angular development is about scale, maintainability, testing, performance, and clean architecture.
Feature-Based Structure
src/app/
├── core/
│ ├── auth/
│ ├── http/
│ ├── layout/
│ └── services/
│
├── shared/
│ ├── ui/
│ ├── pipes/
│ ├── directives/
│ └── utils/
│
├── features/
│ ├── dashboard/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── services/
│ │ └── dashboard.routes.ts
│ │
│ ├── courses/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── services/
│ │ └── courses.routes.ts
│ │
│ └── students/
│ ├── components/
│ ├── pages/
│ ├── services/
│ └── students.routes.ts
│
├── app.config.ts
├── app.routes.ts
└── app.ts
Expert Rules
Lazy Route Example
export const routes = [
{
path: 'courses',
loadChildren: () =>
import('./features/courses/courses.routes')
.then(m => m.COURSES_ROUTES)
}
];
15. Common Mistakes
| Mistake | Why It Is Wrong | Correct Habit |
|---|---|---|
Editing node_modules |
Changes will disappear after reinstall. | Never edit it manually. |
Editing dist |
Build output is regenerated. | Edit source files, then run ng build. |
Putting all code in app.ts |
App becomes hard to maintain. | Create components, pages, and services. |
| Using absolute image paths blindly | Can break on GitHub Pages. | Use correct relative paths or configure base href properly. |
Randomly changing angular.json |
Can break builds. | Change it only when you understand the option. |
| Committing secrets | Public GitHub repos expose files. | Never commit private API keys. |
16. Student Assignment
Open your Angular project and identify each of the following files. Write one sentence about each file.
Mini Project
Create this clean structure:
src/app/
├── pages/
│ ├── home/
│ ├── about/
│ └── courses/
│
├── shared/
│ └── components/
│ ├── header/
│ └── footer/
│
└── core/
└── services/
Final Summary
| Question | Answer |
|---|---|
| Where do I edit visible HTML? | src/app/app.html |
| Where do I edit component CSS? | src/app/app.css |
| Where do I write global CSS? | src/styles.css |
| Where does Angular start? | src/main.ts |
| Where is the outer HTML page? | src/index.html |
| Where are project scripts? | package.json |
| Where is Angular build configuration? | angular.json |
| Which folder should I not edit manually? | node_modules and dist |