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</...
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
Core System Features
Key capabilities & architectural features
Web chat UI with streaming AI responses
Web chat UI with streaming AI responses
WhatsApp webhook integration (backend ready, UI pending)
WhatsApp webhook integration (backend ready, UI pending)
RAG‑enabled knowledge base using Qdrant and Gemini embeddings
RAG‑enabled knowledge base using Qdrant and Gemini embeddings
Automatic lead extraction and storage in MongoDB
Automatic lead extraction and storage in MongoDB
NextAuth.js authentication with admin/guest roles
NextAuth.js authentication with admin/guest roles
Role‑based admin dashboard placeholders for leads and analytics
Role‑based admin dashboard placeholders for leads and analytics
Theme switching and slash‑command shortcuts in the chat UI
Theme switching and slash‑command shortcuts in the chat UI
CRUD interfaces for FAQs and knowledge items (backend ready)
CRUD interfaces for FAQs and knowledge items (backend ready)
Rate‑limit ready architecture using Redis (planned middleware)
Rate‑limit ready architecture using Redis (planned middleware)
Telemetry hooks for future analytics and reporting
Telemetry hooks for future analytics and reporting
Engineering Challenges & Solutions
Problem statements & resolution strategies
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
Ensuring lead extraction accuracy without false positives, requiring careful prompt design
Ensuring lead extraction accuracy without false positives, requiring careful prompt design
Managing connection pools for MongoDB during hot reloads in a serverless environment
Managing connection pools for MongoDB during hot reloads in a serverless environment
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
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 component managing app source logic
app/apiModule component managing api source logic
app/(chat)/api/modelsModule component managing models source logic
componentsModule component managing components source logic
components/uiModule component managing ui source logic
docsModule component managing docs source logic
scriptsModule component managing scripts source logic
hooksModule component managing hooks source logic
libModule component managing lib source logic
testsModule component managing tests source logic
tests/pagesModule component managing pages source logic
User Journey Pipeline
- 1User accesses application user interface via browser
- 2Payload processed through AI/ML pipeline or local inference model
- 3Data persisted or retrieved from database storage layer
Execution Code Flow
- 1Client or caller initiates request to application entrypoint
- 2Service layer delegates task to ML runtime or LLM API worker
- 3Database ORM/client executes storage query
- 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