Logo vun Criterion

Criterion

Communautéit
BalajSaleem

Quran based intelligence

EditeurBalajSaleem
Repositorycriterion
SproochTypeScript
Forks
8
Stären
20
Disponibel Tools
3
Transporttypstreamable-http
Kategorien
Linken
  • Tools mat KI-Workflows verbannen

    Criterion stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 3 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    20 Stären an 8 Forks aus dem verlinkte Repository.

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

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

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

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.

Installatioun

TypingMind
{
  "mcpServers": {
    "criterion": {
      "url": "https://criterion.life/api/mcp",
      "env": null,
      "headers": null
    }
  }
}

Disponibel Tools

  • search_quran

    Search 6,236 Quran verses using semantic similarity. Returns verses with ±2 surrounding verses for context. Use this for questions about Quranic guidance, themes, or specific topics.

  • search_hadith

    Search 21,641 authentic Hadith narrations from 6 major collections: Sahih Bukhari, Sahih Muslim, Jami` at-Tirmidhi, Sunan Abi Dawud, 40 Hadith Nawawi, and Riyad as-Salihin. Filter by collection and authenticity grade. Use this for questions about Prophet Muhammad's teachings and practices.

  • get_verse

    Retrieve a specific Quran verse by reference. Use this when you need an exact verse (e.g., Ayat al-Kursi is 2:255).

Criterion MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal Criterion verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun verbënnt sech an TypingMind iwwer d'URL vun engem gehoste MCP-Server.

Eng MCP-Server-URL derbäisetzen

Benotzt dës Optioun, wann Criterion scho remote gehost gëtt oder Är Ekipp ee gemeinsame Connector wëllt, op dee méi Benotzer kënnen zougräifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbäisetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbäisetzen“.
TypingMind-Formulaire fir eng benotzerdefinéiert MCP-Server-URL derbäizesetzen
2

D'Server-URL apeschen

Gitt https://criterion.life/api/mcp am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinéiert HTTP-Headeren oder OAuth-Clientastellungen derbäi, wann de Server se erfuerdert.

  1. Pescht https://criterion.life/api/mcp an d'Feld „Server-URL“.
  2. Gitt en Numm fir d'Verbindung mat Criterion an.
  3. Setzt eng Beschreiwung an e Symbol derbäi, fir d'Verbindung méi einfach erëmzeerkennen.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbäi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zeréck op d'Plugin-Lëscht a kontrolléiert, ob déi nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat Criterion als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen ouni nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivéiert d'Tools vu Criterion ënner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-Aarbechtsberäich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. Aktivéiert d'Tools vu Criterion ënner „Plugins“.
  4. Biet de Modell, den Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Criterion?
Criterion
Jo. Ech hunn et gelies.
Dat hunn ech mat Criterion fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server Criterion benotzt?

Criterion ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech Criterion MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir Criterion mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat Criterion MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann Criterion verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech Criterion MCP mat TypingMind?

Dir kënnt Criterion mat TypingMind verbannen, andeems Dir d'URL vu sengem gehoste MCP-Server derbäisetzt. Dat ass nëtzlech, wann Dir eng Remote-MCP-Verbindung wëllt, déi aus Ärem TypingMind-Aarbechtsberäich disponibel ass.

Wéi eng Tools stellt Criterion MCP an TypingMind zur Verfügung?

Criterion stellt 3 MCP-Tools zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Criterion MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann Criterion eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