Topics and lessons

How to design a multi-tenant application

A multi-tenant application is an application that is used by multiple clients, companies or customers, but each party will only see their own data.

The example application below is a single HR-application that can be used by different companies (clients) at the same time. You don’t want employees of one company to be able to see or process the data of other companies. The system administrator must be able to see and manage all data in the system.

In this lesson:

  1. Set up a System administrator
  2. Set up Page filters
  3. Set up Flow parts filters

Set up a System administrator

  1. The system administrator is not an employee of a client company. A simple way to identify a system administrator is to use a flag in the data item User.
    Create the flag System admin in the data item User.
data-item-user

Set up Page filters

  1. In all flows that process employees, you must create filters that make sure a user can only process employees of his/her own company, unless the user is the system administrator.
  2. The system administrator will see this:
employee-overview-system-administrator
  1. A manager from ACER will see this:
employee-overview-manager-acer
  1. The HP manager will see this:
employee-overview-manager-hp

Page filters

  1. Go to Design.
  2. Open the user flow (in this example: Employees).
  3. Open the overview page.
  4. Proceed to the screen where you can define a filter.
user-flow-content-dialog
  1. Select Apply a filter.
  2. Create this filter: the company of the current user = the company of the employee OR the current user is system administrator.
user-flow-employee-filter

This means that a user will only see his colleagues. Except when the user is system admin, then there is no filter and he/she will see all employees.

Set up Flow parts filters

Be aware that flow parts must know for which company they have to ‘work’.

  1. Create an input containing the company.
  2. The user flow where the flow part is included, provides the company: it is the company of the user.
  3. Make sure that the system administrator cannot start such a flow part (e.g., a raise should only be applied to the employees of a single company and not to all employees in the system). The easy way to do that: set a filter on the button that calls the flow part.
system-admin-false
  1. Now the button only appears if the user is not a system administrator.
user-flow-button

Flow parts

  1. Create the input Company. It gets the input from the user flow.
  2. Create a lookup for all employees of this company.
  3. Perform the necessary actions, for instance, by creating a repeat action.
repeat-action-flow-part