Vala Khosravi
This document will help you develop and design scalable Angular projects.
...
Acourding to Mathis Garberg - How to define a highly scalable folder structure for your Angular project scalable Angular projects directory should be like this:
Note! The [+] indicates that the folder has additional files.
|-- app
|-- modules
|-- home
|-- [+] components
|-- [+] pages
|-- home-routing.module.ts
|-- home.module.ts
|-- core
|-- [+] authentication
|-- [+] footer
|-- [+] guards
|-- [+] http
|-- [+] interceptors
|-- [+] mocks
|-- [+] services
|-- [+] header
|-- core.module.ts
|-- ensureModuleLoadedOnceGuard.ts
|-- logger.service.ts
|
|-- shared
|-- [+] components
|-- [+] directives
|-- [+] pipes
|-- [+] models
|
|-- [+] configs
|-- assets
|-- scss
|-- [+] partials
|-- _base.scss
|-- styles.scss
|-- modules
|-- home
|-- components
|-- pages
| |-- home
| |-- home.component.ts|html|scss|spec
|
|-- home-routing.module.ts
|-- home.module.ts
|-- core
|-- authentication
|-- authentication.service.ts|spec.ts
|-- header
|-- header.component.ts|html|scss|spec.ts
|-- footer
|-- footer.component.ts|html|scss|spec.ts
|-- guards
|-- auth.guard.ts
|-- no-auth-guard.ts
|-- admin-guard.ts
|-- http
|-- user
|-- user.service.ts|spec.ts
|-- api.service.ts|spec.ts
|-- interceptors
|-- api-prefix.interceptor.ts
|-- error-handler.interceptor.ts
|-- http.token.interceptor.ts
|-- mocks
|-- user.mock.ts
|-- services
|-- srv1.service.ts|spec.ts
|-- srv2.service.ts|spec.ts
|-- core.module.ts
|-- ensureModuleLoadedOnceGuard.ts
|-- logger.service.ts
|-- shared
|-- components
|-- loader
|-- loader.component.ts|html|scss|spec.ts
|-- buttons
|-- favorite-button
|-- favorite-button.component.ts|html|scss|spec.ts
|-- collapse-button
|-- collapse-button.component.ts|html|scss|spec.ts
|-- directives
|-- auth.directive.ts|spec.ts
|-- pipes
|-- capitalize.pipe.ts
|-- safe.pipe.ts
|-- models
|-- user.model.ts
|-- server-response.ts
|-- configs
|-- app-settings.config.ts
|-- dt-norwegian.config.ts
|-- scss
|-- partials
|-- _layout.vars.scss
|-- _responsive.partial.scss
|-- _base.scss
|-- styles.scss
This section is about code writing rules.
- All variables must be camelCase
- All field variables must be defined with type
- All variable names must introduce its usage
- Must start with "is"
- The default value must be true and its name should be defined by its default value
- Never pass opposite value of boolean variable to it self.
isActive = !isActive
- All array variables must end with "List" instead of "s"
- On iterating on array element name is array name without "List"
- Function type and type of input parameters should be determined
- All functions that used in template must be public
- Private function should be used in public functions
Naming pattern: "on" + (button Label, input name, ...) + (event type)
Example: onSubmitClick, onUserNameKeyEnter, ...
Naming pattern: (request type) + (requested model or models) + ("List" or "ById")
Example: getRetailerListWithProductList, postProductById, ...
ng g module --flat --routing=true "module name"
ng g component --module="module name" "component name"