LegalDraft-AI: Modular Multi-Step Legal Document Generation System
Modular FastAPI backend decoupling retrieval, structured prompting, deterministic template validation, and a stateful draft-review-refine workflow.
Stateful multi-step Draft → Review → Refine pipeline with deterministic template validation
- FastAPI
- Python
- RAG
- Structured LLM Prompting
- REST APIs
Problem
Single-shot LLM generation frequently hallucinates clauses or breaks structural formatting in multi-section legal documents.
Approach
Built a modular FastAPI backend separating retrieval, structured prompting, template validation, and a stateful draft-review-refine workflow with inspectable intermediate outputs.
Results
Delivered repeatable, schema-validated legal drafts with isolated, unit-testable retrieval and formatting stages.
What Went Wrong
Early monolithic prompts suffered from formatting drift and inconsistent clause numbering on longer documents.
What I Learned
In this system, decoupling retrieval from deterministic template validation and iterative refinement turned probabilistic LLM outputs into more reliable software pipelines.
Links & Artifacts
Code / artifacts being prepared for release.