CodePrism Technologies logoCodePrism Technologies
Case Study — AI Backend & Architecture

Building PrismBot: A Multi-Tenant, Multi-Agent Chat Architecture

A multi-tenant AI chatbot backend built with NestJS and TypeScript that utilizes LangGraph for a supervisor-specialist agent routing system, delivering real-time responses and autonomous CRM updates via WebSockets.

PlatformSaaS Backend
DurationOngoing Development
TypeAI Backend & Architecture
Stack7 technologies
PROJECT OVERVIEW

3-Stage

RAG pipeline with parallel query expansion

100%

Tenant isolation across vectors, KB, and CRM

2

Specialist agents (RAG Expert & CRM Sales)

THE CHALLENGE

WhatsApp messaging gets complicated at scale.

Single-agent LLM systems struggle with context bloat and lack the ability to simultaneously query complex knowledge bases while also updating customer relationship databases autonomously. Additionally, serving multiple enterprise tenants requires strict data isolation to prevent data leakage.

Challenge 1

Static AI pipelines cannot easily update CRM records based on conversation context.

Challenge 2

Monolithic LLMs are vulnerable to jailbreaks and script injections.

Challenge 3

Data leakage risks in shared vector databases and chat histories.

Challenge 4

Tightly coupled WebSocket logic makes it hard to scale AI agent tools.

WHAT WE LEARNED
01

Parallel query expansion significantly improves the recall of relevant vector chunks.

02

Abstracting WebSockets via closures allows LLM agents to safely trigger UI updates without knowing the transport layer.

03

Running a mandatory CRM agent post-query ensures user profiles stay updated dynamically.

04

Pre-pipeline guardrails are essential to prevent costly and dangerous prompt injections.

Technologies Background
Our Technologies

Built with technologies we trust.

NestJS
TypeScript
LangGraph
Socket.IO
MongoDB
PostgreSQL + PGVector
OpenAI

Project Goals

Build a strict multi-tenant architecture scoping requests to specific tenants from the first step.
Implement a Supervisor LLM that never answers questions, but strictly routes to specialist agents.
Create a comprehensive RAG pipeline with query expansion and MMR reranking.
Automate CRM profile updates using conversational context without manual intervention.
Decouple Socket.io infrastructure from agent logic to allow safe admin interventions.

The Outcome

The PrismBot architecture proves that moving away from monolithic LLM prompts toward a multi-agent, supervisor-driven model drastically improves reliability and feature depth. By strictly isolating tenant context and decoupling the WebSocket layer from the LLM execution, we created a highly scalable platform.

Conclusion & Impact

"The PrismBot architecture proves that moving away from monolithic LLM prompts toward a multi-agent, supervisor-driven model drastically improves reliability and feature depth. By strictly isolating tenant context and decoupling the WebSocket layer from the LLM execution, we created a highly scalable platform."

Have a project in mind?

Let's discuss how we can help you build your next big thing.
Reach out and our team will be in touch.

Protected by reCAPTCHA. Google Privacy & Terms apply.

Building systems that hold up in production.

Bring up the problem others won't attempt.