Architecting a Human-in-the-Loop RAG Platform for Legal AI

Vynyl partnered with a class action law firm to transform a Node-RED prototype into JAINE AI, a production-ready AI assistant that addresses the legal industry's fundamental trust problem with artificial intelligence. By engineering a sophisticated human-in-the-loop system that combines retrieval augmented generation (RAG), expert-verified knowledge graphs, and automated quality assurance, we built an AI platform that law firms can confidently deploy to thousands of claimants. In the end, this multi-tenant SaaS platform provides much more than answering legal questions. JAINE reinvents the intake process through conversational AI that qualifies leads while gathering structured data.

JAINE admin console showing flagged unresolved questions, confidence scores and verified answers, beside a phone running JAINE's conversational claimant intake
Built With
  • Claude (Opus, Sonnet, Haiku)
  • AWS Bedrock
  • Bedrock Knowledge Bases
  • RAG
  • Titan Embeddings
  • Cohere Rerank
  • Neptune Analytics
  • Vercel AI SDK
  • LLM-as-a-judge
  • Guardrails
  • Expert-approved answers
  • SvelteKit
  • SST
  • AWS Serverless
  • PostgreSQL
  • Multi-tenant
See how it's built
Rapid Deployment
Only 4 months from kickoff to a production-ready MVP with multi-tenant infrastructure and AWS Bedrock integration
3‑Point Scoring
Reliable feedback loop that continuously improves AI accuracy through expert verification
2 Sources
Dual-source intelligence: RAG over case documents plus an expert-verified knowledge graph

The Challenge

The AI Trust Crisis in Legal Tech

The legal industry has a barrier to AI adoption: hallucination rates. As of this publication, surveys of legal AI tools (including systems from major providers like LexisNexis) revealed hallucination rates as high as 60%, with some of the best-performing systems often producing incorrect answers nearly 20% of the time. For law firms fielding questions from thousands of potential claimants about nuanced medical and legal matters, this unreliability is unacceptable.

JAINE's founding team had proven the concept that claimants needed 24/7 access to answers about their cases without tying up expensive lawyer hours. But their initial Node-RED prototype faced three fundamental obstacles:

Tech Limitations: The visual workflow tool suited for prototyping couldn't scale to support a true multi-tenant SaaS platform. Sure the architecture worked for internal testing, but it couldn't support multiple law firms with isolated data.

Commercialization Gap: Without multi-tenancy, the prototype couldn't generate revenue and each new client would require a separate deployment. Not exactly scalable.

The Trustworthiness Problem: The system lacked guardrails. It could search documents and generate answers, but it had no mechanism to verify accuracy or flag uncertainty. It also couldn’t improve over time and firms couldn’t risk deploying an AI that might give incorrect medical/legal information.

The team needed a partner who could take JAINE from a validated concept to production-ready commercial software while solving the core trust problem that plagued legal AI.

Engineering Viewpoint

How We Engineer AI You Can Verify

Adam Keener, Vynyl’s Director of Engineering, explains how we turn natural language into structured, guardrailed pipelines with citations you can check, built for regulated industries.

Vynyl's Solution

1. Rebuilding the Foundation: Modern Architecture for Scale

Vynyl rebuilt the entire platform from scratch using a modern, maintainable tech stack designed for production scale: SvelteKit for the full-stack framework, PostgreSQL for the database, and AWS serverless infrastructure with Bedrock powering the AI layer.

The new multi-tenant architecture would allow multiple law firms and claims administrators to use the platform with complete data isolation. Each organization can manage multiple AI assistants, upload case-specific documents, and maintain their own claimant records, with robust data isolation keeping every organization's information strictly separate. This architectural decision took JAINE from a single-use prototype to a scalable commercial product.

2. Human-in-the-Loop: The SME Survey System

The core innovation addressing the trust problem is what we call the SME (Subject Matter Expert) Survey System, which is a three-stage feedback loop that continuously improves AI accuracy through expert verification.

Stage 1: Automated Quality Detection - The system automatically flags potentially problematic answers using two mechanisms:

  • Confidence scoring: Vynyl engineered a custom quality scoring system that evaluates each answer across three dimensions: reference sourcing, relevance, and reasoning quality. When the composite score falls below the configured threshold, the question enters an "Unresolved Questions" queue for expert review.
  • User feedback: Any answer receiving a thumbs-down rating from users (or anyone else assigned quality control access) gets flagged for review

This creates a quality assurance layer that operates in real-time, catching problems before they get worse.

Stage 2: Expert Review and Verification - Administrators can create surveys from flagged questions and distribute them to subject matter experts with domain expertise. These experts provide verified, correct answers through a secure survey interface. If clarification is needed, answers can be escalated up the expert chain. Administrators review and approve final answers, creating a human verification layer that improves accuracy.

Stage 3: Knowledge Graph Storage - Approved question-answer pairs are stored in AWS Neptune, a graph database that enables sophisticated knowledge management. Unlike a simple relational database storing Q&As in rows, Neptune structures knowledge as nodes (concepts) and relationships (connections between concepts).

This architecture provides two critical capabilities:

  • Vector-based semantic search: Neptune Analytics embeds questions as vectors, enabling the AI to find similar questions even when phrasing differs. "Can I take ibuprofen with blood thinners?" and "Is it safe to use Advil while on anticoagulants?" are recognized as semantically equivalent, even though the wording and terminology differ.
  • Extensibility for complex relationships: As the knowledge base grows, the graph structure can capture nuanced relationships. A drug might connect to multiple side effects, which connect to related conditions, which connect to treatment protocols. These are all queryable in ways that a traditional database structure would struggle to represent.

The result: the AI doesn't have to focus on exact matches. It reasons about relationships between concepts, drawing on institutional knowledge that gets smarter over time, making the tool more valuable the more it is used.

3. Dual-Source Intelligence: RAG + Expert Knowledge

JAINE operates with two distinct knowledge sources, and the system intelligently routes queries based on context:

Retrieval Augmented Generation (RAG): The AI searches uploaded case documents (settlement agreements, medical studies, court filings) to find relevant passages before generating answers. This grounds responses in actual case materials and provides citation transparency. Users can verify answers by reviewing the source documents.

Expert-Verified Knowledge Graph: For questions that have been previously answered and verified by subject matter experts, the system pulls from Neptune rather than re-processing documents. This provides deterministic, reliable answers for common questions while maintaining the flexibility to handle novel queries through RAG.

The architectural sophistication lies in the decision layer. The system evaluates whether to use document retrieval or expert knowledge, and flags low-confidence responses for future expert review. This creates a continuously improving feedback loop where the most common and critical questions become locked-in, verified answers.

Close-up of thick binders of case documents

4. Conversational Intake & Lead Qualification

Vynyl also developed JAINE's intake system using a novel approach in legal tech. Rather than presenting claimants with a static 10-page form, the intake system uses conversational AI to guide potential claimants through eligibility screening.

The system dynamically adapts questions based on responses. If a potential claimant indicates they didn't take the medication in question, the conversation short-circuits immediately rather than wasting time on irrelevant questions. Users can ask clarifying questions in natural language if they don't understand medical or legal terminology. At the end of the process, qualified claimants can digitally sign representation agreements.

This creates value on a couple fronts: it functions as both a marketing tool (reducing friction in the lead capture process) and an automated screener (filtering out unqualified claimants before they consume lawyer time). If the law firm deploys this to 10,000 previously uncontactable leads, potential claimants who didn't respond to phone outreach but might engage with a lower-friction digital process.

JAINE chat widget offering suggested questions about the CPAP settlement

5. Production-Ready in Four Months

Vynyl delivered the MVP (including multi-tenant infrastructure, AI chatbot functionality with AWS Bedrock integration, and knowledge base management) in four months from kickoff. The platform launched to initial clients in June 2025 and has been in continuous feature development since, with new capabilities funded by specific client needs as the platform scales.

Built With

The technologies behind JAINE, from the AI layer to the infrastructure that keeps every organization’s data separate.

AI layer: Claude (Opus, Sonnet and Haiku, matched to each task) through AWS Bedrock, grounded by retrieval augmented generation over each firm’s case documents with Bedrock Knowledge Bases, Titan embeddings and Cohere reranking.

Knowledge: Neptune Analytics holds expert-approved answers as a knowledge graph, using vector similarity search to match new questions to answers subject-matter experts have already approved.

Quality: Guardrails screen every question and answer, and an LLM-as-a-judge scores each response on sourcing, relevance and reasoning.

Application: SvelteKit and PostgreSQL on AWS serverless infrastructure built with SST, with multi-tenant data isolation.

Takeaways for Regulated Industries

01

Trust Requires Transparency and Human Verification

Put simply, the legal industry's AI skepticism is based on evidence of unreliable systems. JAINE's architecture demonstrates that trustworthy AI in regulated industries requires not only better models, but transparent decision-making (document citations), automated quality detection (confidence scoring), and human expert verification (the SME system). These guardrails take AI from a black box into an auditable, improvable system.

02

Graph Databases Enable Sophisticated Knowledge Management

While everything a graph database does can technically be accomplished with a relational database, the extensibility advantage is significant for AI applications. As knowledge bases grow and relationships become more complex, graph structures provide natural ways to represent how concepts connect. The investment in Neptune positions JAINE to extend its knowledge management capabilities as use cases evolve.

03

Multi-Tenant Architecture Unlocks Commercial Scale

The discipline of defining a true MVP and focusing on core functionality that enabled commercialization was critical to JAINE's success. Rather than building every feature in the initial prototype, Vynyl prioritized multi-tenant isolation and sellability. This allowed the platform to begin generating revenue early and use real client needs to drive feature prioritization.

04

Conversational AI Can Reinvent Traditional Workflows

The intake system demonstrates how AI enables genuinely new workflows rather than simply automating existing ones. Traditional intake meant either expensive lawyer phone time or static forms with high abandonment. Conversational intake combines the guidance of human interaction with the scale and cost-efficiency of automation, creating value that didn't exist in either approach alone.

Workflows JAINE Reinvents

  • Claimant Records Conversational intake qualifies leads while gathering structured data.
  • Lawyer Hours Unqualified claimants are filtered out before they consume lawyer time.
  • Confidence Scoring Every answer is evaluated on reference sourcing, relevance, and reasoning quality.
  • Case Documents Answers are grounded in settlement agreements, medical studies, and court filings.

Conclusion

Sophisticated AI engineering and disciplined product thinking pays off, and Vynyl transformed JAINE from a promising prototype into a commercial platform that addresses the legal industry's fundamental concerns about AI reliability. The combination of human-in-the-loop verification, dual-source intelligence, and innovative conversational workflows creates a system that law firms can confidently deploy to thousands of claimants.

The technical choices (graph databases for knowledge management, RAG for document backed responses, automated quality detection) demonstrate that building trustworthy AI for regulated industries requires comprehensive platform engineering, rather than off-the-shelf models.

Take the Next Step

Ready to build AI systems that regulated industries can trust? Check out how Vynyl's expertise in architecting AI-native platforms can transform your vision into production-ready software.

Book a Call