Usman Liaqat.
Back to all work

OrhanAI

A multi tenant AI agent SaaS that trains a business assistant on a website and its documents, then answers visitors in an embeddable widget and on WhatsApp, Messenger, Instagram, and Gmail with lead capture and human handoff.

Next.js 16Google GeminiQdrantMongoDBRedisStripe

Last updated

OrhanAI website screenshot

The Challenge

Letting a small business launch an assistant that answers only from its own approved content, on its website and on the messaging apps its customers already use. The platform had to crawl and index sites and files of every kind, keep each workspace's knowledge strictly separate, resist prompt injection and data extraction, meter every AI reply against a paid plan, and pass the conversation to a human the moment the AI could not help, all while the embedded widget stayed light enough not to slow the host page.

The Approach

Built a Next.js 16 App Router platform with Cache Components, Server Actions, and a native MongoDB data access layer. A website URL starts the flow: a crawler indexes the site, Gemini analyses the business and asks setup questions, and a training pipeline extracts, chunks, and embeds websites, PDFs, Word files, spreadsheets, images, audio, and video with multimodal Gemini embeddings. Chunks are searched in Qdrant with MongoDB Atlas Vector Search as a fallback, and the RAG layer ranks matches, bounds conversation history, and guards against prompt leakage before Gemini answers. A Shadow DOM widget of about 32 KB embeds on any site, while one channel router sends WhatsApp, Messenger, Instagram, and Gmail messages through the same agent. Redis carries rate limits and realtime events, an in container worker runs seventeen scheduled jobs, and Stripe handles plans, credit packs, and dunning. Docker images are built and smoke tested in GitHub Actions, then deployed through Dokploy.

Key Features

  • Website first agent setup that crawls a URL, analyses the business, and trains the agent from approved sources
  • Training from websites, sitemaps, PDF, Word, CSV, Q&A pairs, images, audio, and video with multimodal embeddings
  • Lightweight Shadow DOM chat widget with file attachments, voice input, lead forms, and a JavaScript API
  • Omnichannel inbox for WhatsApp, Messenger, Instagram, and Gmail with live updates and human handoff
  • Flow builder with AI answers, questions, choices, lead forms, appointment booking, and handoff blocks
  • Lead pipeline with conversational capture, AI lead scoring, assignment rules, and SLA tracking
  • Stripe subscriptions with AI reply credits, credit packs, coupons, and automated dunning
  • Enterprise controls including SAML SSO, two factor auth, custom roles, audit logs, white label, and a public REST API with signed webhooks

Results

Shipped a live platform where a business goes from a website URL to a trained, published agent answering on its site and messaging channels, backed by 671 unit tests and a 173 test end to end suite. Tuning Gemini's thinking level cut time to first word from about 2.2 to 1.3 seconds and output tokens per reply by roughly two thirds, and a security assessment repelled 27 of 28 simulated attacks, with every finding fixed.

Tech Stack

Next.js 16
React 19
TypeScript 6
Tailwind CSS v4
MongoDB
Qdrant Vector DB
Redis
Google Gemini
Stripe
Brevo API
Firebase Cloud Messaging
RustFS S3
Sentry
Playwright
Docker

Related reading