Skip to content

MuhammadSamarShehzad/AlimBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AlimBot

Python FastAPI Streamlit Docker AI

An intelligent Islamic guidance system powered by AI, providing scholarly answers based on Quran, Hadith, and Fatwa sources.


🌟 Features

πŸ€– AI-Powered Responses

  • Gemini 2.5 Pro integration for intelligent Islamic guidance
  • Multi-source knowledge base combining Quran, Hadith, and Fatwa
  • Structured responses with proper citations and references
  • Context-aware answers tailored to user queries

πŸ“š Comprehensive Knowledge Base

  • Quran Index: Complete Quranic text with verse references
  • Hadith Database: Authentic Hadith collections with proper citations
  • Fatwa Repository: Extensive collection of Islamic rulings
  • Vector Search: Semantic similarity search for relevant answers

🎨 Modern Web Interface

  • Streamlit-based UI with elegant, responsive design
  • Interactive Q&A interface with example questions
  • Real-time processing with loading indicators
  • Mobile-friendly responsive design

πŸ—οΈ Robust Architecture

  • Microservices architecture with FastAPI backend
  • Docker containerization for easy deployment
  • Session management for conversation continuity
  • Error handling and graceful degradation

πŸš€ Quick Start

Prerequisites

  • Python 3.10+
  • Docker & Docker Compose
  • Google AI API key (for Gemini 2.0)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/alimbot.git
    cd alimbot
  2. Set up environment variables

    cp .env.example .env
    # Edit .env with your Google AI API key
  3. Launch with Docker

    docker-compose up --build
  4. Access the application


πŸ›οΈ Architecture

AlimBot
β”œβ”€β”€ 🎯 Frontend (Streamlit)
β”‚   β”œβ”€β”€ Modern UI with Islamic design elements
β”‚   β”œβ”€β”€ Interactive Q&A interface
β”‚   └── Real-time response display
β”‚
β”œβ”€β”€ πŸ”§ Backend (FastAPI)
β”‚   β”œβ”€β”€ RESTful API endpoints
β”‚   β”œβ”€β”€ Session management
β”‚   └── Error handling
β”‚
β”œβ”€β”€ 🧠 Core Engine
β”‚   β”œβ”€β”€ AI Agent (Gemini 2.0)
β”‚   β”œβ”€β”€ Knowledge Tools
β”‚   └── Response Formatter
β”‚
β”œβ”€β”€ πŸ“š Knowledge Base
β”‚   β”œβ”€β”€ Quran Index (FAISS)
β”‚   β”œβ”€β”€ Hadith Index (FAISS)
β”‚   └── Fatwa Index (FAISS)
β”‚
└── 🐳 Infrastructure
    β”œβ”€β”€ Docker containers
    β”œβ”€β”€ Environment management
    └── Service orchestration

πŸ”§ API Usage

Query Endpoint

POST /query
Content-Type: application/json

{
  "query": "What breaks wudu?"
}

Response Format

{
  "result": "πŸ“– **Quran References:**\n- Surah Al-Ma'idah 5:6\n\nπŸ“œ **Hadith References:**\n- Sahih Bukhari, Book of Ablution, Hadith #135\n- Sahih Muslim, Book of Purification, Hadith #225\n\nπŸ“š **Fatwa Answer:**\n- Breaking wind, urination, defecation, deep sleep, and loss of consciousness break wudu.\n\nπŸ’‘ **Conclusion:**\nWudu is invalidated by natural bodily functions and states that affect consciousness."
}

πŸ› οΈ Development

Project Structure

β”œβ”€β”€ api/                 # FastAPI backend
β”‚   β”œβ”€β”€ main.py         # FastAPI application
β”‚   β”œβ”€β”€ routes.py       # API endpoints
β”‚   └── Dockerfile      # Backend container
β”œβ”€β”€ app/                # Streamlit frontend
β”‚   β”œβ”€β”€ main.py         # Web interface
β”‚   └── Dockerfile      # Frontend container
β”œβ”€β”€ core/               # Core AI engine
β”‚   β”œβ”€β”€ agent.py        # AI agent configuration
β”‚   β”œβ”€β”€ tools.py        # Knowledge tools
β”‚   β”œβ”€β”€ services.py     # Search services
β”‚   └── config.py       # Configuration
β”œβ”€β”€ data/               # Knowledge base
β”‚   └── fatwas.csv      # Fatwa dataset
β”œβ”€β”€ indexing/           # Vector indices
β”‚   β”œβ”€β”€ quran_index/    # Quran embeddings
β”‚   β”œβ”€β”€ hadith_index/   # Hadith embeddings
β”‚   └── fatwas_index/   # Fatwa embeddings
└── docker-compose.yml  # Service orchestration

Local Development

# Install dependencies
pip install -r requirements.txt

# Run backend
cd api && uvicorn main:app --reload

# Run frontend (in another terminal)
cd app && streamlit run main.py

πŸ“Š Knowledge Base

Data Sources

  • Quran: Complete text with verse metadata
  • Hadith: Authentic collections with proper citations
  • Fatwa: Comprehensive Islamic rulings database

Search Capabilities

  • Semantic Search: Using sentence-transformers embeddings
  • Multi-modal Queries: Text-based question processing
  • Relevant Retrieval: Top-k most relevant results
  • Citation Tracking: Proper source attribution

🎨 Features in Detail

πŸ€– AI Agent Capabilities

  • Multi-tool Integration: Seamlessly combines Quran, Hadith, and Fatwa tools
  • Structured Responses: Organized answers with clear sections
  • Citation Management: Proper references to Islamic sources
  • Context Awareness: Understands complex Islamic queries

🎯 User Experience

  • Example Questions: Pre-loaded common Islamic queries
  • Real-time Processing: Live response generation
  • Error Handling: Graceful degradation on API failures
  • Mobile Responsive: Works on all device sizes

πŸ”’ Security & Privacy

  • Local Processing: No sensitive data sent to external services
  • Session Isolation: Separate conversation contexts
  • Input Validation: Sanitized user queries
  • Error Logging: Comprehensive error tracking

πŸš€ Deployment

Docker Deployment

# Production deployment
docker-compose -f docker-compose.prod.yml up -d

# Development deployment
docker-compose up --build

Environment Variables

# Required
GOOGLE_AI_API_KEY=your_gemini_api_key

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


⚠️ Important Disclaimer

This AI system is designed to provide general Islamic information and should not be considered a replacement for qualified Islamic scholars or religious authorities. Always consult with knowledgeable scholars for important religious decisions and rulings.

πŸ™ Acknowledgments

  • Open Source Community: For the amazing tools and libraries that made this project possible
  • Google AI: For providing the Gemini 2.0 model
  • Islamic Knowledge Sources: For the authentic Quran, Hadith, and Fatwa databases

🀲 May Allah guide us all with knowledge and wisdom

Built with ❀️ for the Muslim community

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors