blog image

Lexora : Context-Aware Chatbot with Knowledge Base Integration

Lexora AI is a smart chatbot I built for my academic project. It’s designed to answer user questions by using documents uploaded to a knowledge base, all powered by the Dify API. I focused on building a clean frontend, connecting to the API, and managing users with authentication and roles.

What It Does

  • Users can chat with the bot and get answers from a document-based knowledge base.
  • The answers are generated using the Dify platform.
  • Only admins can manage the knowledge base.
  • There's role-based access in the app: guest, user, and admin.
  • It has a simple, responsive UI built with ShadCN UI.

How I Built It

  • I used Next.js (App Router) to build the full app.
  • ShadCN was used to style the chat interface and pages.
  • I used NextAuth for authentication, and added role-based logic to restrict admin access.
  • The chat component sends messages to a custom API route, which then calls the Dify API and returns the response.
  • The app is structured to keep the API key safe and manage all logic in the BFF (Backend For Frontend).

Roles

  • Guest: Can try out the chat.
  • User: Logged-in users with full chat access.
  • Admin: Gets access to settings or internal pages.

Features

  • Simple chatbot with document-based answers.
  • Clean UI using ShadCN components.
  • Auth system with role management.
  • Real-time chat with loading states.
  • Fully client-side experience with API integration.