Adaptable Angular Project Structure: A Flexible Foundation for Large-Scale Applications
Over the past years, I have worked in several large scale Angular applications.
Acknowledging the diverse factors such as organizational context, team dynamics, and application type, I am emphasizing the absence of a one-size-fits-all folder structure.
Instead, I am presenting a versatile foundation encompassing feature modules with containers and components, shared modules, and core modules.
This adaptable structure enhances application understanding, providing a blueprint that can be tailored to specific project needs. By offering a degree of transparency, developers gain valuable insights without constraining the end-user experience.
src/
├── app/
│ ├── core/
│ │ ├── services/
│ │ │ ├── auth.service.ts
│ │ │ └── ...
│ │ └── ...
│ ├── features/
│ │ ├── dashboard/
│ │ │ ├── components/
│ │ │ │ ├── candidate-summary
│ │ │ │ │ ├── candidate-summary.component.ts
│ │ │ │ │ └── ...
│ │ │ │ ├── job-summary
│ │ │ │ │ ├── job-summary.component.ts
│ │ │ │ │ └── ...
│ │ │ │ └── ...
│ │ │ ├── container/
│ │ │ │ ├── dashboard.component.ts
│ │ │ │ └── ...
│ │ │ └── directives/
│ │ ├── feature1/
│ │ │ ├── components/
│ │ │ │ ├── component-a
│ │ │ │ │ ├── component-a.component.ts
│ │ │ │ │ └── ...
│ │ │ │ └── ...
│ │ │ ├── container/
│ │ │ │ ├── feature-1.component.ts
│ │ │ │ └── ...
│ │ │ └── directives/
│ ├── shared/
│ │ ├── components/
│ │ │ ├── header.component.ts
│ │ │ └── footer.component.ts
│ │ ├── directives/
│ │ │ └── ...
│ │ └── pipes/
│ │ └── ...
│ └── app.module.ts
└── ...
You can enhance this hierarchy further by categorizing your components into smart & dumb components.
Advice
- Do not nest components to indicate their parent child relationship, it might look alluring at first. But at some point, this will most likely become unmanageable.