Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I’m trying to decide what to do I this scenario:

I want to create a product that I want to sell in a SaaS business model, I already have the backend more or less thought out and some code in place in nodejs. It handles oAuth, sessions, and controls the roles of the users when accessing a certain endpoint.

The doubt is in the frontend architecture: Each client will share the same functionality, but the design of their page will be completely different from one another. I want to put as much of the app logic that I can in services, so I can reuse it, my idea is to only change controllers/templates/directives from client to client, is this ok?

Should I have different folders and serve the static files for each client from nodejs? ex: in nodejs I would know the url for client1 was called so I would serve client1-index.html?

should I put each client in their own nodejs server and their own host?

what other ways are there?

I would like to be able to easily reuse the services as I’ll be introducing changes to the features or adding more, and I want to do this upgrades easily.

There will also be an admin panel that will be exactly the same for all of them, the part that will change is the one my client's users see.

Think of it as having many clients and giving each of them a store, so they can sell their stuff. They want an admin page and a public page. The admin page will the same for all, but the public page has to change.

So, and app that shares the same functionality across users but looks completely different for each one of them, how would you do it?

like image 937
Toddy Avatar asked Jan 19 '16 00:01

Toddy


People also ask

Can we use angular and NodeJS together?

One way to build Angular application is with NodeJS or Java, and the other method is in which we first build Angular, serve the static content with NGINX. If we are using it with NodeJS, then we also need to deal with server code. For example, the index. html page must be loaded with node.

Is NodeJS good for SaaS?

Node. js is an open-source JavaScript runtime platform built on Chrome's V8 engine. The efficiency and robust cross-platform development environment of Node. js have made it a popular choice for creating heavy SaaS applications like Netflix, Uber, NASA, and Linkedin.

Which is better AngularJS or NodeJS?

Node. js is more preferable when faster and scalable web development is needed. It is usually used for building small-sized projects. Angular is preferred when real-time applications, for example, chat apps, or instant messaging are needed.

Is AngularJS and NodeJS same?

AngularJS is a client-side framework. Node. js is a cross-platform runtime environment. AngularJS supports two-way data binding but cannot support database query writing features.


1 Answers

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.

like image 81
The Dark Knight Avatar answered Oct 01 '22 09:10

The Dark Knight