Search code examples
angularmoduleangular6project-structureangular-module

Angular 6 should i create separate app or separate module for admin dashboard?


I am currently working on a angular 6 project to create a website ( a company website ) with following features

  1. Website which act as a company website + Online Store with landing pages where contents (like slider, text and images, list) can be changed from admin dashboard.

  2. Also there is a products page with shopping cart where users can purchase company products by login in

  3. Admin Dashboard where admin can control the contents in the website

Note :

Admin dashboard and contents of website ( expect the product pages and shopping card ) is connected to a NodeJs Api website-api

Products listing and shopping cart is connected to different NodeJs Api

Presently i have created an angular project with following modules

  • Admin Modules : with components and routes related to admin dashboard
  • Views Modules : with different components and routes related to different pages like home,about,contact us,careers etc

  • Product Modules : with components related to product page , listing and shopping cart

  • shared Module : With components which are shared between these different modules

Currently i have the following concerns :

  • How should i handle the project structure / modules to optimise it for performance ?

  • How should i handle authentication since i have the same app connected to two separate API ( should i have separate authentication ) ?

  • Should i create a separate angular 6 app for admin dashboard or should i stick with creating a different module in the same app ?

I appreciate any form of suggestion to improve the overall app performance


Solution

  • Performance

    First, you should optimize your own code : avoid O(n²) complexity (or more), request only the required HTTP data, don't import modules you don't use ...

    After that, you can also use lazy loading to load your modules on demand.

    Finally, you can use Server Side Rendering to optimize the loading time of your application.

    Splitting your app in two is of course going to impact your performance, but it highly depends on the content of both applications.

    Authentication

    It's up to you : you can either have two separate apps, with two separate databases and two different authentications, or you can have a single application with a role-based database.

    I've seen and worked on both, neither is the best nor the worst. They both have advantages and drawbacks : it's up to you to choose.

    Given those two opinions, you must guess the last : you can choose either way for your application. It really depends on you, your team, and your end users.