N
Neon7mo ago
graceful-blue

Using drizzle to make project-per-tenant?

B2B SaaS: How can I automate onboarding for new organizations using drizzle in a shared application, one db-per-tenant? For example creating organization at sign-up, and getting a database right away? The application could probably make do by using shared database, shared schema. But I am planning to implement AI features later, where the AI only has access to each tenants data, so planning to use db-per-tenant for data isolation, and hoping management can be automated by using Neon’s API. (Nextjs application with Clerk auth)
3 Replies
adverse-sapphire
adverse-sapphire7mo ago
We generally recommend a project per tenant to keep resources separate. Please see this page for an intro: https://neon.tech/use-cases/database-per-tenant The Neon API supports most Neon platform operations like creating projects, databases, roles, etc. https://api-docs.neon.tech/reference/getting-started-with-neon-api There are different SDKs for the Neon API: https://api-docs.neon.tech/reference/sdks-for-the-neon-api
Neon
Database Per User at Scale
Manage thousands of Postgres databases with minimal effort and costs.
Neon
Get started with the Neon API
This page will help you get started with the Neon API
Neon
SDKs and providers for the Neon API
There are several SDKs and a Terraform provider available for use with Neon. All are wrappers around the Neon API, providing methods to programmatically manage API keys, Neon projects, branches, databases, endpoints, roles, and operations. TypeScript SDK Python SDK Go SDK ( community ) Node.js and D...
graceful-blue
graceful-blueOP7mo ago
Thank you for answering! I found this example code, and looking into this approach: https://github.com/neondatabase/db-per-tenant I did not find a blog article related to it, but trying to learn from the code. Is this solution a good practice? Each tenant will get provisioned more than 1 table each, but I guess it works the same? I haven't found much info regarding the npm package @neondatabase/api-client for interacting with the API, do you have any good tips there? Also, for provisioning multiple Projects/databases (one for each tenant), do I need an Organization account in Neon?
GitHub
GitHub - neondatabase/db-per-tenant: Example chat-with-pdf app show...
Example chat-with-pdf app showing how to provision a dedicated database instance for each user. In this app, every database uses pgvector for similarity search. Powered by Neon - neondatabase/db-pe...
adverse-sapphire
adverse-sapphire7mo ago
https://www.npmjs.com/package/@neondatabase/api-client is a wrapper around our Neon API: https://api-docs.neon.tech/reference/getting-started-with-neon-api You don't don't need an Org account to create multiple projects. Our Free Plan supports up to 10 projects, Launch up to 100, and so on. You can learn more about Orgs here: https://neon.tech/docs/manage/organizations If you're working on a team, it may be of interest to you for managing different projects. @Mahmoud might be able to comment on this particular application example.
npm
@neondatabase/api-client
Wrapper for Neon API. Latest version: 1.12.0, last published: 21 days ago. Start using @neondatabase/api-client in your project by running npm i @neondatabase/api-client. There are 6 other projects in the npm registry using @neondatabase/api-client.
Neon
Get started with the Neon API
This page will help you get started with the Neon API
Neon
Organizations - Neon Docs
Build your team in Neon with Organizations. Manage all of your team's projects under a single account — with billing, role management, and project collaboration capabilities in one accessible location...

Did you find this page helpful?