Express Multi-Tenant Configurations

Multi-tenancy boilerplate with Node.js, Express & Prisma

Gallery image 1
Gallery image 2
Gallery image 3

Two working multi-tenant patterns with Express, Prisma, and Postgres

This repository shows side-by-side implementations: shared database, separate schema per tenant and shared database, shared tables with a tenant key. Both include superadmin flows to manage tenants and users, JWT auth, and contact CRUD scoped per tenant. Run either variant with the Docker Compose profiles documented in the README.

When it is useful

You are choosing between stronger physical isolation vs. simpler shared-table tenancy, you need runnable code to stress-test Prisma migrations and queries, or you are onboarding engineers to tenant-aware APIs. It is an architecture reference, not a hosted SaaS.

What you can do

  • Boot the separate-schema profile or the shared-schema profile and compare operational tradeoffs summarized in the project’s comparison table.
  • Exercise tenant admin and tenant user flows as implemented for contacts.
  • Read the per-folder READMEs linked from the main documentation for deeper setup detail.

Limits

  • Compliance, legal isolation, and performance at scale depend on your domain; use the examples to inform design, not as certification.
  • Migrations, backups per tenant, and connection pooling get harder with separate schemas; discipline on queries matters more with shared tables.
  • Anything beyond the demo scope (analytics, billing, per-tenant theming) is custom engineering.

Frequently asked questions

Which multi-tenant patterns are shown?

Two side-by-side Express + Prisma + Postgres implementations: shared database with a separate schema per tenant, and shared database with shared tables keyed by tenantId.

What features are common to both?

Superadmin flows to manage tenants and users, JWT auth with role-based access, and contact CRUD scoped per tenant. Docker Compose profiles start either variant.

How do I run each variant?

Use docker compose --profile express-seperate-schema up for separate schemas, or docker compose --profile express-shared-schema up for the shared-schema path. Per-folder READMEs have deeper setup detail.

How should I choose between them?

Separate schemas favor stronger physical isolation, per-tenant backup, and compliance-style separation, at higher ops cost. Shared schema is simpler to maintain and update when strict isolation is not required. This repo is an architecture reference, not a hosted SaaS.

Continue exploring