SaaS app with angularjs and nodejs, how do i organize different clients? SaaS app with angularjs and nodejs, how do i organize different clients? angularjs angularjs

SaaS app with angularjs and nodejs, how do i organize different clients?


Since You seem to be using Angular, have you thought of using the routing service? See more about it Here : https://docs.angularjs.org/api/ngRoute/provider/$routeProvider

Basically what it does is it based on the url loads a html page and a controller (JS file). For example if your user would just be move to url.com/client1 and angular would load client1.html and client1CTRL.

A Simple Structure would be the following:

  • Index.Html- References to any dependencies, and in the body only a ng-view tag
  • Templates (The Html Templates for each of the users)
    • Login
    • Admin
    • Client 1 etc...
  • Scripts (JS)
    • External Scripts (Jquery, Angular ETC)
    • Index.js ( This is where you would have all your js controllers for each page)
  • Stylesheets
    • CSS FILES GO HERE

Example Angular Routing: Tutorial

var App = angular.module('saasApp', []);App.config(['$routeProvider',  function($routeProvider) {    $routeProvider.      when('/admin', {        templateUrl: 'templates/admin.html',        controller: 'AdminController'      }).      when('/client1', {        templateUrl: 'templates/client1.html',        controller: 'client1Controller'      }).      when('/login', {        templateUrl: 'templates/login.html',        controller: 'loginController'      }).      otherwise({        redirectTo: '/login'      });  }]);

Hope this works for what you are trying to do.


I guess your question is about Architecture. If I were to do same back-end and different front ends I would've implemented virtual template structure.

Permissions

I would have:

  1. a super user that has rights to setup multiple stores.
  2. an admin user that can manage a particular store

Super User template management.

  1. I would have base templates in /admin/templates and when I create a new store I would copy them and stick them in database
  2. I would create a menu with all the templates on the left hand side and have wysiwyg editor that allows me to modify those template for particular customer and upload additional assets (images, pdfs etc)
  3. Template would support swig syntax
  4. I would create a server route /get/tempalte/:id and dynamically parse those templates on server using swig engine

I hope this helps. The key here is to be able to update templates via browser and distribute them to new shops/customers via web panel.