Skip to content

Repository files navigation

🤖 AI Customer Support Platform (NovaCart)

An end-to-end, full-stack Agentic AI Customer Support Platform built with FastAPI, React (TypeScript + Vite + Tailwind CSS), PostgreSQL, and Hybrid RAG.

Instead of static chatbot prompts, the system uses an autonomous Plan-Act-Observe agent loop that reasons about customer requests, calls business tools (order lookup, ticket management, policy retrieval, email generation), and streams real-time responses over Server-Sent Events (SSE).


🚀 Key Features

  • Autonomous Agentic Loop: Multi-step reasoning engine (Planner, Tool Executor, Observer) to resolve compound support requests.
  • Hybrid RAG Pipeline: Combines dense vector search (FAISS) and sparse lexical search (BM25) with cross-encoder reranking.
  • Real-Time Streaming (SSE): Streams markdown responses chunk-by-chunk via Server-Sent Events with client-side rendering and automatic database persistence.
  • Dual LLM Provider Support: Unified interface supporting Google Gemini (gemini-2.5-flash) and Groq (openai/gpt-oss-120b / open models).
  • Orders & Support Tickets: Order lookup and tracking information, ticket lifecycle management (open/close/reopen), threaded messages, and AI-assisted replies.
  • JWT Auth & Data Isolation: Stateless JWT authentication with strict user-level data isolation across conversations, orders, and tickets.
  • Evaluation Suite: Automated Information Retrieval metrics (Hit Rate, Precision@K, MRR) and LLM-as-a-judge agent evaluation.

🏗 System Architecture

 User (Browser) ──► React SPA (Vite + Tailwind) ──► FastAPI (JWT Auth / Tracing)
                                                            │
                     ┌──────────────────────────────────────┼──────────────────────────────────────┐
                     ▼                                      ▼                                      ▼
             PostgreSQL (DB)                        AI Agent Loop (Orchestrator)            Hybrid RAG Engine
        (Users, Orders, Tickets,                 (Planner ──► Tools ──► Observer)        (FAISS + BM25 + Reranker)
         Conversations, Messages)                           │                                      │
                                                            └──────────────────┬───────────────────┘
                                                                               ▼
                                                                  LLM Provider (Gemini / Groq)
                                                                               │
                                                                 SSE Token Stream ──► React UI

🛠 Technology Stack

Category Technologies
Frontend React 19, TypeScript, Vite, Tailwind CSS v4, React Markdown
Backend Python 3.12, FastAPI, Uvicorn, SQLAlchemy 2.0, Alembic, Pydantic v2
Database PostgreSQL 17
AI / LLM Google Gemini (gemini-2.5-flash), Groq (gpt-oss-120b / open models)
RAG & Search FAISS, Rank-BM25, Sentence Transformers (all-MiniLM-L6-v2), Cross-Encoder (ms-marco-MiniLM-L-6-v2)
Security JWT (python-jose), Passlib / Bcrypt
DevOps & Eval Docker, Docker Compose, Automated IR Metrics (Hit Rate, Precision, MRR)

⚙️ Core Architecture & Workflows

1. How the AI Support Workflow Works

  1. User Request: User sends a message via the React chat workspace (POST /ask/stream).
  2. Planning: The AI Planner analyzes the user query, conversation history, and context to select the appropriate tool.
  3. Execution & Context Update: The tool executes (retrieving order details, ticket info, or knowledge chunks) and updates the shared agent context.
  4. Observation: The Observer determines whether all parts of the user request are answered (FINISH or CONTINUE).
  5. Streaming Synthesis: The Response Generator synthesizes the accumulated context into structured Markdown and streams tokens via SSE.

2. Hybrid RAG & Vector Search

  • Knowledge Base: Domain policy documents covering shipping, refunds, warranties, payments, and security (knowledge_base/NovaCart).
  • Retrieval Pipeline: Multi-query expansion ➔ Parallel FAISS (dense semantic search) & BM25 (sparse keyword search) ➔ Cross-encoder reranking ➔ Context compression.

3. Agent Tools

  • knowledge_search: Retrieves store policies, procedures, and FAQs via the Hybrid RAG engine.
  • order_lookup: Retrieves shipment status, tracking codes, and delivery estimates scoped to the authenticated user.
  • ticket_lookup: Retrieves support ticket status, assigned agents, and priority levels.
  • send_email: Compiles order, ticket, or policy context into a structured customer support email.

4. Orders, Tickets & Authentication

  • Orders: Dedicated user order workspace with demo order seeding and status tracking.
  • Tickets: Ticket lifecycle operations (open/close/reopen), message threads, and AI features (/suggest-reply, /summarize, /classify, /analyze).
  • Authentication: JWT access tokens with user-isolated queries across all database entities.

📂 Project Structure

ai-support-platform/
├── alembic/              # Database schema migrations
├── app/                  # FastAPI backend application
│   ├── agent/            # Agent loop (planner, observer, executor, tools, prompts)
│   ├── api/              # REST & SSE endpoints (auth, orders, tickets, rag, health)
│   ├── auth/             # JWT authentication, security, and dependencies
│   ├── core/             # Configuration, error handlers, and middleware
│   ├── database/         # Database engine and session management
│   ├── llm/              # Gemini & Groq multi-provider interface
│   ├── models/ & schemas/# SQLAlchemy models and Pydantic schemas
│   └── services/         # Domain services (RAG, orders, tickets, memory, AI)
├── evaluation/           # RAG metrics (Hit Rate, Precision, MRR) & LLM evaluation
├── frontend/             # React 19 + TypeScript + Vite SPA
├── knowledge_base/       # NovaCart enterprise policy documents
├── docker-compose.yml    # Multi-container orchestration (PostgreSQL + Backend)
└── requirements.txt      # Python dependencies

🚀 Getting Started

1. Prerequisites & Environment Setup

  • Python 3.11+, Node.js 18+, PostgreSQL (or Docker)
# Clone repository
git clone https://github.com/PR12-tech/ai-support-platform.git
cd ai-support-platform

# Backend setup
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

Create a .env file in the root directory:

DATABASE_URL=postgresql://postgres:password@localhost:5432/ai_support_db
SECRET_KEY=your_jwt_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
FRONTEND_URL=http://localhost:5173
LLM_PROVIDER=gemini       # or "groq"
GEMINI_API_KEY=your_gemini_api_key
GROQ_API_KEY=your_groq_api_key

2. Database Migrations & Frontend Setup

# Apply database migrations
alembic upgrade head

# Frontend setup
cd frontend
npm install
cd ..

🏃 Running the Application

Start Backend (from root with .venv active):

uvicorn app.main:app --reload --port 8000

API documentation available at http://localhost:8000/docs.

Start Frontend (from frontend/ directory):

cd frontend
npm run dev

Application available at http://localhost:5173.

Run Retrieval Evaluation:

python -m evaluation.test_evaluation

🐳 Docker Support

To run the backend and PostgreSQL database in containers:

docker compose up --build
docker compose exec backend alembic upgrade head

(The React frontend runs locally via npm run dev against http://localhost:8000)


📌 Status, Limitations & Future Work

  • Status: Feature-complete working implementation.
  • Current Limitations: In-memory local FAISS index (non-distributed); simulated email delivery service; demo order line-items enriched via metadata service.
  • Future Improvements: Cloud vector database integration (Qdrant/pgvector), transactional email provider integration (SES/Resend), and CI/CD deployment pipelines.

👨‍💻 Author

Prasad Kadam — Built as an exploration of modern GenAI Engineering, combining Agentic AI, Hybrid RAG, structured SQL workflows, and real-time streaming interfaces.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages