io.github.BalajSaleem/criterion

编码与调试

by balajsaleem

支持在 6,236 节 Quran 经文和 12,416 条 authentic Hadiths 中进行语义搜索,辅助伊斯兰指引。

什么是 io.github.BalajSaleem/criterion

支持在 6,236 节 Quran 经文和 12,416 条 authentic Hadiths 中进行语义搜索,辅助伊斯兰指引。

README

<h1 align="center">Criterion - Islamic Knowledge Assistant</h1> <p align="center"> <strong>An AI-powered Da'i (invitor to Islam)</strong> bringing authentic Islamic guidance to seekers worldwide. </p> <p align="center"> Built on the Quran and authentic Hadith. Free forever. For the sake of Allah. </p> <p align="center"> <a href="#mission"><strong>Mission</strong></a> · <a href="#features"><strong>Features</strong></a> · <a href="#tech-stack"><strong>Tech Stack</strong></a> · <a href="#getting-started"><strong>Getting Started</strong></a> · <a href="#mcp-server"><strong>MCP Server</strong></a> · <a href="#documentation"><strong>Documentation</strong></a> </p> <br/>

Mission

Criterion exists to bring authentic Islamic knowledge to anyone seeking truth, using modern technology to make divine guidance accessible to all of humanity — freely, forever, for the sake of Allah alone.

Our Four Pillars

  1. Truth & Authenticity — Every response is grounded in verified sources (Quran and Sahih Hadith). We never fabricate or hallucinate.
  2. Fundamentals & Simplicity — We focus on core Islamic teachings that unite. We avoid sectarian debates and controversial topics.
  3. For the Sake of Allah — Criterion will always be free, with no monetization or organizational promotion. This is Sadaqah Jariyah.
  4. State of the Art — We use cutting-edge AI to deliver Islamic guidance effectively to the masses.

👉 Read the full mission and vision in MISSION.md

Key Differentiators

