AI Engineering · Case Study

Event-Driven Document ETL Pipeline for RAG

Turns unstructured and semi-structured documents into a retrieval-ready knowledge base — a scale-to-zero worker that replaced a fragile three-Lambda chain.

← All AI engineering work
Trigger
SQS message from any authorized producer
Compute
ECS/Fargate — 0-5 tasks, scales to zero
Stages
Parse → Process → Extract → Index
Sinks
Hybrid search + SQL store + job tracker
Architecture diagram: SQS-triggered ECS/Fargate worker running Parse, Process, Extract, and Index stages, writing to a hybrid search index, relational store, and job-tracking table
High-level architecture — ingestion, pipeline stages, and storage sinks.
▸ Implementation details
  • Format-aware parsing (PDF/DOCX/PPTX/CSV/XLSX/JSON) with structure-preserving, section-aware chunking
  • Per-document LLM entity extraction — 50-100x cheaper than per-chunk, and clinical/technical documents still fit in one call
  • Hybrid retrieval: dense embeddings + sparse neural vectors + BM25, with a structural metadata prefix and IDF-weighted tags for ranking quality
  • Native tabular data (CSV/XLSX) routed to a relational store for SQL-queryable access with row-level RBAC; PDF-extracted tables stay in the search index
  • Content-hash idempotency, dead-letter handling, and per-item error isolation so one bad chunk never blocks a whole document
Next case study Row-Level RBAC for Agentic Data Access via MCP →