# RAG engineering — Muhammad Huzaifa Shahbaz

Canonical page: https://mhuzaifa.com/expertise/rag-engineering
Last updated: 2026-09-28
Person: Muhammad Huzaifa Shahbaz (https://mhuzaifa.com)

Retrieval-augmented systems for document Q&A and for internal operations, including a Gemini legal assistant and n8n workflows.

## What I build

- Document assistants that answer from a private corpus and return the passage they used.
- Operational RAG wired into n8n so repetitive internal lookups do not depend on someone pasting context into a chat window.

## Architecture

- The legal assistant uses Gemini for generation, LangChain to orchestrate retrieval, and MongoDB for documents and embeddings.
- Queries hit vector search first. The model answers from retrieved passages instead of from the prompt alone.
- Ops automation pairs the same retrieval idea with n8n. At Digital Dividend that workflow is credited with about 8 hours saved per week.

## Production constraints

- Legal answers without a source are not usable. The assistant is built to retrieve case material and contracts, not to freestyle.
- Published results on the legal assistant: 95%+ accuracy on classification and question answering in their evaluation, and about a 70% reduction in document review time versus manual research.
- Token cost and stale embeddings are the ongoing bills. Retrieval has to be scoped to the documents that matter for the question.

## Stack

Gemini, LangChain, MongoDB, Next.js, n8n, RAG

## Tradeoffs

- A vector store over a full-document prompt is cheaper and easier to cite, and it fails when the chunking splits the clause that actually answers the question.
- n8n is the right tool for an ops workflow a small team can edit. It is the wrong place for a latency-sensitive user-facing agent.

## Projects

- [AI Legal Assistant](https://mhuzaifa.com/portfolio/ai-legal-assistant): Gemini RAG assistant for legal document search and cited answers.

## External verification

- [Legal AI demo](https://legal-ai.sajjaduddin.site/)
- [Portfolio write-up](https://mhuzaifa.com/portfolio/ai-legal-assistant)

## Questions

### What RAG systems has he shipped?

A Gemini and LangChain legal assistant with MongoDB vector search, plus operational RAG workflows automated with n8n at Digital Dividend Global.

### How is the legal assistant grounded?

It retrieves from stored legal documents and embeddings before answering, and the public write-up describes citation-backed answers rather than ungrounded chat.
