Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • AngularJS Tutorial
  • AngularJS Directives
  • AngularJS Functions
  • AngularJS Filters
  • AngularJS Examples
  • AngularJS Interview Questions
  • Angular ngx Bootstrap
  • AngularJS Cheat Sheet
  • AngularJS PrimeNG
  • JavaScript
  • Web Technology
Open In App
Next Article:
Folder Structure of Angular Project
Next article icon

Folder Structure of Angular Project

Last Updated : 19 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Creation and Organization of an Angular Project in a well-planned manner is very important for readability, scalability, and manageability. A clear structure helps in managing code, configurations, modules and services effectively. In this article, we are going to have a clear understanding of the folder structure of Angular Project. We will explore best practices for organizing an Angular Project Folder Structure.

Prerequisites

  • Basic Knowledge of Angular.
  • NodeJs and npm
  • An IDE or VS Code.

Table of Content

  • Folder Structure Overview:
  • Steps to Create Folder Structure
  • Improved Files and Folder Structure:
  • Why Angular Project Structure is Important?
  • Best practice for Angular Project Structure

Folder Structure Overview

Screenshot-2024-07-19-113959
Folder Structure Overview

Steps to Create Folder Structure

Step 1: Open the terminal, Go the path where you want to create the project and run the command with the name of the project to create project.

ng new Folder-Structure
cd Folder-Structure

Step 2: Run the command to create a Component, inside src/app.

ng generate component components/Header
ng generate component components/Footer
ng generate component components/Main

Step 3: Run the Command to create a Service

ng generate service services/Product
ng generate service services/Customer

Step 4: Run the command to create Directives

ng generate directive directives/my-directive

Step 5: Run the command to create Model

ng generate class models/User

Step 6: Go the Folder-Structure and Run the command to create core Folder

mkdir src/app/core

The above command , will create a folder named 'core'. You can add components, services inside core folder.

Step 7: Go the Folder-Structure and Run the command to create Pages Folder.

 mkdir src/app/pages

The above command , will create a folder named 'Pages'.

Step 8: Go the Folder-Structure and Run the command to create Shared Folder.

mkdir src/app/shared

The above command , will create a folder named 'Shared'. You can add related components, services inside shared folder.

Improved Files and Folder Structure

For managing the project in more concise way we can create these folder for more manageable code.

  • Components Folder
  • Services Folder
  • Directives Folder
  • Model Folder
  • Core Folder
  • Shared Folder
  • Pages Folder
Screenshot-2024-07-19-125630
Improved Folder Structure

Folder Structure contains files and Folders that are present in directory. There are multiple files and folders, for example, components, services, directives, shared, etc.

Components Folder

In Angular, all the components are made inside src\app directory by default. Components are the basic building blocks of an Angular Project, containing templates, styles and behaviour of a part of the user Interface. It contains an individual component folder each with their own HTML, CSS, TypeScript and unit test cases.

Services Folder

This Folder is responsible for handling all the services and API calls. Each service has a spec.ts file for testing purpose and a ts file in which our main functionality for service will be written. Services refers to a reusable variable/data that can be shared and used outside component in which it is defined. These are basically typescript classes with @injectable decorator, which means this class is a service and can be injected in the component that needs that service.

Directives Folder

This Folder is responsible for handling all the directives. Directives are simply and instruction to DOM. We can have custom as well as build-in Directives in Angular.

Model Folder

This folder stores all the typescript model classes used to define data structure and business logic of an application. It encapsulates properties or methods of a concept.

Core Folder

This folder serves as central storage hub of an angular application where you keep all important services, guards, interceptors for smooth functioning of the application. It helps in organizing your application as well as making it cleaner and efficient for usage.

Shared Folder

This folder is responsible for storing all the components, services, directives, etc. This folder is necessary for organizing shared files and folders.

Pages Folder

This folder serves as a directory to manage views and pages. It helps in organizing related components, template, styles ,etc. by keeping them under one folder. It helps you by giving clarification and easiness in making an angular Project.

Why Angular Project Structure is Important?

Project Structure defines the organization of the code and files. A clean, decent project structure shows a clean written code, which helps to increase its readability and developers can understand it easily. Also while deploying code, it helps to easily recognize the files, which saves time.

Best practice for Angular Project Structure

It is the best practice to make a Project structure for Angular project, separate files and folders for difference purpose helps in keeping the files aligned and making the work of end user easy. For Example: Components to be in Components folder, Services to be in Services folder, etc.

Conclusion

Creating a well-organized folder structure is very important for maintaining an Angular Project. It increases readability, scalability, clarity of an angular application. It is a good practice to keep folder structure well organized to manage code.


Next Article
Folder Structure of Angular Project

D

deepansaw28
Improve
Article Tags :
  • Web Technologies
  • AngularJS

Similar Reads

    Folder Structure of a NestJS Project
    Organizing a NestJS project with a well-planned folder structure is important for readability, scalability, and maintainability. A clear structure helps in managing code, configurations, modules, and other assets effectively. In this article, we are going to learn the folder structure of a NestJS pr
    5 min read
    Folder structure for a Node JS project
    Organizing a Node JS project with well planned folder structure is crucial for readability, scalability, and maintainability. A clear structure helps in managing code, configurations, modules, and other assets effectively. In this article, we are going to learn the folder structure of the Node JS pr
    5 min read
    Folder Structure for a React JS Project
    Organizing a React project with a well-planned folder structure is very important for readability, scalability, and maintainability. A clear structure helps in managing code, configurations, modules, and other assets effectively. In this article, we are going to learn the folder structure of the Rea
    5 min read
    Angular CLI | Angular Project Setup
    Angular is an open-source front-end web application framework that is used for building single-page and complex web applications. By default, angular uses TypeScript for creating logic but as the browser doesn't know typescript it converts typescript into javascript in order to make typescript under
    3 min read
    Top Angular Projects with Source Code
    Angular is a powerful framework for building websites and web applications. It provides the structure and tools developers need to create efficient, interactive, and organized applications. Think of it as a set of tools and guidelines that help developers create apps that run smoothly on the web, li
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences