The challenge
Legal professionals were searching tens of thousands of French-language court decisions with keyword tools that missed meaning, context and precedent. Finding the right decision, and the appeals that followed it, took hours.
The documents carried sensitive personal data, including information about minors, so nothing could be indexed or surfaced without rigorous anonymization. Access had to be controlled by role, and the platform had to respect OHADA business-law conventions across multiple jurisdictions.
50K+ décisions· < 2 s· BM25 + vecteurs· réponses citées
- Cour d’appel · Commercial0.94
…la juridiction relève que [PARTIE A] a procédé à la résiliation du bailsans préavis, en méconnaissance de l’Acte uniforme OHADArelatif au droit commercial général…
[1] Arrêt n° ••• · chaîne d’appel ↗
- Tribunal de commerce · Bail0.86
…[PARTIE B], preneur, sollicite des dommages-intérêts pour rupture abusive…
Architecture · 6 stages
- 01
Ingest
PDF/Word extraction, structure-aware chunking
- 02
Redact
Triple-search PII anonymization, minor-protection rules
- 03
Comply
OHADA + privacy rules, three-tier RBAC
- 04
Index
Triple-index Elasticsearch + Pinecone vectors
- 05
Retrieve
Hybrid BM25 + dense fusion, metadata filters
- 06
Generate
Cited answers and document drafting
The solution
I architected and built the platform end to end. A multi-stage ingestion pipeline extracts text from PDF and Word files and applies structure-aware chunking with overlap, so legal reasoning is not cut mid-argument.
Retrieval runs on a triple-index Elasticsearch layer (semantic, metadata and appeal-chain indices) alongside Pinecone vector search. Fusing BM25 keyword scoring with dense vectors improved retrieval accuracy by 15% over either method alone.
A Claude-powered anonymization engine with a triple-search architecture detects and masks personal data before anything is indexed, with dedicated safeguards for minors and vulnerable parties. Three-tier RBAC governs who sees what, and an AI document-generation module drafts legal documents from retrieved precedent.
Compliance is enforced by the pipeline, not by policy: no document reaches the index or the model without passing anonymization first, so 100% of indexed content is privacy-safe by construction. OHADA conventions and multi-jurisdiction privacy rules are applied at ingestion, and every access is scoped by role.
Every architecture change was validated against a 200-question evaluation set built with a practicing lawyer, which caught regressions before they reached users.
Engineering highlights
- Hybrid BM25 + vector retrieval, 15% more accurate than either alone
- Triple-index Elasticsearch: semantic, metadata and appeal-chain search
- Triple-search anonymization engine: 98% PII detection, safeguards for minors
- Compliance by design: 100% of documents anonymized before indexing
- OHADA-aware, multi-jurisdiction privacy rules applied at ingestion
- 200-question lawyer-built evaluation set gating every release
- Three-tier role-based access control (RBAC)
- AI document generation that cut drafting time by 80%
- Around 23 documented REST endpoints for integration
Technology
- Python
- Flask
- Claude API
- OpenAI
- Pinecone
- Elasticsearch
- Docker
- REST API
Related services
Building something similar?
Get a candid view of the architecture, risks and timeline on a free 30-minute call, or ask the AI assistant how this approach would map to your project.