Skip to content

Folder and File Structure

Marcin Ufniarz edited this page Feb 13, 2024 · 4 revisions

Sample folder and file structure for an Ionic project for a social networking website.

/my-app
  /src
    /app
      /core
        /services
          authentication.service.ts
          user.service.ts
          group.service.ts
          ...
        /guards
          authentication.guard.ts
          ...
        /interceptors
          http.interceptor.ts
          ...
        /utils
          firebase.util.ts
          ...
      /modules
        /account
          /pages
        /user
          /pages
            /signin
              signin.page.ts
              signin.page.html
              signin.page.scss
              signin.page.spec.ts
              /components
                form.component.ts
                ...
            /profile
              profile.page.ts
              profile.page.html
              profile.page.scss
              profile.page.spec.ts
            /edit-profile
              edit-profile.page.ts
              edit-profile.page.html
              edit-profile.page.scss
              edit-profile.page.spec.ts
          /components
            header.component.ts
            header.component.html
            header.component.scss
            header.component.spec.ts
            ...
        /group
          /pages
            /group
              group.page.ts
              group.page.html
              group.page.scss
              group.page.spec.ts
          /components
            group-info.component.ts
            group-info.component.html
            group-info.component.scss
            group-info.component.spec.ts
            ...
        ...
      /shared
        /components
          side-menu.component.ts
          side-menu.component.html
          side-menu.component.scss
          side-menu.component.spec.ts
          ...
        /directives
          custom-if.directive.ts
          ...
        /pipes
          custom-date.pipe.ts
          ...
    /assets
      /images
      /icons
    /environments
      environment.ts
      environment.prod.ts
  /node_modules
  /www
  /platforms
  /plugins
  config.xml
  ionic.config.json
  package.json
  ...

Here's a brief explanation of the directories:

  • /core: This folder contains all the core services, guards, and interceptors that are used throughout the application.

  • /modules: This folder contains feature modules such as home, profile, and group. Each module has its own pages and components.

  • /shared: This folder contains shared components, directives, and pipes that can be used across different modules.

  • /assets: This folder contains static files like images and icons.

  • /environments: This folder contains files for different environments like development and production.

Note: This structure is just a suggestion, and depending on the complexity and specifics of your application, you might need to adjust it. For a large application like a social network, consider using a state management library like NgRx or Akita, and structure your application accordingly.

Clone this wiki locally