Mission-Aligned:

  • Free Forever — No paywalls, no ads, no monetization. Built fi sabilillah (for Allah's sake)
  • 📚 Fundamentals-Focused — Avoids sectarian debates, focuses on universally accepted Islamic teachings
  • 🛡️ Trust-First — Grade-filtered authentic Hadith (defaults to Sahih), verified sources only
  • 🤝 Seeker-Oriented — Designed for curious minds, new Muslims, and students of knowledge
  • 🕌 Da'i Personality — Compassionate, knowledgeable, humble guidance

Technical Excellence:

  • 🎯 Semantic Search — Natural language queries return relevant verses from 6,236 Quran verses + 21,641 Hadith narrations
  • 📖 Contextual Retrieval — Top results include ±2 surrounding verses/narrations for proper context
  • 🌐 Multilingual — Read in English (fast) + Slovak (expandable to 10+ languages)
  • 🔗 Accurate Citations — All responses include source references with hyperlinks (Quran.com, Sunnah.com)
  • Fast — <150ms query response time

Features

What Criterion Does

Semantic Quran Search — Ask natural language questions, get relevant verses
Semantic Hadith Search — Search authentic Hadith with grade & collection filtering
Contextual Understanding — Top results include surrounding context for proper meaning
Accurate Citations — Every response cites real sources with hyperlinks
Multilingual Reading — English (fast) + Slovak (single JOIN <200ms)
Shareable URLs/quran/search?q=patience, /hadith/search?q=charity, and /quran/2/255 with metadata
Real-time Streaming — Progressive response generation with token-by-token delivery
Tool-Based RAG — LLM autonomously decides when to retrieve from Quran/Hadith

Technical Stack

How It Works

The RAG Pipeline

code
User Question
    ↓
XAI Grok 4 LLM (decides which tools to use)
    ↓
Tool Selection:
  - queryQuran → 6,236 verses (top 7 for chat, top 20 for search)
  - queryHadith → 21,641 hadiths from 6 collections (top 3 for chat, top 15 for search, with grade filtering)
    ↓
Vector Search (768-dim Gemini embeddings)
    ↓
Context Enhancement (top 3 get ±2 surrounding verses)
    ↓
LLM Generates Response with Citations
    ↓
Real-time Stream to User (Server-Sent Events)

Data

  • 6,236 Quran verses from all 114 Surahs

    • Arabic text (Tanzil Quran)
    • English translation (master)
    • Slovak translation (expandable)
    • 768-dimensional embeddings (Gemini text-embedding-004)
  • 21,641 Hadith narrations from 6 major collections (Kutub al-Sittah subset)

    • Sahih Bukhari (7,558)
    • Sahih Muslim (2,920)
    • Jami` at-Tirmidhi (3,951)
    • Sunan Abi Dawud (5,274)
    • 40 Hadith Nawawi (42)
    • Riyad as-Salihin (1,896)
    • Grade filtering (Sahih, Hasan, Da'if)
    • 768-dimensional embeddings

Performance

  • Quran search: <150ms (English), <200ms (translated)
  • Hadith search: <150ms
  • Vector search: Powered by HNSW indexes
  • Streaming: Real-time token-by-token delivery

Getting Started

Prerequisites

  • Node.js 18+ and pnpm
  • PostgreSQL database (recommend Neon)
  • API Keys:
    • XAI API Key (for Grok LLM)
    • Google AI Studio API Key (for embeddings)

Installation

  1. Clone the repository
bash
git clone <repo-url>
cd criterion
  1. Install dependencies
bash
pnpm install
  1. Set up environment variables

Create a .env.local file:

bash
# Database
POSTGRES_URL=postgresql://...

# AI APIs
XAI_API_KEY=xai-...
GOOGLE_GENERATIVE_AI_API_KEY=...

# Authentication (optional)
AUTH_SECRET=...
  1. Enable pgvector extension
bash
pnpm db:enable-pgvector
  1. Run database migrations
bash
pnpm db:migrate
  1. Ingest Quran data (generates embeddings for 6,236 verses)
bash
pnpm ingest:quran

This will take 10-15 minutes to complete.

  1. Test the Quran search
bash
pnpm test:quran
  1. Start the development server
bash
pnpm dev

Your app should now be running on localhost:3000.

Available Commands

Development

bash
pnpm dev          # Start dev server
pnpm build        # Build for production
pnpm start        # Start production server

Database

bash
pnpm db:generate  # Generate Drizzle schema
pnpm db:migrate   # Run migrations
pnpm db:studio    # Open Drizzle Studio (GUI)

Data Ingestion & Testing

bash
# Quran
pnpm clear:quran         # Clear all Quran data
pnpm ingest:quran        # Ingest Quran verses and generate embeddings
pnpm ingest:quran:slovak # Ingest Slovak translation
pnpm test:quran          # Test Quran search functionality

# Hadith
pnpm clear:hadith  # Clear all Hadith data
pnpm ingest:hadith # Ingest Hadith and generate embeddings

MCP Server

Criterion exposes its semantic search capabilities through the Model Context Protocol (MCP), allowing AI assistants like Claude Desktop and Cursor to search Quran and Hadith directly.

Quick Setup:

json
{
  "mcpServers": {
    "criterion": {
      "url": "https://criterion.life/api/mcp"
    }
  }
}

Available Tools:

  • search_quran — Search 6,236 Quran verses
  • search_hadith — Search 21,641 authentic Hadiths from 6 collections
  • get_verse — Retrieve specific verse by reference (e.g., "2:255")

👉 Read full MCP documentation in MCP.md

Project Structure

code
criterion/
├── app/
│   ├── (auth)/          # Authentication routes
│   ├── (chat)/          # Chat interface and API
│   │   └── api/chat/    # Main chat endpoint
│   ├── search/          # Quran search page
│   │   └── api/         # Quran search API
│   ├── hadith/
│   │   └── search/      # Hadith search page and API
│   └── quran/           # Quran reading pages
├── lib/
│   ├── ai/
│   │   ├── embeddings.ts     # Core RAG logic
│   │   ├── prompts.ts        # Da'i system prompts
│   │   └── tools/
│   │       ├── query-quran.ts   # Quran search tool
│   │       └── query-hadith.ts  # Hadith search tool
│   └── db/
│       ├── schema.ts         # Database schema
│       └── migrations/       # SQL migrations
├── components/
│   ├── chat.tsx              # Main chat UI
│   ├── quran-verses.tsx      # Quran display component
│   ├── hadith-narrations.tsx # Hadith carousel
│   └── hadith/
│       └── hadith-card.tsx   # Reusable hadith card
├── scripts/
│   ├── ingest-quran.ts       # Quran data ingestion
│   ├── ingest-hadith.ts      # Hadith data ingestion
│   └── test-*.ts             # Test scripts
└── data/
    ├── quran*.txt            # Quran translations
    └── *-full.json           # Hadith collections

Documentation

Understanding Criterion

  • MISSION.md — Our vision, values, and deeper purpose. Read this first to understand why we build Criterion.
  • CRITERION_DETAILED.md — Comprehensive technical documentation including architecture, implementation history, and performance metrics.
  • CRITERION.md — Quick reference guide for setup and key concepts.

Key Sections

DocumentPurpose
MISSION.mdVision, values, pillars, and long-term goals
CRITERION_DETAILED.mdTechnical architecture, database schema, components, and best practices
CRITERION.mdQuick start, commands, and core concepts
README.mdGetting started, features, and project overview

Architecture Overview

code
components/
├── Chat UI (QuranVerses, HadithNarrations, MessageActions)
├── Search Pages (Quran and Hadith semantic search with filters)
├── Hadith Components (reusable HadithCard for search and chat)
├── Quran Pages (shared components for context, language selection)
└── UI Components (buttons, inputs, etc.)

lib/
├── ai/
│   ├── embeddings.ts (vector search logic)
│   ├── prompts.ts (Da'i system prompts)
│   └── tools/ (queryQuran, queryHadith, requestSuggestions)
├── db/
│   ├── schema.ts (Drizzle ORM definitions)
│   └── queries.ts (database functions)
└── monitoring/ (performance tracking)

app/
├── (chat)/api/chat (main chat endpoint)
├── quran/search/ (Quran search page and API)
├── hadith/search/ (Hadith search page and API)
├── quran/ (Quran reading pages)
└── (auth)/ (authentication)

Data Attribution

  • Quran Text: Tanzil.net — Creative Commons Attribution 3.0
  • Quran Translations: Multiple sources with proper attribution
  • Hadith Collections: Sunnah.com, IslamicNetwork.com
  • Embeddings: Google Gemini text-embedding-004

Our Commitment

Criterion is built with these commitments:

  • Never monetize Islamic knowledge
  • Always cite sources with proper references
  • Never fabricate verses or hadiths
  • Focus on fundamentals — avoid sectarian debates
  • Build for the community — this belongs to all Muslims and benefits all humanity
  • Stay at the forefront — leverage state-of-the-art technology

Contributing

We welcome contributions from developers, scholars, and community members who share our mission. Please see CONTRIBUTING.md for guidelines.

License

  • Quran Text: Creative Commons Attribution 3.0 (Tanzil.net)
  • Hadith Data: From verified Islamic sources with proper attribution
  • Code: See LICENSE file for details

"Invite to the way of your Lord with wisdom and good instruction, and argue with them in a way that is best." — Quran 16:125

May Allah accept this work and make it a means of guidance for seekers everywhere. Ameen.

常见问题

io.github.BalajSaleem/criterion 是什么?

支持在 6,236 节 Quran 经文和 12,416 条 authentic Hadiths 中进行语义搜索,辅助伊斯兰指引。

相关 Skills

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描164.6k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描164.6k

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描164.6k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
88.1k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
58.6k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
49.4k

评论