Angular Project Structure and Important Files
Folder Overview
text
my-first-app/
src/
app/
app.ts component class
app.html component template
app.css component styles
app.spec.ts unit test
app.config.ts application providers
app.routes.ts routes
index.html the one HTML page
main.ts starting point
styles.css global styles
public/ static files (images, favicon)
angular.json CLI and build settings
package.json dependencies and scripts
tsconfig.json TypeScript settings
File names: Newer CLI versions generate short names like
app.ts and the class App. Older tutorials and many company projects use app.component.ts and AppComponent. Both work the same way. In this course we sometimes use the longer style with a suffix (for example UserService) because it makes the role of a class obvious.
index.html
html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MyFirstApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<app-root></app-root>
</body>
</html>
This is the only page. app-root is a custom tag. Angular fills it with your application.
main.ts: The Starting Point
typescript
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));
It starts the root component and gives it the configuration.
app.config.ts: Providers
typescript
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient } from '@angular/common/http';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes),
provideHttpClient(),
],
};
Here you switch on features: routing, HTTP, animations and more. In older projects this was done with AppModule.
The Root Component
typescript
// app.ts
import { Component, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
imports: [RouterOutlet],
templateUrl: './app.html',
styleUrl: './app.css',
})
export class App {
protected readonly title = signal('my-first-app');
}
html
<!-- app.html -->
<h1>{{ title() }}</h1>
<router-outlet />
| Part | Meaning |
|---|---|
@Component({...}) | Decorator that tells Angular this class is a component |
selector | The HTML tag name (app-root) |
imports | Other components, directives and pipes used in this template |
templateUrl / template | HTML file or inline HTML |
styleUrl / styles | CSS for this component only |
angular.json and package.json
angular.json: build, serve and test settings, asset folders, global stylespackage.json: dependencies and scripts such asnpm start,npm run build,npm testtsconfig.json: TypeScript strict settings (keep them on)public/: files copied as they are to the final site
Where do I write code? Almost all your work is inside
src/app/. Each feature gets its own folder with components, services and routes.
Conclusion
main.ts starts the app, app.config.ts registers features, App is the root component shown in index.html and you build everything else inside src/app.
Quick Summary: index.html > main.ts > bootstrapApplication(App, appConfig) > app-root.

