Angular Architecture
Priority: P0 (CRITICAL)
Principles
- •Feature-Based: Organize by feature, not type (e.g.,
features/dashboard/containing components, services, and models). - •Standalone First: Use Standalone Components/Pipes/Directives. Eliminate
NgModuleunless interacting with legacy libs. - •Core vs Shared:
- •
core/: Global singletons (AuthService, Interceptors). - •
shared/: Reusable UI components, pipes, utils (Buttons, Formatters).
- •
- •Smart vs Dumb:
- •Smart (Container): Talks to services, manages state.
- •Dumb (Presentational): Inputs/Outputs only. No logic.
Guidelines
- •Lazy Loading: All feature routes MUST be lazy loaded using
loadComponentorloadChildren. - •Flat Modules: Avoid deep nesting of modules.
- •Barrel Files: Use carefully. Prefer direct imports for better tree-shaking in some build tools (though modern bundlers handle barrels well).