Skip to content

Project Structure

An Angular CLI-generated project follows a conventional layout: application code lives in src/app/, static assets in src/assets/, and each component/service/pipe typically gets its own folder or file group (.ts, .html, .css, .spec.ts). Modern Angular favors a feature-based structure β€” grouping files by what they do (e.g. orders/, users/) rather than by file type (all components in one folder, all services in another).

src/
β”œβ”€β”€ app/
β”‚ β”œβ”€β”€ app.component.ts
β”‚ β”œβ”€β”€ app.config.ts # providers, routes (standalone app setup)
β”‚ β”œβ”€β”€ core/ # singleton services, guards, interceptors
β”‚ β”‚ └── auth.service.ts
β”‚ β”œβ”€β”€ shared/ # reusable components/pipes used across features
β”‚ β”‚ └── loading-spinner.component.ts
β”‚ └── features/
β”‚ β”œβ”€β”€ users/
β”‚ β”‚ β”œβ”€β”€ user-list.component.ts
β”‚ β”‚ β”œβ”€β”€ user-list.component.html
β”‚ β”‚ β”œβ”€β”€ user-list.component.css
β”‚ β”‚ β”œβ”€β”€ user-list.component.spec.ts
β”‚ β”‚ └── user.service.ts
β”‚ └── orders/
β”‚ └── order-list.component.ts
β”œβ”€β”€ assets/ # images, fonts, static files
β”œβ”€β”€ environments/ # environment.ts, environment.prod.ts
β”œβ”€β”€ index.html
β”œβ”€β”€ main.ts # bootstraps the app
└── styles.css # global styles

Dumping every component into one flat components/ folder as the app grows β€” this works fine for small apps, but quickly becomes hard to navigate, since related files (a feature’s component, service, and tests) end up scattered rather than grouped together.

# Grows painfully as the app scales
src/app/components/
β”œβ”€β”€ user-list.component.ts
β”œβ”€β”€ order-list.component.ts
β”œβ”€β”€ product-list.component.ts
β”œβ”€β”€ ... (50 more components, no grouping)
# Feature-based grouping keeps related files together
src/app/features/
β”œβ”€β”€ users/ (user-list.component.ts, user.service.ts, ...)
β”œβ”€β”€ orders/ (order-list.component.ts, order.service.ts, ...)
  1. Where does the bulk of an Angular application’s code live in the default CLI structure?

    Answersrc/app/.
  2. What’s the difference between organizing by β€œfeature” versus by β€œfile type”?

    AnswerFeature-based grouping keeps everything related to one part of the app (component, service, tests) together in one folder; type-based grouping puts all components in one folder, all services in another, scattering related files as the app grows.
  3. What’s a common purpose for a core/ folder in a feature-based Angular project?

    AnswerSingleton, app-wide concerns like authentication services, HTTP interceptors, and route guards β€” things meant to be used once across the whole app, not per-feature.