Skip to content

Multi-tenant RAG: the key to secure and scalable production AI

License

Notifications You must be signed in to change notification settings

inngest/multi-tenant-rag-example

Repository files navigation

Multi-tenant RAG

Leverage Neon’s database-per-user and Inngest’s multi-tenancy to deploy fair and reliable RAG at scale.

Deploy with Vercel

Tech Stack

  • Next.js - React framework
  • Neon - Serverless Postgres database
  • Inngest - Serverless Workflow engine

Prerequisites

Before you begin, ensure you have:

Getting Started

  1. Clone the repository:
git clone <repository-url>
  1. Install dependencies:
npm install
  1. Set up environment variables: Create a .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:

    • Go to your Neon project
    • Navigate to Connection Details
    • Copy the URL
  • Neon API Key:

    • Go to your Neon Console
    • Navigate to your Profile page
    • Create a new API Key and copy it
  • OpenAI:

    • Go to OpenAI
    • Navigate to View API keys
    • Copy the API Key
  • SERP API:

    • Go to SERP API
    • Sign up and get your API key
  1. Initialize the database schema:

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.

Development

  1. Start the Next.js development server:
npm run dev
  1. In a separate terminal, start the Inngest dev server:
npx inngest-cli@latest dev
  1. Visit:

License

Apache License

About

Multi-tenant RAG: the key to secure and scalable production AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages