Bayyan AI is an intelligent Quranic search and assistant platform built with modern AI technologies. It leverages Retrieval-Augmented Generation (RAG) to provide accurate, context-aware answers to questions about the Quran, ensuring every response is backed by authentic verses with citations .
- Semantic Search: Find verses based on meaning, not just keywords.
- RAG-Powered Answers: Get direct answers synthesized from Quranic context using LLMs.
- Strict Citations: Every claim includes Surah name, number, and Ayah reference.
- Multilingual Support: Displays both Arabic text and English translations.
- Session Memory: Remembers conversation history using Redis.
|
Python |
FastAPI |
ChromaDB |
MongoDB |
Redis |
- Core Framework: FastAPI (Backend API)
- Vector Database: ChromaDB (Vector Search)
- Primary Database: MongoDB (Source Quranic Data)
- LLM Orchestration: LangChain + Groq (Llama 3.1)
- Embeddings: Sentence-Transformers (
all-MiniLM-L6-v2)
bayyan-AI/
├── bot/ # Telegram Bot (Node.js)
│ ├── commands/ # Modular command handlers (start, help, query)
│ ├── utils/ # Utility functions (logger, etc.)
│ ├── index.js # Bot entry point
│ └── package.json # Node.js dependencies
├── src/
│ ├── main.py # FastAPI entry point & API routes
│ ├── orchestrator.py # RAG logic & LLM chain configuration
│ ├── preprocess.py # Data ingestion from MongoDB to ChromaDB
│ └── search.py # Vector search implementation
├── quran_vectordb/ # Local vector database storage
├── requirements.txt # Python dependencies
└── .env # Environment variables configuration
- Python 3.9+
- MongoDB instance
- Redis instance (optional for session history)
- Groq API Key
git clone https://github.com/rafshandev/bayyan-ai.git
cd bayyan-ai
pip install -r requirements.txtCreate a .env file in the root directory:
# Backend Config
MONGO_URI=your_mongodb_uri
GROQ_API_KEY=your_groq_api_key
REDIS_URL=your_redis_url
# Telegram Bot Config
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
BAYYAN_API_URL=http://localhost:8000In a new terminal:
cd bot
npm install
node index.jsVectorize the Quranic data from MongoDB:
python src/preprocess.pyuvicorn src.main:app --reloadThe API will be available at http://localhost:8000.
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Welcome message |
GET |
/search?q={query} |
Get AI-generated answer and relevant verses |
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.