{"id":19874549,"url":"https://github.com/strongloop/loopback-multitenant-poc","last_synced_at":"2026-03-09T13:02:27.931Z","repository":{"id":66071278,"uuid":"51769226","full_name":"strongloop/loopback-multitenant-poc","owner":"strongloop","description":"LoopBack Multitenancy PoC","archived":false,"fork":false,"pushed_at":"2019-05-10T16:03:09.000Z","size":38,"stargazers_count":19,"open_issues_count":1,"forks_count":5,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-05-02T10:50:55.767Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strongloop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-15T16:37:56.000Z","updated_at":"2023-08-01T08:37:29.000Z","dependencies_parsed_at":"2023-02-20T19:30:56.031Z","dependency_job_id":null,"html_url":"https://github.com/strongloop/loopback-multitenant-poc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/strongloop/loopback-multitenant-poc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-multitenant-poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-multitenant-poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-multitenant-poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-multitenant-poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strongloop","download_url":"https://codeload.github.com/strongloop/loopback-multitenant-poc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strongloop%2Floopback-multitenant-poc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30297111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T11:12:22.024Z","status":"ssl_error","status_checked_at":"2026-03-09T11:10:54.577Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T16:24:03.574Z","updated_at":"2026-03-09T13:02:27.911Z","avatar_url":"https://github.com/strongloop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi-tenant LoopBack POC\n\nThis is a POC on implementing multi-tenancy in LoopBack using isolated processes and isolated data sources.\n\n## How is it implemented?\n\nA proxy (**Gateway**) sits in front of the individual tenant apps. Using the first segment of the URL path as the tenant identifier, Gateway forwards requests to the corresponding tenant app.\n\nTenant apps are complete LoopBack apps with their own configurations and application files, with a shared `node_modules` directory.\n\nIn the actual implementation tenants will be exposed to limited configurability of their apps via an API - mainly the ability to configure datasources and define models. For the POC, please edit the tenant app files manually.\n\nGateway starts the tenant apps, and requests are mapped using their port numbers. In this POC, this allows easy access to the apps' *explorer* app. Unix sockets might be a better option in the actual implementation.\n\nGateway is aware about new tenants being added and existing tenants being removed.\n\nPS: The code is modularly organized and well commented, please browse through it to better understand the implementation.\n\n## Instructions for a quick demo\n\nWe want to create two tenants with their own datasources and models.\n\nTenant one, named *foo*, will use MySQL as the datasource and have the models *Customer* and *Order*. Tenant two, named *bar*, will use MongoDB as the data source and have the models *Customer*, *Product*, and *Review*.\n\n**Clone this repo**\n\n```\n$ git clone git@github.com:strongloop/loopback-multitenant-poc.git\n```\n\n**Install dependencies**\n\n`cd` to the repo directory and install the dependencies.\n\n```\n$ npm install\n```\n\n**Install commandline tools**\n\n```\n$ [sudo] npm link\n```\n\nThis will install two commandline tools - `mtm` (multi-tenant manager) and `mtg` (multi-tenant gateway). `mtm` is used for managing tenants, `mtg` is the Gateway manager.\n\nIn the actual implementation, the functionality of these two tools will be also be exposed as APIs.\n\nNOTE: Only the very basic functionality of `mtm` and `mtg` are implemented in the POC as of 15th Feb, 2016.\n\n**Create tenant \"foo\"**\n\n```\n$ mtm add foo\n```\n**Create \"Customer\" model for tenant \"foo\"**\n\n```\n$ mtm model foo:Customer\n```\n\nThis will create a directory named *foo* under the *tenants* directory.\n\n**Create \"Order\" model for tenant \"foo\"**\n\n```\n$ mtm model foo:Order\n```\nMake the necessary changes in the `datasources.json`, `model-config.json`, and the model files for tenant \"foo\".\n\nSimilarly, add tenant \"bar\", and create and edit the necessary files.\n\n**Start the Gateway**\n\n```\n$ mtg start\n```\n\nThe Gateway will start the tenant apps, and accept connections on behalf of them. Gateway will be listening for connections on localhost at port 9000.\n\nThe tenant \"foo\" will be accessible at `http://localhost:9000/foo`, and so on.\n\nA separate app for Gateway can be served at `http://localhost:9000/`.\n\n## Features\n\n* Customize `model-config.json` and `datasources.json` for each tenant\n* A tenant's `model-config.json` and `datasources.json` can be updated without having to restart other tenants\n* Each tenant can have custom middleware, components, and boot scripts, if required\n\n## Gateway Manager\n\nThe gateway manager works as the front facing proxy for the tenant apps. It is available as the `mtg` command on the command line.\n\nGateway must be started before the tenant apps can be accessed.\n\n**Start Gateway**\n\n```\n$ mtg start\n```\n\n**Restart Gateway**\n\nNot supported currently.\n\n```\n$ mtg restart\n```\n\n**Stop Gateway**\n\nNot supported currently. To stop, press `ctl+c`.\n\n```\n$ mtg stop\n```\n\n## Tenant Manager\n\nThe tenant manager is used for managing tenants and their models. It is available as the `mtm` command on the command line.\n\nUse a `tenant id` composed of alphanumerical characters only.\n\nThe tenant config files must be manually configured in the POC.\n\n**Add tenant**\n\n```\n$ mtm add \u003ctenant id\u003e\n```\n\n**Remove tenant**\n\n```\n$ mtm remove \u003ctenant id\u003e\n```\n\n**Start tenant app**\n\nNot supported currently.\n\n```\n$ mtm start \u003ctenant id\u003e\n```\n\n**Stop tenant app**\n\nNot supported currently.\n\n```\n$ mtm stop \u003ctenant id\u003e\n```\n\n**Restart tenant app (after making configuration changes)**\n\nNot supported currently.\n\n```\n$ mtm restart \u003ctenant id\u003e\n```\n\n**Create model for tenant**\n\n```\n$ mtm model \u003ctenant id:model name\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-multitenant-poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrongloop%2Floopback-multitenant-poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrongloop%2Floopback-multitenant-poc/lists"}