Back to Projects

AI · RAG on AWS

Noor AI

A conversational Islamic Q&A assistant grounded in a retrieval-augmented knowledge base of the Quran and Sahih al-Bukhari

Type
AI · RAG on AWS
Released
2026
Role
Solo build — design to deploy
Stack
8 technologies

The Problem

General-purpose chatbots are unreliable for Islamic questions: they fabricate Quran and hadith citations and gloss over genuine differences between the four Sunni schools of thought.

The Solution

A conversational Islamic Q&A assistant grounded in a retrieval-augmented knowledge base of the Quran and Sahih al-Bukhari. A LangChain tool-calling agent on AWS Bedrock (Claude) retrieves whole verses and hadith with precomputed citations, keeps conversation memory in DynamoDB, streams answers token by token, and states madhab differences explicitly instead of claiming false consensus — fully serverless on AWS.

Architecture

An offline ingestion pipeline transforms the Quran and Sahih al-Bukhari into ~27,000 single-chunk corpus files, each paired with citation metadata, embedded with Cohere Multilingual v3 into an S3 Vectors index behind a Bedrock Knowledge Base — so retrieval units are always whole verses or whole hadith and citations come from metadata, never the model. A FastAPI backend runs on Lambda through the Lambda Web Adapter with response streaming over a Function URL; the LangChain agent calls the Knowledge Base Retrieve API as a tool and DynamoDB persists chat sessions for memory. The Next.js chat UI is served from S3 via CloudFront, which also routes /api/* to the backend under one custom domain (Route 53 + ACM). Everything is provisioned by AWS CDK across dedicated DNS, data, knowledge-base, API, and web stacks.

Built With

  • Python
  • FastAPI
  • LangChain
  • AWS Bedrock
  • AWS CDK
  • DynamoDB
  • Next.js
  • Tailwind CSS

Challenges

  • Eliminating fabricated citations: one corpus file per verse/hadith with citations precomputed at ingestion time, so the agent quotes references verbatim from retrieval metadata instead of generating them.
  • Presenting fiqh rulings faithfully across the four Sunni madhahib — the system prompt forbids claiming consensus and requires per-school classification with each school's own terminology.
  • Streaming agent responses end to end through Lambda without Docker: FastAPI behind the Lambda Web Adapter with a response-streaming Function URL, and Python dependencies bundled on the host with uv at deploy time.

Results

  • Live at noorai.elprince.net — one CloudFront domain serving both the chat UI and the streaming API.
  • Grounded answers citing whole Quran verses and Bukhari hadith from a ~27,000-chunk knowledge base.
  • Fully serverless, infrastructure-as-code deployment across five AWS CDK stacks.