.
βββ π project
βββ π scripts
β βββ <file name>.js
β βββ ...
β
βββ π src
β βββ π app
β β βββ π pages
β β β βββ π <page name>
β β β β βββ π components
β β β β β βββ ...
β β β β β βββ index.ts
β β β β β
β β β β βββ π services
β β β β β βββ ...
β β β β β βββ index.ts
β β β β β
β β β β βββ π interfaces
β β β β β βββ ...
β β β β β βββ index.ts
β β β β β
β β β β βββ π store
β β β β β βββ π actions
β β β β β β βββ <actions group name>.actions.ts
β β β β β β βββ ...
β β β β β β βββ index.ts
β β β β β β
β β β β β βββ π effects
β β β β β β βββ <effects group name>.effects.ts
β β β β β β βββ ...
β β β β β β βββ index.ts
β β β β β β
β β β β β βββ π reducers
β β β β β β βββ <reducer name>.reducer.ts
β β β β β β βββ ...
β β β β β β βββ index.ts
β β β β β β
β β β β β βββ π selectors
β β β β β β βββ <selectors group name>.selectors.ts
β β β β β β βββ ...
β β β β β β βββ index.ts
β β β β β β
β β β β β βββ index.ts
β β β β β βββ state.ts
β β β β β
β β β β βββ <page name>.module.ts
β β β β
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ app.component.html
β β βββ app.component.spec.ts
β β βββ app.component.ts
β β βββ app-routing.module.ts (optional)
β β βββ app.module.ts
β β
β βββ π shared
β β βββ π components
β β β βββ π <component name>
β β β β βββ <component name>.component.html
β β β β βββ <component name>.component.scss
β β β β βββ <component name>.component.spec
β β β β βββ <component name>.component.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π directives
β β β βββ π <directive name>
β β β β βββ <directive name>.directive.spec.ts
β β β β βββ <directive name>.directive.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π services
β β β βββ π <service name>
β β β β βββ <service name>.service.spec.ts
β β β β βββ <service name>.service.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π pipes
β β β βββ π <pipe name>
β β β β βββ <pipe name>.pipe.spec.ts
β β β β βββ <pipe name>.pipe.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π guards
β β β βββ π <guard name>
β β β β βββ <guard name>.guard.spec.ts
β β β β βββ <guard name>.guard.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π interceptors
β β β βββ π <interceptor name>
β β β β βββ <interceptor name>.interceptor.spec.ts
β β β β βββ <interceptor name>.interceptor.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π utils
β β β βββ π <util name>
β β β β βββ <util name>.util.spec.ts
β β β β βββ <util name>.util.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π interfaces
β β β βββ <interface name>.interface.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π types
β β β βββ <type name>.type.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π enums
β β β βββ <enum name>.enum.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π constants
β β β βββ <constant name>.const.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ π store
β β β βββ π actions
β β β β βββ <actions group name>.actions.ts
β β β β βββ ...
β β β β βββ index.ts
β β β β
β β β βββ π effects
β β β β βββ <effects group name>.effects.ts
β β β β βββ ...
β β β β βββ index.ts
β β β β
β β β βββ π reducers
β β β β βββ <reducer name>.reducer.ts
β β β β βββ ...
β β β β βββ index.ts
β β β β
β β β βββ π selectors
β β β β βββ <selectors group name>.selectors.ts
β β β β βββ ...
β β β β βββ index.ts
β β β β
β β β βββ index.ts
β β β βββ state.ts
β β β
β β βββ shared.module.ts
β β βββ public-api.ts
β β
β βββ π assets
β β βββ π animations
β β β βββ <file name>.json
β β β βββ ...
β β β
β β βββ π fonts
β β β βββ π <font name>
β β β βββ <font name>-Regular.ttf
β β β βββ <font name>-Bold.ttf
β β β βββ <font name>-Light.ttf
β β β βββ <font name>-Italic.ttf
β β β βββ ...
β β β
β β βββ π i18n
β β β βββ <language code>.json
β β β βββ ...
β β β
β β βββ π icons
β β β βββ <file name>.svg
β β β βββ ...
β β β
β β βββ π images
β β β βββ <file name>.png
β β β βββ <file name>.jpg
β β β βββ <file name>.jpeg
β β β βββ ...
β β β
β β βββ π sprite
β β β βββ svg-sprite.svg
β β β
β β βββ favicon.ico
β β
β βββ π environments
β β βββ π endpoints
β β β βββ <api name>-endpoints.ts
β β β βββ ...
β β β βββ index.ts
β β β
β β βββ environment.ts
β β βββ environment.prod.ts
β β
β βββ π styles
β β βββ π mixins
β β β βββ <file name>.scss
β β β βββ ...
β β β βββ index.scss
β β β
β β βββ π variables
β β β βββ <file name>.scss
β β β βββ ...
β β β βββ index.scss
β β β
β β βββ π buttons
β β β βββ <file name>.scss
β β β βββ ...
β β β βββ index.scss
β β β
β β βββ π inputs
β β β βββ <file name>.scss
β β β βββ ...
β β β βββ index.scss
β β β
β β βββ π placeholders
β β β βββ <file name>.scss
β β β βββ ...
β β β βββ index.scss
β β β
β β βββ reset.scss
β β βββ styles.scss
β β βββ index.scss
β β
β βββ index.html
β βββ main.ts
β
βββ .editorconfig
βββ .eslintrc.json
βββ .gitignore
βββ angular.json
βββ karma.conf.js
βββ proxy.conf.json (optional)
βββ package.json
βββ package-lock.json
βββ tsconfig.app.json
βββ tsconfig.json
βββ tailwind.config.js
βββ README.md
The index.ts
allows Angular developers to keep all related things closely packed together, so they donβt need to bother about
the source file name. This helps to reduce the size of introductory statements.
Many developers mix the components and business logic, resulting in a complex and untidy mess that is difficult to comprehend. Hence, it is important to follow Angular development best practice guidelines and keep the logic separate from your components.
The testing process of UI and components differ from Logic Testing.
Different services for Business Logic are used to improve code reusability and quality. Having logic in a separate service will allow you to use it in multiple components. This would result in a reduction of build size and also lesser code.
Description:
In many projects, the core
folder is often used to store services and components that are considered
fundamental to the application's core functionality, such as authentication services, global data services, and
application-wide components like the main navigation bar.
General usage:
The key here is to maintain consistency and clarity in your project structure. If the distinction between core
and shared
doesn't serve your project's needs, it's perfectly fine to eliminate the core
folder and place everything
in the shared
or other relevant folders. Ultimately, the goal is to have a structure that makes it easy for developers to
understand and navigate the codebase.
Architectural choice:
The distinction between core
and shared
doesn't provide any meaningful separation in the project, it's perfectly
valid to opt for a flatter structure.
Arguments for not using the core folder in the project:
-
Simplicity and Consistency:
Having fewer folders and a flatter structure can make the project easier to navigate and understand for both new and existing developers. It simplifies the mental model required to locate and manage different parts of the code. -
Reduced Redundancy:
Placing all shared components, services, and other elements in a singleshared
folder can eliminate the redundancy introduced by maintaining both acore
and ashared
folder. This reduction in duplication can lead to cleaner and more maintainable code. -
Flexibility in Organizing:
With a flat structure, you have the flexibility to organize your code based on logical modules or features rather than forcing components into predefinedcore
andshared
categories. This can be especially helpful as your project evolves and its structure naturally adjusts to new requirements. -
Easier Refactoring:
Without thecore
folder, you won't have to worry about moving code betweencore
and other folders during refactorings or changes. This can save time and effort, as well as reduce the risk of breaking the application. -
Clarity in Responsibility:
In many cases, the line between what constitutescore
functionality and what belongs inshared
can become blurred. Placing everything inshared
emphasizes that all components and services are equally important and contributes to a more balanced understanding of the codebase. -
Ease of Onboarding:
For new team members, a simpler folder structure can speed up the onboarding process. They won't need to learn the nuances of distinguishing betweencore
andshared
items. -
Maintainability:
As the project grows, a flat structure can help prevent the creation of sprawling subfolders. This can lead to better maintainability and improved performance in version control systems.
Summary
In summary, eliminating the core
folder simplifies the project structure, reduces redundancy, and allows for greater
flexibility in organizing and maintaining the codebase. It aligns with the principle of simplicity and can lead to a
more efficient development process.