---
title: "Inside LuBot's database-per-tenant architecture"
description: "LuBot, a solo-founder analytics chat product, gives each paying customer an isolated Postgres database by creating a Neon branch from a Stripe webhook, with Supabase kept as the control plane for orgs, users and billing."
url: "https://swe.quest/articles/inside-lubot-s-database-per-tenant-architecture-3e140bf0d5ffcd96"
canonical: "https://neon.com/blog/inside-lubots-database-per-tenant-architecture"
source: "Neon"
published: "2026-09-14"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["multi-tenancy","postgres","serverless","system-design"]
---

# Inside LuBot's database-per-tenant architecture

A post on [Neon](https://swe.quest/sources/neon.md), published 2026-09-14, 5 min read, Case study. Original: [https://neon.com/blog/inside-lubots-database-per-tenant-architecture](https://neon.com/blog/inside-lubots-database-per-tenant-architecture)

## Summary

LuBot, a solo-founder analytics chat product, gives each paying customer an isolated Postgres database by creating a Neon branch from a Stripe webhook, with Supabase kept as the control plane for orgs, users and billing. Branches get deterministic names so webhook retries are idempotent; the new branch is migrated, its connection URL is stored on the user row, and all access goes through a single tenant resolver function. Tenant computes autoscale from 0.25 to 4 CU and suspend after 300 seconds idle, avoiding roughly $20/month per idle tenant. Behind PgBouncer transaction-mode pooling, session settings like search\_path do not persist, so set them per query or at the role level, use direct URLs for migrations, and reset connections on check-in.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Multi-tenancy](https://swe.quest/tags/multi-tenancy.md) (Architecture & design)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)

## Prerequisites

- PostgreSQL schemas ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- connection pooling
- webhooks

## Keywords

Neon, PgBouncer, Stripe, Supabase, LuBot, FastAPI, search\_path

## Related posts

- [Database-per-User Architecture With Shared Application Environments: How and Why](https://swe.quest/articles/database-per-user-architecture-with-shared-application-environments-how-and-why-75dc31cab7b5ea77.md): Neon · 2024-10-18 · Medium · 8 min read · Multi-tenancy, PostgreSQL, System design, Schema migrations
  A single shared application environment serving many per-customer Neon Postgres databases keeps deployment simple, but every tenant database must stay at the same schema version and data residency is hard to offer.
- [A database per agent: how Turso and Neon give different answers](https://swe.quest/articles/a-database-per-agent-how-turso-and-neon-give-different-answers-05d4b7fddc0c2ee5.md): Turso · 2026-11-12 · Easy · 10 min read · Multi-tenancy, Databases, AI agents, SQLite, PostgreSQL
  Neon and Turso both support a database per agent but differ in the unit: Neon gives each agent a Postgres project with its own autoscaling compute that suspends after 5 minutes idle and is billed by CU-hour, while Turso treats each SQLite-compatible database as a file managed by a shared server, billed by rows read/written and storage with unlimited databases on paid plans.
- [The Noisy Neighbor Problem in Multitenant Architectures](https://swe.quest/articles/the-noisy-neighbor-problem-in-multitenant-architectures-3c851a6c15e7f85b.md): Neon · 2025-04-03 · Easy · 8 min read · Multi-tenancy, PostgreSQL, Serverless, Cloud platforms
  Noisy neighbors in a shared Postgres instance such as AWS RDS degrade performance for every tenant through CPU saturation, work\_mem and shared\_buffers pressure, disk I/O contention on EBS, exhaustion of max\_connections, and lock contention from long transactions.
- [One Postgres, a database per user, or both?](https://swe.quest/articles/one-postgres-a-database-per-user-or-both-3df8849f282fa457.md): Turso · 2026-11-25 · Easy · 10 min read · Multi-tenancy, Local-first & sync, System design, SQLite, PostgreSQL
  Choosing between one Postgres database, a Turso database per user, or both comes down to where data must live, who owns it, and how many features need to read across users.
- [How Cedalio uses Neon for an efficient development workflow](https://swe.quest/articles/how-cedalio-uses-neon-for-an-efficient-development-workflow-265835e6a16f5a00.md): Neon · 2024-05-29 · Easy · 5 min read · PostgreSQL, CI/CD, Multi-tenancy, Serverless
  Cedalio, an ESG data verification startup, moved from DynamoDB to Postgres and picked Neon over RDS for a simpler API and console.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
