Inspiration
Compliance teams face an impossible task: manually reviewing every Slack message, email, and document to check for PII leaks or regulatory violations. A single missed Social Security Number in a support ticket can result in GDPR fines up to €20 million. I wanted to build an agent that turns hours of manual review into seconds of automated analysis.
What it does
Legal Auditor is a multi-step AI agent that:
- Ingests documents in real-time through a PII detection pipeline
- Identifies sensitive data (SSNs, credit cards, emails, phone numbers)
- Matches content against compliance policies using Elasticsearch Hybrid Search (BM25 + Vector)
- Flags violations with specific policy citations and risk scores
- Provides a real-time dashboard for compliance officers
How I built it
- Elasticsearch Serverless for data storage and hybrid search
- Ingest Pipelines with custom PII detection logic
- Hybrid Search combining keyword (BM25) and semantic vector search for accurate policy matching
- Node.js + Express API server
- Vanilla JavaScript frontend for a lightweight, fast dashboard
The agent monitors three Elasticsearch indices:
compliance-policies- GDPR, HIPAA, and internal policiesmonitored-documents- Incoming documents with PII annotationsflagged-violations- High-risk items requiring review
Challenges I faced
Elasticsearch Serverless limits - The strict regex limits on Painless scripts forced me to move PII detection from ingest pipelines to the application layer. This actually improved performance!
Hybrid search tuning - Balancing keyword relevance vs. semantic similarity required experimentation with boost values and reciprocal rank fusion.
Risk scoring algorithm - Designing a scoring system that accurately prioritizes violations based on PII type, policy severity, and context.
What I learned
- Elasticsearch's hybrid search is incredibly powerful for matching unstructured text against policy databases
- Moving compute-heavy operations (like regex-based PII detection) to the application layer can actually be more scalable than doing it in ES
- Agent Builder's custom tools make it easy to connect LLMs with Elasticsearch data
What's next
- Integration with Slack/Teams for real-time alerts
- Support for more compliance frameworks (SOC2, PCI-DSS)
- Remediation workflow automation (auto-redact, auto-ticket creation)
Built With
- css
- elasticsearch
- elasticsearch-agent-builder
- elasticsearch-serverless
- express.js
- html
- hybrid-search
- ingest-pipelines
- javascript
- node.js
Log in or sign up for Devpost to join the conversation.