How to understand a Angular codebase
Angular apps are organised around components, services and dependency injection. Newer projects use standalone components bootstrapped with `bootstrapApplication`; older ones group everything into NgModules. State flows through injected services, RxJS observables and, since Angular 16, signals.
How to tell it's Angular
angular.jsonand@angular/coreinpackage.json- Files named
*.component.ts,*.service.ts,*.module.ts src/main.tscallingbootstrapApplicationorplatformBrowserDynamic().bootstrapModule
Where things usually live
- src/main.ts
- Bootstraps the root component or module.
- src/app/app.config.ts
- Standalone apps: global providers such as router, HTTP client and interceptors.
- src/app/app.routes.ts
- Route definitions, lazy-loaded features and guards.
- src/app/**/*.component.ts
- Components: class logic, with the template inline or in a
.component.htmlfile. - src/app/**/*.service.ts
- Injectable services: API calls, shared state and business logic.
- src/app/core/ and shared/
- A common convention: app-wide singletons in
core, reusable pieces inshared. - src/environments/
- Per-environment settings swapped at build time.
Conventions, not rules. Real projects rename and move things, so confirm against the repository.
Where to start reading
src/main.tsandapp.config.ts(orapp.module.ts), to see providers and interceptorsapp.routes.ts, to map URLs to features- The services a feature injects, since most logic lives there
How a request moves through the code
main.tsbootstraps the app with its providers.- The router matches the URL, runs guards and resolvers, and lazy-loads the feature if needed.
- The routed component is created; Angular injects the services listed in its constructor or
inject()calls. - Services call the backend through
HttpClient, passing through any HTTP interceptors (auth headers, error handling). - Results arrive as observables or signals, and the template updates through change detection.
Questions to ask about the repository
- Which HTTP interceptors are registered, and what does each one do to requests?
- Which services are singletons and which are provided per component?
- Which routes are lazy-loaded, and what guards protect them?
- Is this app using signals, RxJS or both for state, and where?
What trips people up
- Where a service is provided changes whether components share one instance; check
providedInand componentprovidersarrays. - Observables do nothing until subscribed, so a call that seems to do nothing may be missing a subscription or an
asyncpipe. - Templates in
.component.htmlfiles hold much of the logic; read them alongside the class.