Introduction
Ever opened a large Angular codebase and felt lost within a maze of folders? You’re not alone. Organizing your Angular project structure becomes critical as the app grows—especially in enterprise-level apps where maintainability, scalability, and team collaboration matter the most.
In this guide, you’ll discover battle-tested best practices for Angular folder and file structure, using a complex frontend project as an example. Ready to streamline your workflow?
Why Folder Structure Matters in Angular Projects
Before diving into naming conventions and folder trees, let’s understand why it matters:
- Scalability: A clear structure supports app growth.
- Maintainability: Easier for teams to find and update code.
- Separation of Concerns: Encourages modular design.
- Onboarding: New developers understand the layout quickly.
Project Overview: Complex Angular Application Example
Let’s take an enterprise-level insurance platform with features like:
- User dashboards
- Admin panels
- Claims management
- Payments & transactions
- Role-based access control
- Multiple APIs and shared components
We’ll structure the project accordingly.
Recommended Angular Folder Structure (Feature-Based)
/src
│
├── app
│ ├── core # App-wide singletons: services, guards, interceptors
│ ├── shared # Reusable components, pipes, directives
│ ├── features # Modularized feature folders
│ │ ├── dashboard
│ │ │ ├── components
│ │ │ ├── pages
│ │ │ └── dashboard.module.ts
│ │ ├── claims
│ │ │ ├── components
│ │ │ ├── services
│ │ │ ├── models
│ │ │ └── claims.module.ts
│ │ └── payments
│ │ ├── ...
│ ├── state # NgRx store: actions, reducers, effects
│ ├── assets
│ ├── environments
│ └── app.module.ts
Folder-by-Folder Breakdown
1. Core Module
Houses application-wide services, interceptors, and guards. These are singletons and don’t depend on feature modules.
Example:
/core
├── interceptors
│ └── auth.interceptor.ts
├── guards
│ └── role.guard.ts
├── services
│ └── auth.service.ts
└── core.module.ts
Make sure CoreModule
is imported only once—in AppModule
.
3. Feature Modules
Each major feature (e.g., dashboard, claims, payments) gets its own folder, components, services, and routes.
Example:
/features/claims
├── components
│ └── claim-form
├── pages
│ └── claim-detail.page.ts
├── services
│ └── claims-api.service.ts
├── models
│ └── claim.model.ts
└── claims.module.ts
➡ Lazy load these modules for performance.
4. State Management Folder (NgRx)
If you’re using NgRx, store all app-wide and feature-specific state here:
/state
├── auth
│ ├── auth.actions.ts
│ ├── auth.reducer.ts
│ ├── auth.effects.ts
│ └── auth.selectors.ts
├── claims
│ └── ...
└── app.state.ts
Organizing store files by domain keeps things manageable in the long run.
Best Practices You Should Follow
Use Feature-Based Architecture
Organize by features, not types. For example, prefer:
/features/claims/claims.service.ts
Over:
/services/claims.service.ts
Group UI Logic
Separate components into components
and pages
:
- Pages: Route components (containers)
- Components: Reusable presentational components
Prefix Files with Type Indicators
This helps with quick identification in file trees:
.component.ts
.service.ts
.model.ts
.guard.ts
.pipe.ts
Common Mistakes to Avoid
Mistake | Why It’s Bad |
---|---|
Flat file structure | Becomes unmanageable as app scales |
Mixing shared & feature-specific | Leads to accidental imports, tight coupling |
Avoiding lazy loading | Slows down app load time |
Putting logic in components | Violates separation of concerns |
FAQs on Angular Folder Structure
What’s the difference between Core and Shared modules?
Core: Singleton services used app-wide.
Shared: Reusable UI elements used across multiple modules.
Should I always use NgRx?
Only if your app has complex state logic (e.g., interdependent components, API caching, user roles). For simpler apps, services with BehaviorSubject
might suffice.
Can I combine page and component folders?
If your feature is small (1-2 components), yes. But for scalable apps, separation is cleaner and helps avoid technical debt.
Conclusion
A well-structured Angular project is more than a tidy folder tree—it’s a foundation for growth, collaboration, and performance. Whether you’re building dashboards or full-scale admin systems, adopting a feature-based structure, clear module boundaries, and reusable code practices can save you hours of debugging and onboarding time.
What’s your go-to structure for Angular apps? Share your thoughts below!