ahmedallem.
AI · 6 min read

Prototyping LegalAgento: From Research to Working Product

How eight months of research became a working prototype. the technical decisions, the surprising challenges, and the first user reactions to AI-guided legal help.

Ahmed Allem

Ahmed Allem

Founder & CTO · Aviation, AI & Startups

ShareShare
Prototyping LegalAgento: From Research to Working Product

Eight months ago, I started researching the access to justice crisis. Three months ago, I started building. Today, I've a working prototype of LegalAgento that can guide a user through a Massachusetts small claims security deposit case from initial situation assessment to filed complaint.

The journey from research to prototype taught me things that no amount of planning could have anticipated. Here is what happened.

Scoping the Prototype

The hardest decision in prototyping LegalAgento wasn't what to build. It was what not to build. The access to justice problem is vast. I could have spent years building a comprehensive legal AI platform. Instead, I forced myself to pick one use case and go deep.

I chose security deposit disputes in Massachusetts for specific reasons:

High frequency. Security deposit issues are among the most common landlord-tenant disputes. The volume of potential users is large.

Clear law. Massachusetts has some of the strongest tenant protection laws in the country. The rules around security deposits (how they must be held, what the landlord must document, the timeline for return) are detailed and specific. This specificity is good for AI because it reduces ambiguity.

Accessible courts. Small claims court in Massachusetts has a $7,000 limit and is designed for self-representation. The procedures are relatively straightforward, and the filing process is documented.

Meaningful stakes. A security deposit can be $2,000-$5,000. That isn't enough for most people to hire a lawyer, but it's enough that they want to fight for it. The gap between "worth fighting for" and "can't afford a lawyer for" is exactly where LegalAgento should live.

The Technical Architecture

LegalAgento's prototype is built on Next.js with App Router, TypeScript, Tailwind CSS, and the Claude API via Vercel's AI SDK. The architecture has three layers:

Conversation Layer

The user interacts with LegalAgento through a structured conversation. Not a free-form chat, but a guided dialogue that systematically gathers the information needed to assess the case and generate documents.

The conversation follows a state machine pattern. Each state has:

  • A set of questions to ask
  • Validation logic for the answers
  • Transition rules to the next state
  • A progress indicator showing where the user is in the process

This hybrid approach (AI-powered natural language understanding within a structured flow) turned out to be much more effective than a purely free-form conversation. Users need to feel like they are making progress, and a state machine gives that sense of forward motion.

Knowledge Layer

The knowledge layer is where the legal expertise lives. It's a structured database of Massachusetts landlord-tenant law, organized by topic, with specific statutes, relevant case law, and plain-language explanations.

I built this layer through a combination of manual research and AI-assisted synthesis. I read the actual statutes, then used Claude to help me create structured representations of the legal requirements with cross-references and plain-language summaries.

The critical design decision was to use retrieval-augmented generation (RAG) rather than relying on the model's training data for legal information. The model's knowledge of Massachusetts security deposit law is decent but not reliable enough for production use. RAG lets me control exactly what legal information the model has access to, ensuring accuracy and providing clear citations.

Document Generation Layer

When the user has provided enough information, LegalAgento generates the actual court documents: the complaint form, the demand letter, and supporting documentation.

Document generation uses AI SDK's structured output with detailed Zod schemas that match the court's required formats. The generated documents are then rendered into fillable PDFs that the user can print and file.

The challenge here was mapping between the user's natural-language description of their situation and the formal legal language required by the court. Claude handles this translation well, but it required careful prompt engineering to ensure the output uses appropriate legal terminology while remaining accurate to the user's specific facts.

Surprising Challenges

Challenge 1: Jurisdiction Specifics Are Harder Than I Expected

Even scoped to one state, the legal details are more granular than I anticipated. Different Massachusetts courts have slightly different filing procedures. The rules for service of process vary by county. Small details, like whether you need to include a certificate of service with the initial filing, can trip up a self-represented litigant.

I ended up building a jurisdiction layer that captures these county-level differences and adjusts the guidance accordingly. This wasn't in the original plan but turned out to be essential for the product to be genuinely useful.

Challenge 2: Users Do Not Know What They Do Not Know

In user testing, the biggest challenge wasn't answering questions users asked. It was identifying questions they didn't know to ask. A user might describe their situation thoroughly but omit a critical detail (like whether they received their security deposit statement within 30 days) because they didn't know it mattered.

LegalAgento's conversation layer had to be redesigned to proactively ask about legally significant details, even when the user didn't volunteer them. The state machine now includes required checkpoints that ensure all legally relevant facts are captured before proceeding.

Challenge 3: Emotional Complexity

I wrote about this in my UX lessons post, but experiencing it in prototype testing was different from theorizing about it. Users who had been wronged by their landlord were angry. Users who were being evicted were scared. The AI's response needed to acknowledge these emotions without being patronizing.

After several iterations, I landed on a pattern that works: acknowledge briefly, then empower. "That sounds like a frustrating situation. The good news is that Massachusetts law is strongly on your side here. Let me walk you through your options."

First User Reactions

I tested the prototype with eight people who had real security deposit disputes. The reactions fell into a clear pattern:

Initial skepticism. Every tester started skeptical. "An AI is going to help me with a legal problem?" The association between AI and chatbots made people expect something superficial.

Surprise at specificity. The skepticism broke when LegalAgento showed knowledge of their specific situation. Citing the exact Massachusetts statute, calculating the exact amount they might be owed (including treble damages under MGL Chapter 93A), and explaining the specific steps for their specific court. That level of detail wasn't what they expected.

Relief at having a plan. The most common emotional reaction was relief. Not excitement about the technology, but relief at having a clear, step-by-step plan for something that had felt overwhelming. Several testers said some version of: "I knew I should do something about this but I didn't know where to start."

Concern about correctness. Every tester asked some version of "Is this right?" The confidence indicators and attorney referral options were essential for addressing this concern. Users were more comfortable when LegalAgento explicitly said "This is well-established law" versus "This might depend on your specific circumstances, so consider consulting an attorney."

What Is Next

The prototype proves the concept. AI-guided legal help for specific case types, with structured workflows, domain-specific knowledge, and clear handoffs to human attorneys, is technically feasible and genuinely useful.

The next phase is expanding to additional case types (eviction defense, wage claims) while deepening the Massachusetts coverage. Then, state-by-state expansion, starting with states that have similarly well-codified tenant protection laws.

Eight months from research to working prototype. For a product that could help millions of people access the legal system for the first time, that feels like the most meaningful eight months of building I've ever done.