Multi-tenant RAG: the key to secure and scalable production AI
Leverage Neon’s database-per-user and Inngest’s multi-tenancy to deploy fair and reliable RAG at scale.
Before you begin, ensure you have:
git clone <repository-url>
npm install
.env.local file in the root directory:# Neon Database
DATABASE_URL=
NEON_API_KEY=
# OpenAI
OPENAI_API_KEY=
# SERP API
SERP_API_KEY=
Here is how you can get the above values:
Neon Database URL:
Neon API Key:
OpenAI:
SERP API:
Go over your Neon Console and navigate to the SQL Editor.
Copy the contents of db/schema.sql and paste it into the SQL Editor.
Running the query will create the schema.
Then start the Next.js development server (npm run dev) and navigate to http://localhost:3000/api/setup.
This will create the initial workspaces.
npm run dev
npx inngest-cli@latest dev