NG
Programmers Picnic
AI-ML Classes by Champak Roy
New Angular Lesson

Angular Folders and Files

A complete Level 0 to expert lesson on what is created after Angular installation, why each file exists, what beginners should edit, and what advanced developers must understand.

Start Lesson

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.

Beginner Goal Know where to edit HTML, CSS, and TypeScript.
Intermediate Goal Know routes, components, assets, and services.
Expert Goal Understand build configuration, environments, libraries, and scalable structure.

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.

Simple meaning: Angular gives us a ready-made workshop. Some files are for writing our app. Some files are for telling Angular how to build the app. Some folders are created automatically.
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.

Angular Workspace Root Config angular.json package.json Source Code src/app components, routes Public Files public images, favicon, CNAME Dependencies node_modules installed packages Build Output dist final website files
The most important beginner folder is src/app. The most important expert file is usually angular.json.

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
In older Angular projects, you may see files like 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.

Root Folder Controls the Project angular.json Build, serve, assets, styles package.json Scripts and dependencies tsconfig.json TypeScript rules src Main application code public Static public files node_modules Downloaded packages
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>
The browser loads 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
src/app Folder app.ts Component logic app.html Component template app.css Component style app.routes.ts Page routes app.config.ts App providers app.spec.ts Testing file
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.

Angular Component = Logic + Template + Style TypeScript data methods events HTML visible structure buttons text and layout CSS colors spacing responsive design Together they create one reusable piece of UI.

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.

Angular Start Flow index.html browser loads main.ts bootstraps app app.config.ts providers App root component app.html template app.css style app.routes.ts pages

Start Flow in Simple Words

  1. The browser opens index.html.
  2. index.html contains <app-root>.
  3. main.ts starts Angular.
  4. Angular loads the root component.
  5. The root component uses its HTML and CSS.
  6. 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
For GitHub Pages custom domain, you can place a 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">
Starting with / 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"
              }
            ]
          }
        }
      }
    }
  }
}
The exact structure can vary by Angular version, but the idea is the same: 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"
  }
}
Beginners should not randomly edit 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

First learn these four files well: 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
Clean Intermediate Structure core global services, guards shared reusable components pages route-level screens models TypeScript data shapes routes connect URLs to pages This structure helps when the project becomes large.
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

Rule 1 Keep pages separate from reusable components.
Rule 2 Keep API logic inside services.
Rule 3 Keep data shapes inside models or types.
Rule 4 Use lazy routes for big features.
Rule 5 Keep global layout in core or layout folder.
Rule 6 Avoid one giant component.

Lazy Route Example

export const routes = [
  {
    path: 'courses',
    loadChildren: () =>
      import('./features/courses/courses.routes')
        .then(m => m.COURSES_ROUTES)
  }
];
Lazy loading means Angular can load a feature only when the user visits that feature. This is useful for large applications.

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/
When a student understands folders and files, Angular becomes much less frightening.

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