Angular Project Structure for Modularity and Reusability
Organize an Angular application into core, features, and shared directories with clear dependency boundaries.
Directory Structure
- core
- Contains application-wide functionality, including constants, guards, interceptors, models, and services.
- Code in
featurescan use this directory, butcoreshould never reference features or shared code.
- features
- Contains one directory for each feature module.
- Feature modules may reference
coreorshared, but should remain independent of one another.
- shared
- Contains reusable code such as directives, forms, pipes, and services.
- Feature modules may use this code, but
sharedmust not reference them.

src/├── app/│ ├── core/│ │ ├── constants/│ │ ├── decorators/│ │ ├── guards/│ │ ├── interceptors/│ │ ├── interfaces/│ │ │ ├── api/│ │ ├── models/│ │ ├── resolvers/│ │ ├── services/│ │ │ ├── api/│ │ ├── validators/│ ├── features/│ │ ├── auth/│ │ │ ├── password-reset/│ │ │ ├── sign-in/│ │ │ ├── sign-up/│ │ │ ├── verify/│ │ │ ├── auth.module.ts│ │ │ ├── auth.service.ts│ │ │ ├── auth-routing.module.ts│ │ ├── .../│ ├── shared/│ │ ├── components/│ │ ├── directives/│ │ │ ├── attribute/│ │ │ ├── structural/│ │ ├── forms/│ │ │ ├── input/│ │ │ ├── select/│ │ │ ├── .../│ │ ├── pipes/│ │ ├── services/│ ├── app.component.ts│ ├── app.module.ts│ ├── app-routing.module.tsassets/environments/styles/tests/theme/global.scssWhile the Angular coding style guide advises keeping directories flat, you should consider subdirectories when a folder exceeds seven files.
Consider creating sub-folders when a folder reaches seven or more files. – Angular coding style guide
Reference
Conclusion
Organizing an Angular app into core, features, and shared directories, each with a defined dependency direction, keeps feature modules isolated and reusable code centralized.
The dependency direction keeps the boundaries clear: core must not reference features or shared, while feature modules may depend on core and shared but not directly on one another. Code that is not specific to one feature belongs in core or shared instead of being imported from another feature.
The style guide’s seven-file threshold provides a practical point at which to consider dividing directories such as shared/services or core/guards into smaller subdirectories.
Related posts
Spying on Mock Object Properties in Jasmine
Working around Jasmine's "already been spied upon" error when spying on a mocked object's property with Object.getOwnPropertyDescriptor.

Integrating AWS Amplify with Eclipse Mosquitto for MQTT Messaging
Testing AWS Amplify's PubSub module against a local Eclipse Mosquitto broker before pointing it at AWS IoT Core.
Sign in with Slack Using Cognito User Pools and OIDC
Federating Cognito user pools with Slack over OIDC and wiring "Sign in with Slack" into a Next.js app with Amplify.
Deploying FastAPI on AWS Lambda with Lambda Web Adapter
Containerizing a FastAPI backend and deploying it to a single Lambda function with Lambda Web Adapter and AWS CDK.
Testing ECMAScript Modules with Jest
Fixing Jest's "Cannot use import statement outside a module" error by wiring up ESM support across package.json, TypeScript, and Jest config.
