← back to the sandbox
LeanQ · Dec 2022–Dec 2023NestJSTypeScriptPostgreSQLMulti-Tenant SaaS

Multi-Tenant SaaS Platform

Role & context

As Senior Backend Developer and Project Lead at LeanQ, I was responsible for the architecture of a multi-tenant SaaS platform serving multiple client organizations from a single codebase. Leading a cross-functional team of 6 engineers, I owned the tenancy model from design through rollout.

The challenge

Each customer organization needed data isolation strong enough to satisfy security and compliance expectations, without the operational cost of standing up and maintaining a fully separate deployment per customer. The platform also needed a single, centralized authentication layer so users could move between tenant contexts without re-implementing auth per tenant.

Approach

I designed a subdomain-based tenant isolation model — each organization resolves to its own subdomain, routed to its own database, while a shared, centralized auth service handles identity across all tenants. This kept per-tenant data fully separated at the database level (avoiding shared-schema row-level isolation risk) while still letting the platform run as one operationally manageable system rather than N separate deployments.

Elasticsearch was integrated as part of the same platform to bring full-text search query times down from 2.1s to roughly 200ms, keeping search responsive as tenant data volume grew.

Tech stack

  • NestJS + TypeScript for the application layer
  • PostgreSQL, with per-tenant database isolation
  • Elasticsearch for search
  • Centralized authentication service shared across tenants

Results

  • Scaled to 1,000+ users across 15+ organizations on the platform
  • 99.9% uptime maintained in production
  • Search query latency cut from 2.1s to ~200ms