S
AI/ML2026CompletedFeatured Project

Gartech Vercel Bot

<a href="https://gartech.co.in"> <img alt="Gartech AI Chatbot" src="Gartech-Logo.png" width="200" style="margin-bottom: 20px;"> </a> <h1 align="center">Gartech AI Assistant & CRM</...

RoleSole Developer
Classificationhigh
Client / ContextOpen Source Project
Development TimelineCompleted

Technical Architecture & Engineering Overview

Detailed system design and core implementation

The core architecture follows a domain‑driven modular monolith pattern. The /app directory hosts the Next.js UI and API routes, using route groups like (chat) and (auth) to isolate concerns without affecting URLs. The primary chat endpoint POST /api/v1/chat (also exposed as /api/chat for streaming) receives a user message, invokes queryQdrant to fetch relevant knowledge base vectors, augments the system prompt, and calls the Gemini model, streaming the response back to the client. Behind the scenes, the extractAndSaveLeadInfo routine parses the conversation for lead attributes (name, phone, capacity, land size) and persists them via Mongoose schemas.

Data ingestion is handled by a PDF parsing pipeline that chunks documents, stores raw text in FAQ/KnowledgeItem collections, and pushes embeddings to Qdrant. The vector store is queried in real‑time to provide RAG capabilities, ensuring answers are grounded in the uploaded knowledge base. Security is scaffolded with NextAuth.js (MongoDB adapter) for session management, JWT‑based strategies, and planned middleware for authentication, rate‑limiting (Redis‑backed), and centralized error handling.

The backend resides under /backend/src with clear layers: config for env validation, routes for API gateways, controllers for request handling, and services for business logic (AI, conversation state, WhatsApp webhook processing, CRM integration). Persistence is abstracted via lib/db/connection.ts and lib/db/queries.ts, providing typed access to Chat, Message, Lead, and knowledge collections. Telemetry and analytics hooks are earmarked for future integration, feeding metrics into an admin dashboard at /admin.

Deployment targets Docker containers on Vercel (frontend) and Google Cloud Run (backend), enabling horizontal scaling. The codebase includes TypeScript typings throughout, ensuring type safety across API contracts and database models. Continuous development is supported by utility scripts such as scripts/make-admin.js for role management.

System Diagrams & Flow Visualizations

Interactive Mermaid architecture & execution flows

Architectural Visualizer · System Architecture

Core System Features

Key capabilities & architectural features

FEATURE 01

Web chat UI with streaming AI responses

Web chat UI with streaming AI responses

FEATURE 02

WhatsApp webhook integration (backend ready, UI pending)

WhatsApp webhook integration (backend ready, UI pending)

FEATURE 03

RAG‑enabled knowledge base using Qdrant and Gemini embeddings

RAG‑enabled knowledge base using Qdrant and Gemini embeddings

FEATURE 04

Automatic lead extraction and storage in MongoDB

Automatic lead extraction and storage in MongoDB

FEATURE 05

NextAuth.js authentication with admin/guest roles

NextAuth.js authentication with admin/guest roles

FEATURE 06

Role‑based admin dashboard placeholders for leads and analytics

Role‑based admin dashboard placeholders for leads and analytics

FEATURE 07

Theme switching and slash‑command shortcuts in the chat UI

Theme switching and slash‑command shortcuts in the chat UI

FEATURE 08

CRUD interfaces for FAQs and knowledge items (backend ready)

CRUD interfaces for FAQs and knowledge items (backend ready)

FEATURE 09

Rate‑limit ready architecture using Redis (planned middleware)

Rate‑limit ready architecture using Redis (planned middleware)

FEATURE 010

Telemetry hooks for future analytics and reporting

Telemetry hooks for future analytics and reporting

Engineering Challenges & Solutions

Problem statements & resolution strategies

Challenge #1

Balancing real‑time streaming performance with the latency of vector search and LLM calls

Balancing real‑time streaming performance with the latency of vector search and LLM calls

Challenge #2

Ensuring lead extraction accuracy without false positives, requiring careful prompt design

Ensuring lead extraction accuracy without false positives, requiring careful prompt design

Challenge #3

Managing connection pools for MongoDB during hot reloads in a serverless environment

Managing connection pools for MongoDB during hot reloads in a serverless environment

Challenge #4

Designing a modular monolith that can later be split into microservices without breaking contracts

Designing a modular monolith that can later be split into microservices without breaking contracts

Challenge #5

Implementing robust security (auth, rate limiting) after the initial MVP phase

Implementing robust security (auth, rate limiting) after the initial MVP phase

Key Code Modules & Architecture

Core file entrypoints and service responsibilities

AppMODULE 01
app

Module component managing app source logic

ApiMODULE 02
app/api

Module component managing api source logic

ModelsMODULE 03
app/(chat)/api/models

Module component managing models source logic

ComponentsMODULE 04
components

Module component managing components source logic

UiMODULE 05
components/ui

Module component managing ui source logic

DocsMODULE 06
docs

Module component managing docs source logic

ScriptsMODULE 07
scripts

Module component managing scripts source logic

HooksMODULE 08
hooks

Module component managing hooks source logic

LibMODULE 09
lib

Module component managing lib source logic

TestsMODULE 010
tests

Module component managing tests source logic

PagesMODULE 011
tests/pages

Module component managing pages source logic

User Journey Pipeline

  1. 1User accesses application user interface via browser
  2. 2Payload processed through AI/ML pipeline or local inference model
  3. 3Data persisted or retrieved from database storage layer

Execution Code Flow

  1. 1Client or caller initiates request to application entrypoint
  2. 2Service layer delegates task to ML runtime or LLM API worker
  3. 3Database ORM/client executes storage query
  4. 4Application serializes JSON/audio/data response back to client

System FAQ & Technical Specifications

Frequently asked questions and core architecture details

Q: What technologies are used in Gartech Vercel Bot?

Gartech Vercel Bot is engineered using modern full-stack frameworks.

Q: What core engineering problem does Gartech Vercel Bot solve?

<a href="https://gartech.co.in"> <img alt="Gartech AI Chatbot" src="Gartech-Logo.png" width="200" style="margin-bottom: 20px;"> </a> <h1 align="center">Gartech AI Assistant & CRM</...

Q: How is 'Balancing real‑time streaming performance with the latency of vector search and LLM calls' resolved in Gartech Vercel Bot?

Resolved through specialized system architecture and resilient state handling.

Related Systems & Case Studies

Explore similar technical architectures and projects

View All Systems