Skip to content

BarristerBot: A GenAI based legal chatbot designed to provide personalized legal advice and solutions according to Pakistani law.

License

Notifications You must be signed in to change notification settings

ayeshajadoon/BarristerBot

Repository files navigation

BarristerBot

BarristerBot is a Generative AI-based legal chatbot designed to provide personalized legal advice and solutions according to Pakistani law. The system leverages Retrieval-Augmented Generation (RAG) and Large Language Models (LLMs) to deliver accessible, accurate, and context-aware legal guidance.

📖 Thesis

You can read the full thesis for this project here: 📄 BarristerBot Thesis (PDF)

📂 Dataset: Pakistan Law Data (Kaggle)
📑 Source of Laws: Ministry of Law and Justice, Pakistan
🔗 Live Demo: barrister-bot.vercel.app
Please note:

  • Some features may not work currently due to expired APIs or third-party service limits.
  • For full functionality, you can run the project locally (see instructions below).

🚀 Features

-🧑‍⚖ Provides legal advice and answers based on Pakistani law

  • 📚 Uses Retrieval-Augmented Generation (RAG) for reliable information retrieval
  • 🎙️ Voice-to-text support for interactive communication
  • 🔒 PII masking to protect user privacy
  • 🔑 Secure authentication with JWT and Google Social Login
  • 💾 Conversation history management with Hasura + GraphQL
  • 🌐 Fully deployed on Vercel for seamless accessibility

Structure Architecture

System Architecture Diagram
System Architecture of BarristerBot


🛠️ Tech Stack

  • Frontend: Next.js (TypeScript)
  • Backend: Next.js server components
  • LLM: Mistral 8x7B
  • Embeddings & RAG Pipeline: LlamaIndex + Together.ai embeddings
  • Vector Database: Chroma DB
  • Data Management: Hasura + GraphQL
  • PII Masking: BERT-based model
  • Voice Integration: Google Speech-to-Text
  • Authentication: JWT-based + Google Social Login
  • Deployment: Vercel

📂 Dataset

The dataset powering BarristerBot consists of Pakistani legal documents extracted from the official Ministry of Law and Justice website.


🖼️ User Interface Preview

🏠 Home Page

Home Page
Home Page of BarristerBot


🔐 Login Page

BarristerBot Login Page
Figure 2: Secure JWT-based login with Google authentication.


🌙 Dark Mode Interface

BarristerBot Dark Mode Interface
Figure 3: Dark theme interface for better accessibility and comfort.


🗣️ Text and Speech Interaction

BarristerBot Text and Speech Interaction
Figure 4: Voice-enabled legal consultation powered by Google Speech-to-Text.


⚙️ Installation & Setup

1. Clone Repository

git clone https://github.com/yourusername/barristerbot.git
cd barristerbot

2. Install Dependencies

npm install

3. Setup Environment Variables

Create a .env.local file in the root directory and add:

NEXT_PUBLIC_HASURA_GRAPHQL_URL=your_hasura_url
NEXT_PUBLIC_CHROMADB_URL=your_chroma_db_url
NEXT_PUBLIC_TOGETHER_API_KEY=your_together_ai_api_key
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id
NEXT_PUBLIC_GOOGLE_CLIENT_SECRET=your_google_client_secret
JWT_SECRET=your_jwt_secret

4. Run Development Server

npm run dev

App will be available at: [(http://localhost:3000/)]

🧪 Future Improvements

  • Expansion of dataset with more legal resources
  • Integration with Urdu NLP models for bilingual support
  • Improved UI/UX for better accessibility
  • Advanced analytics for case tracking and recommendations

📜 License

This project is licensed under the MIT License – feel free to use, modify, and distribute.

Releases

No releases published

Packages

No packages published