ProjectBuild an AI-Powered Digital Bank with RAG: the explanation · Module 12: Guardrails and personal data masking · part 14 of 20
Part 14 · Module 12: Guardrails and personal data masking

Module 12: Guardrails and personal data masking

23 min read·
About 35 minutes · Needs: Module 9 (retrieval) and Module 10 (the agent graph) · Code: backend/app/agent/guardrails.py, backend/app/core/pii.py, backend/app/agent/stream_guard.py

Where this fits

WHERE THIS FITS The Kestrel Bank system this module CLIENT API LAYER FastAPI SAFETY AGENT LangGraph MODELS RETRIEVAL DATA AND INGESTION Postgres, Redis QUALITY Langfuse Customer app React Admin app React FastAPI REST + streaming Auth + RBAC tokens, roles Document upload admin only, checked Guardrails injection, PII Router small or large Agent LangGraph Banking tools ledger, transfers LLMs Groq, Gemini Retrieval hybrid + rerank Ingestion parse, chunk, embed PostgreSQL + pgvector ledger, chunks, state Redis limits, queue Observability Langfuse, metrics, logs Evaluation golden set, release gate
Guardrails (blue: this module) wrap the agent and its models, and the same masker runs inside logs and traces.

Guardrails sit on both sides of the agent. Every customer message passes through them before the router sees it, and every answer passes through them before the customer sees it. The same personal data masker also runs inside logging and tracing, so this module touches the API, the agent, the model calls and observability.

The rest of this project is yours to keep

This project is bought on its own, once, and stays readable afterwards, including the parts added to it later.

Or open everything with a plan