Project logo πŸ€–
2024
Entytech

AI Legal Generator

Generative UI approach for complex document drafting.

Drafting legal documents from scratch is intimidating. Users know their intent ("I need a loan agreement") but lack the legal specifics. The challenge was to build a tool that converts a vague one-sentence description into a robust legal document, avoiding the tedious back-and-forth of a chatbot.

🧠 Solution: Generative UI

I implemented a Two-Stage Wizard where the interface itself adapts to the user's intent.

  1. Intent: The user enters a general description in a single input field (e.g., "Freelance contract for a designer in Serbia").
  2. Form Generation: The system doesn't "chat." Instead, the AI generates a JSON schema of required clarifications, and the frontend instantly renders a strict, validated form.
  3. Execution: The user fills in the generated inputs (dates, amounts, dropdowns) and receives the final document.
The system dynamically builds the UI based on the specific legal context.

βš™οΈ Engineering Details

To ensure reliability, I leveraged the Structured Outputs capabilities (just introduced by OpenAI in 2024) instead of relying on loose text generation. This enabled a robust Generative UI pattern: the backend guarantees a valid JSON schema, allowing the frontend to render native form components without the risk of breaking the layout.

To tackle the iterative nature of LLM development, I introduced an "Engineering Mode" (Staging only). This in-app sandbox allowed us to tweak system prompts and temperature directly from the frontend and instantly test the results. This reduced the feedback loop from minutes (backend redeploys) to seconds, empowering the team to fine-tune accuracy rapidly.

πŸ’Ž Result

  • Integration: The output (DOCX + PDF) is automatically placed into the existing Contracts module architecture for signing or editing.
  • UX: We abstracted the complexity of prompt engineering behind a clean, professional form interface.
OpenAI API (Structured Outputs)
Generative UI
NestJS / Vue 3
Dynamic Forms