Skip to content

Angular Architecture πŸ—οΈ

Angular follows a component-based architecture where everything is organized around components, services, and modules. Here’s how it all fits together.

V19 and below

src/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ app.component.ts # Root component
β”‚ β”œβ”€β”€ app.component.html # Root template
β”‚ β”œβ”€β”€ app.component.css # Root styles
β”‚ β”œβ”€β”€ app.config.ts # App configuration
β”‚ └── main.ts # Bootstrap file
β”œβ”€β”€ assets/ # Static files
└── environments/ # Environment configs

V20 and above

src/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ app.ts # Root component
β”‚ β”œβ”€β”€ app.css # Root styles
β”‚ β”œβ”€β”€ app.html # Root template
β”‚ β”œβ”€β”€ app.config.ts # App configuration
β”‚ β”œβ”€β”€ app.routes.ts # App routes
β”‚ └── main.ts # Bootstrap file
β”œβ”€β”€ assets/ # Static files
└── environments/ # Environment configs
  • Purpose: UI building blocks that combine HTML, CSS, and TypeScript
  • Structure: Each component has a class, template, and optional styles
  • Example: A header, sidebar, or product card
  • Purpose: Share data and logic across components
  • Structure: Injectable classes that handle business logic
  • Example: API calls, data storage, authentication
  • Purpose: Group related components, services, and other code
  • Structure: @NgModule decorator with imports, declarations, providers
  • Note: Being replaced by standalone components
  • Purpose: Self-contained components without modules
  • Structure: standalone: true with direct imports and latest version we don’t need to specify standalone: true whatever component we create it will be standalone by default
  • Benefit: Simpler, more flexible architecture
Parent Component
↓ @Input()
Child Component
↑ @Output()
Parent Component

Modern Approach with Signals

Parent Component
↓ input()
Child Component
↑ output()
Parent Component
  • Input: Data flows down from parent to child
  • Output: Events flow up from child to parent
  • Services: Share data between any components

Angular automatically updates the UI when data changes:

  1. Trigger: User clicks, HTTP responses, timers
  2. Check: Angular scans for data changes
  3. Update: DOM updates reflect new data
  1. main.ts starts the application
  2. Root component loads
  3. Component tree builds
  4. Change detection begins
  • Dependency Injection: Angular provides services to components automatically
  • Decorators: @Component, @Injectable, @Input, @Output
  • Lifecycle Hooks: ngOnInit, ngOnDestroy, etc.
  • Templates: HTML with Angular syntax for data binding
  • Understand component-based architecture
  • Know the difference between modules and standalone components
  • Grasp input/output data flow
  • Recognize the role of services
  • Understand change detection basics
  1. Your First App - Build a simple Angular app
  2. Components Basics - Deep dive into components
  3. Services & DI - Learn dependency injection