Multitenant private AI Chat with Azure and Neon

When you are building chat applications for internal teams or customer support, you need to isolate data to meet data residency and compliance requirements. Also, you want to chat with internal documents or APIs securely and safely. You can’t rely on public AI services like ChatGPT.

The solution you are going to explore offers a ready-to-use template where each user has their own private and secure AI-powered chat application, complete with custom personas and prompts, API extensions, document uploads, and voice interactions. Tenant AI Chat Solution Accelerator uses Neon Serverless Postgres on Azure to allow organizations to deploy a private chat tenant in their Azure Subscription with a dedicated database per user on Neon. In this article, we will break down the main features, technologies used, and benefits of using this solution.

To try it,

Post image

What Is This Accelerator?

This accelerator is a ready-made framework that helps organizations deploy their own tenant-specific AI chat applications. Each user gets their own isolated database in Neon for privacy and security purposes.


Key Features

Database Per User

Each user has their own separate database for storing chat history, and vector representation of data.

Flexible Authentication

Log in using providers like Google, GitHub, or Azure Entra ID, or simply use basic authentication using login and password during development. You can also manage chat from the admin user.

AI-Powered Conversations

Chat with uploaded documents (like PDFs) or build your own conversation templates for tailored interactions.

Customizable Personas

Set unique chat personas for different use cases like language translator or accounting assistant. Manage persona settings directly from the application interface.

Extensions Support

Add extra features by defining custom extensions that connect to your workflows or APIs.

Voice Integration

Enable multilingual chat with speech-to-text and text-to-speech features using Azure Speech Service.

Enterprise-Ready Deployment

Deploy easily enterprise-ready infrastructure on Azure with the deployment automation scripts from Azure CLI or Azure Portal.

Post image

Technologies Behind the Magic

Here’s the tech stack that powers the solution:

Azure Services

ServiceUsage in the Project
Azure OpenAIProvides models like GPT-4o for generating AI-powered conversational responses and vector embeddings for semantic search.
Azure Key VaultSecurely stores sensitive information such as API keys, secrets, and connection strings. Used for authentication and APIs.
Azure Blob StorageHandles file storage and uploads for documents or media used in the chat system. Scalable solution for data backups.
Azure App ServiceHosts the web application, REST APIs, and back-end services. Provides a managed environment to deploy and run the solution.
Azure MonitorTracks and monitors application performance, errors, and logs. Helps in diagnosing issues and optimizing performance.
Microsoft Entra ID (Azure AD)Provides secure user authentication and authorization through OAuth2.0. Integrates with organizational identity systems.
Azure Document IntelligenceAutomates data extraction from uploaded documents using AI and OCR (Optical Character Recognition).
Azure Speech ServiceConverts speech to text and vice versa, enabling voice commands or responses in the chat system. Supports multilingual use.

Development Tools

  • Node.js 18: an open-source, cross-platform JavaScript runtime environment.
  • Next.js 13: enables you to create full-stack web applications by extending the latest React features.
  • NextAuth.js: configurable authentication framework for Next.js 13.
  • Tailwind CSS: is a utility-first CSS framework that provides a series of predefined classes that can be used to style each element by mixing and matching.

Solution Architecture

The following high-level diagram depicts the architecture of the solution accelerator:

Multitenant private AI Chat with Neon on Azure Solution Architecture Diagram

How to Get Started Locally

  1. Clone the repository.
  2. Rename .env.example to .env.local and fill in the required variables.
  3. Retrieve your Neon API key and add it to .env.local.
  4. Install dependencies (npm install).
  5. Run the app (npm run dev) and access it at http://localhost:3000.

Each new user automatically gets a separate database on Neon!

Deployment Options

You can deploy the application directly to Azure using:

  1. Azure Developer CLI: Set up and deploy the solution from your local environment.
  2. Azure Portal: Quickly provision resources and follow up with GitHub actions for deployment.

Cost Management

Here’s how you can optimize costs:

  • Use free Neon plans (10 projects, 0.5 GB storage, and more).
  • Switch Azure App Service and Form Recognizer to free tiers for light usage.
  • Reduce document uploads to minimize costs for AI-powered processing.

Start your AI-powered chat journey today and experience the future of intelligent conversations!