Skip to content

Repository files navigation

AI-Powered Customer Support Chatbot (FastAPI + OpenNLP + Lucene + Kafka + React)

Final Year Project (Cloud Computing / NLP): a production-style customer support chatbot that combines:

  • Natural Language Understanding (intent + entities)
  • Knowledge Base Search (Lucene fuzzy retrieval for FAQs)
  • Conversation Memory (Redis session state)
  • Real-time Logging & Analytics (Kafka → consumer → metrics)
  • Modern UI (React + Vite build served via Nginx)

Project Overview

This chatbot answers common support questions, supports multi-turn order tracking, and provides basic product recommendations. It uses a hybrid approach:

  • Deterministic rules for critical flows (order tracking, escalation safety)
  • Model-based intent classification + entity extraction (OpenNLP + local fallback)
  • Lucene search when confidence/scores are strong enough (to avoid “wrong answers”)

Architecture (Simple Explanation)

FastAPI (Backend / Brain)
Receives messages from the frontend, manages session state in Redis, calls the Java NLP/Lucene service, applies decision logic, and returns a structured response.

Java Microservice (Apache OpenNLP + Apache Lucene)
Exposes a REST API that runs intent classification + entity extraction and performs Lucene fuzzy search over the FAQ knowledge base.

Kafka (Logging Pipeline)
Backend publishes each interaction (user message, response, intent, sentiment, language). A consumer stores logs to disk for analytics.

React (Frontend / UI)
Chat interface that calls the backend API and displays response + metadata.


Features

  • Intent Recognition with confidence thresholds (avoids irrelevant answers)
  • Entity Extraction (order IDs, names, locations/products where available)
  • Order Tracking Flow
    • “Where is my order?” → asks for order ID
    • “12345 / ORD-12345 / #12345” → returns tracking status
  • Product Recommendations (deterministic logic + backend function)
  • Sentiment Handling with safe escalation rule (sentiment < -0.6)
  • Multi-language Support (message translation in/out when enabled)
  • Analytics
    • /analytics endpoint for summary stats
    • Kafka audit stream (topic: chat_logs)

Repository Structure (University Requirement)

cc-project-group10/
├── docker-compose.yml
├── .env.example
├── src/
│   ├── backend/      # FastAPI + Kafka producer/consumer + tests
│   ├── frontend/     # React UI (Vite build served by Nginx)
│   └── ai-chatbot/   # Java microservice (OpenNLP + Lucene)
├── config/
├── docs/
├── scripts/
├── results/
└── .github/workflows/

Quick Start (Docker Compose)

Prerequisites

  • Docker Desktop (with Compose)

Run

git clone <YOUR_REPO_URL>
cd cc-project-group10
docker compose up --build

URLs


Docker Services (Ports)

  • frontend3000:3000
  • backend8000:8000
  • lucene (Java NLP/Lucene) → 4567:4567
  • kafka9092:9092
  • zookeeper2181:2181
  • redis6379:6379

API Endpoints

Backend (FastAPI)

  • POST /chat
    Request:

    { "message": "where is my order", "user_id": "u1", "lang": "en" }

    Response includes:

    • response (final message)
    • intent, confidence (0–100), sentiment
    • entities (extracted data)
    • session_context (memory state)
  • GET /health
    Shows API status + Redis mode + Java service connectivity.

  • GET /analytics
    Returns aggregated analytics (safe to call; should never crash).

  • GET /metrics
    Simplified metrics payload for monitoring/report marks.

Java NLP/Lucene Service

  • POST /search
    Request:

    { "query": "refund policy", "topK": 3 }

    Response includes intent, confidence, entities, and Lucene hits.

  • GET /health


Testing

From repo root:

docker compose up -d --build
docker compose exec backend pytest -q

Artifacts & Deliverables



Contributors

  • M wajahat

License

See LICENSE.

About

Enterprise AI customer support chatbot powered by FastAPI, Java OpenNLP, Lucene FAQ search, Redis memory, Kafka analytics, and React UI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages