Inspiration

Finding the right lawyer can be slow, confusing, and intimidating. Most people rely on word-of-mouth referrals, random searches, or calling multiple offices just to figure out who might be relevant to their case. That process often leaves people unsure if they’re making the right choice.

Lex.AI was built to simplify this process and make legal help accessible to everyone. By providing relevant lawyers, performance insights, and cost estimates, it reduces guesswork and empowers users to make informed decisions.

What it does

Lex.AI searches for lawyers on your behalf based on your case details. Users enter:

  • Area of law (e.g., family, criminal, corporate)
  • City they're in
  • A brief description of their case

Lex.AI then:

  • Returns relevant lawyers with publicly available contact info (email and phone)
  • Provides performance signals to help evaluate lawyers’ past success
  • Estimates total case cost with an advanced rate calculator
  • Lets users directly reach out with a single click

Instead of just listing lawyers, Lex.AI helps users compare and decide. In the future, users could also call a dedicated AI line, describe their case verbally, and get connected to the right lawyer—all in one seamless phone session.

How we built it

  • Frontend: HTML interface for fast input and clear results.
    • To ensure our vision was translated seamlessly to code with minimal friction, we utilized Google's latest frontend development AI, Stitch. By combining the doodles we created to draft the look and feel of our application with prompting to refine the AI's designs, we created a seamless user flow and a unified theme across our application's different pages.
  • Backend orchestration: n8n workflows to handle the search and processing pipeline.
    • For accurate win rates, we instructed the agent to look at court documents and verifiable information to reduce hallucinations.
    • Verified model outputs against human-conducted research during testing phase to find the optimal model to provide accurate data.
  • Search layer: Tavily API for finding lawyers based on case details
  • Data processing: Extracted structured lawyer data (contact info, specialization, location)

Project Flowchart


╔══════════════════════════════════════════════════════════════════════════════════════════════╗
║  FRONTEND — Build4Good2026/frontend/                                                         ║
╠══════════════════════════════════════════════════════════════════════════════════════════════╣
║                                                                                              ║
║   ┌───────────────┐    CTA / nav     ┌───────────────┐                                       ║
║   │  index.html   │ ───────────────► │  search.html  │  • header.js / footer.js (web comps)  ║
║   │  (landing)    │                  │  (criteria    │                                       ║
║   └───────────────┘                  │   form)       │                                       ║
║         ▲                            └───────┬───────┘                                       ║
║         │                                    │ submit                                        ║
║         │                          ┌─────────▼──────────────┐                                ║
║         │                          │ scripts/request.js     │                                ║
║         │                          │ POST JSON + loading UI │                                ║
║         │                          └─────────┬──────────────┘                                ║
║         │                                    │                                               ║
║         │         ┌──────────────────────────┼──────────────────────────┐                    ║
║         │         │                          │                          │                    ║
║         │         │                          ▼                          │                    ║
║         │         │              ┌─────────────────────────┐            │                    ║
║         │         │              │ localhost:5678          │            │                    ║
║         │         │              │ POST /webhook/findlawyer│            │                    ║
║         │         │              └───────────┬─────────────┘            │                    ║
║         │         │                          │                          │                    ║
║         │         │                          ▼                          │                    ║
║         │         │  ╔═══════════════════════════════════════════════╗  │                    ║
║         │         │  ║  N8N — LexAI workflow (lexai.json)            ║  │                    ║
║         │         │  ╠═══════════════════════════════════════════════╣  │                    ║
║         │         │  ║  ┌─────────────┐                              ║  │                    ║  
║         │         │  ║  │  Webhook    │                              ║  │                    ║
║         │         │  ║  └──────┬──────┘                              ║  │                    ║
║         │         │  ║         ▼                                     ║  │                    ║
║         │         │  ║  ┌─────────────────────┐                      ║  │                    ║
║         │         │  ║  │ Validate Structure  │  (Code node)         ║  │                    ║
║         │         │  ║  └──────────┬──────────┘                      ║  │                    ║
║         │         │  ║             ▼                                 ║  │                    ║
║         │         │  ║  ┌─────────────────────┐                      ║  │                    ║
║         │         │  ║  │ Structure Check (IF) │                     ║  │                    ║
║         │         │  ║  └───┬─────────────┬───┘                      ║  │                    ║
║         │         │  ║      │ invalid     │ valid                    ║  │                    ║
║         │         │  ║      ▼             ▼                          ║  │                    ║
║         │         │  ║  ┌────────────┐  ┌────────────────────────┐   ║  │                    ║
║         │         │  ║  │ Invalid    │  │ AI Agent (LangChain)   │   ║  │                    ║
║         │         │  ║  │ Structure  │  │  • lm: OpenRouter      │   ║  │                    ║
║         │         │  ║  │ Response   │  │  • tool: Tavily search │   ║  │                    ║
║         │         │  ║  │ HTTP 400   │  │  • parser: JSON output │   ║  │                    ║
║         │         │  ║  └────────────┘  └────────────┬───────────┘   ║  │                    ║
║         │         │  ║                               ▼               ║  │                    ║
║         │         │  ║                  ┌─────────────────────┐      ║  │                    ║
║         │         │  ║                  │ Format Output       │      ║  │                    ║
║         │         │  ║                  │ ({ lawyers: [...] })│      ║  │                    ║
║         │         │  ║                  └──────────┬──────────┘      ║  │                    ║
║         │         │  ║                             ▼                 ║  │                    ║
║         │         │  ║                  ┌─────────────────────┐      ║  │                    ║
║         │         │  ║                  │ Actual Response     │      ║  │                    ║
║         │         │  ║                  │ HTTP 200 + JSON     │      ║  │                    ║
║         │         │  ║                  └─────────────────────┘      ║  │                    ║
║         │         │  ╚═══════════════════════════════════════════════╝  │                    ║
║         │         │                          │                          │                    ║
║         │         └──────────────────────────┼──────────────────────────┘                    ║
║         │                                    │ response JSON                                 ║
║         │                                    ▼                                               ║
║         │                          ┌─────────────────────┐                                   ║
║         │                          │ sessionStorage      │                                   ║
║         │                          │ key: lawyerList     │                                   ║
║         │                          └──────────┬──────────┘                                   ║
║         │                                     │ redirect                                     ║
║         │                                     ▼                                              ║
║         │                          ┌─────────────────────┐                                   ║
║         └──────────────────────────│ results.html        │                                   ║
║                                    │ request.js: render  │                                   ║
║                                    │ prev / next cards   │                                   ║
║                                    └─────────────────────┘                                   ║
║                                                                                              ║
╚══════════════════════════════════════════════════════════════════════════════════════════════╝

┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│  EXTERNAL SERVICES                                                                           │
│  • OpenRouter — LLM (e.g. arcee-ai/trinity-large-preview:free) · creds in n8n                │
│  • Tavily — web search API · TAVILY_API_KEY via backend/n8n/.env                             │
└──────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│  PAYLOAD (request body from frontend → webhook)                                              │
│  priceLow, priceHigh, city, caseType, languages[], disabilityFocused (bool), description     │
└──────────────────────────────────────────────────────────────────────────────────────────────┘

Enhancements:

  • Performance signals: Approximate “success indicators” derived from available data.

  • Cost estimation: Calculates likely total fees based on case type, duration, and typical lawyer rates.

  • Mixed queries: Searches Google and the Texas Bar Association to combine public opinion with official information to provide nuanced recommendations.

The system functions as both a search engine and a decision-support tool, turning unstructured information into actionable insights. Traditional search engines offer biased results with rankings determined by ad placements. Lex.AI provides an unbiased, tailor-made search to user criteria to find the best lawyers given their case.

Marketing

We also ran a social media marketing campaign using demos and skits to gauge interest in a product like this. There was definite interest, with the account amassing followers at a rapid pace. You can find our official Instagram here.

Challenges we ran into

  • Data reliability: True win rates aren’t publicly available, so we had to approximate or infer from incomplete data.

  • Cost estimation complexity: Legal fees vary widely, making accurate projections challenging.

  • Unstructured data: Extracting consistent info from messy web sources was difficult.

  • Time constraints: Implementing a functional end-to-end system during a hackathon required focusing on core features.

  • Balancing simplicity vs. insight: We wanted the UI to be approachable while still giving meaningful metrics.

Accomplishments that we're proud of

  • Built a working end-to-end system from case input → relevant lawyers → contact.

  • Added decision-making tools (performance signals and cost estimates) beyond basic search.

  • Integrated multiple platforms (n8n + Tavily + frontend) into a cohesive workflow.

  • Tackled a real-world problem where data is incomplete and messy, and still produced useful results.

What we learned

  • Users want confidence in their choices, not just options.

  • Even imperfect metrics are valuable if presented transparently.

  • Cost transparency is a major gap in legal services.

  • Building trust through reliable, actionable data is just as important as functionality.

What's next for Lex.AI

  • Improve the accuracy of lawyer performance metrics using verified datasets.

  • Refine the cost estimator with more real-world pricing data.

  • Add user reviews and feedback to complement quantitative metrics.

  • Introduce ranking and recommendation systems personalized to each case.

  • Build a more robust UI with saved searches, comparisons, user, and lawyer profiles.

  • Voice-assisted connection: Users will be able to call an AI line, describe their case verbally, and get connected to the right lawyer in a single session.

Built With

Share this project:

Updates