Hi all,
Frappe’s multi-site approach to multi-tenancy works really well. I’ve used it for years. But it doesn’t help when you have one site and want to run a SaaS-style product on it, where different customers share the same instance and can’t see each other’s records.
Frappe already has some pieces for this, like User Permissions. The trouble is they don’t go all the way. Naming series, DocTypes and a bunch of other places still assume one site means one company. That’s a reasonable assumption for ERPNext, but it gets in the way once you try to host multiple organisations on one site.
I needed this for a SaaS project I was building, so I wrote an app for it: saas_platform. Every record gets tagged with a tenant_id (users included), and Frappe filters on it, so one customer never sees another’s data. It also handles tenant onboarding and subscriptions. It’s MIT licensed, and the code is here: GitHub - vyogotech/saas_platform: Frappe app for Single Site Multi-tenant foundations · GitHub
I’d like developers to try it and tell me what breaks. If you spot a place where data leaks between tenants, or somewhere Frappe’s core fights the approach, please open an issue. PRs are very welcome too. I want to make this better with the community, not just for myself.
How to try it
There are two ways. The first is the usual bench route:
bench get-app https://github.com/vyogotech/saas_platform.git
bench --site your-site.localhost install-app saas_platform
bench --site your-site.localhost migrate
The second is the fastest. We publish single-node Frappista images that come with ERPNext, MariaDB, Redis and a ready site (dev.localhost) already set up. Clone the app and mount it into the container:
git clone https://github.com/vyogotech/saas_platform.git
docker run -d \
--name saas-test \
-p 8080:8000 \
-v $(pwd)/saas_platform:/home/frappe/frappe-bench/apps/saas_platform \
docker.io/vyogo/erpnext:sne-version-16
Give it a minute for the services to start, then install the app and run the migration steps inside the container:
docker exec -it saas-test bash
bench --site dev.localhost install-app saas_platform
bench --site dev.localhost migrate
Then open http://localhost:8080 and log in as Administrator (password admin). Since the code is mounted from your machine, any change you make in the checkout shows up in the container. More about the images: GitHub - vyogotech/frappista: s2i based images for Frappe Framework. Experience all in one pre-installed Frappe and apps. · GitHub
Will it scale?
A single site running ERPNext or any other app does feel monolithic. In production, though, it’s already running as multiple processes. I’ve also built a microservices library for Frappe/ERPNext to help scale things without changing even a single line of existing code. If you want to try that as well, it’s here: GitHub - vyogotech/erpnext-microservices-lib: Foundational library to scale out erpnext/any frappe app into individual services. · GitHub
Thanks for reading. Let me know how it goes.
Varun
Vyogo Technologies