This document outlines the recommended folder structure for the project, focusing on maintaining clarity, scalability, and maintainability. A well-organized structure is crucial for collaboration and the scaling of the project.
The src folder serves as the root of the application's source code. This folder contains the following sub folders inside it
assets: This folder houses all the images, icons, and i18n files etc.app: This folder contains the core components and logic of the application.index.html: This file is the main HTML file of the app. Acts as the entry point for the application.main.ts: This file is the main TypeScript file responsible for bootstrapping the entire application.
The app folder represents the heart of the application, providing a clear structure for the different components, features, styles, etc. To keep the entire logic well defined we are dividing the folder to 4 sub folders.
core: Contains essential elements that define the foundation of the application.features: Organizes the application's functionality into feature-specific modules.shared: Hosts reusable components, directives, and pipes shared across the project.styles: Centralizes global styles to ensure a consistent look and feel.
The core folder focuses on elements integral to the application's operation and maintenance.
constants: Holds core constants that drive the application's behavior. Segregating them enhances clarity and makes updates straightforward.guards: Contains different guards for example route guards, which control navigation and access to certain routes.interceptors: Hosts the core interceptors for example HTTP interceptors for processing requests and responses globally.interfaces: Defines interfaces that represent core data structures.services: Contains core services providing functionality shared across the application.utils: Houses utility files and common functions to be used throughout the application.
The features folder embraces modularity by separating different application features into distinct modules.
Reference: Angular Style Guide: Folders-by-feature structure
components: Contains components specific to each feature. Isolating these components simplifies maintenance and reduces dependencies.models: Houses models that encapsulate data structures unique to each feature.pages: Holds feature-specific pages, enhancing clarity and maintainability.services: Provides services tailored to each feature's requirements.
The shared folder facilitates the reuse of components, directives, and pipes across different parts of the application.
Note: only put the components/directives/pipes that are reusable across different features and not specific to a particular feature/component.
Reference: Angular Style Guide: Shared feature module
components: Contains reusable components that maintain consistency and minimize duplication.directives: Hosts custom directives that can be applied across various features.pipes: Contains pipes offering consistent data transformation and formatting.
The styles folder centralizes styling to ensure a coherent visual identity across the application.
_mixins.styles.scss: Contains mixins, reusable style patterns aiding in consistent UI design._override.styles.scss: Houses style overrides to adapt third-party styles._reset.styles.scss: Contains styles for resetting default browser styles, promoting a consistent starting point._variables.styles.scss: Defines style variables such as colors, typography, and breakpoints.- main.styles.scss: Imports and organizes style partials to create a unified and manageable styling structure.
- Organize the structure for clarity and ease of navigation.
- Embrace the single responsibility principle to ensure components have focused roles.
- Use feature modules to encapsulate related functionality.
- Prioritize reusability by placing components, directives, and pipes in the
sharedfolder. - Separate constants into different files for better organization.
- Keep styles structured and well-documented to maintain consistency.
- Create new feature modules with dedicated folders when adding new functionality.
- Utilize the
sharedfolder for adding reusable components, directives, and pipes. - Regularly remove unused code to prevent clutter and confusion.
- Maintain consistency in global styles to ensure a cohesive user experience.
- Update the documentation whenever significant changes to the folder structure are made.