ai newsFr., 4. Dez.
EilmeldungAlibaba Releases Qwen4-35B-A3B: Open-Weight MoE Model With 1M Context

Engineering Lawise: Building an AI-Powered LegalTech Platform

01. Introduction Building an AI-powered product is not simply about connecting an application to an LLM API. The real engineering challenge lies in transforming complex domain knowledge into reliable, accessible, and actionable intelligence. Lawise is a LegalTech platform designed to make legal kno

dev.toFreitag 04:49 · 04.12.8 Min. Lesezeit
Bild: dev.to

Posted on Dec 4 • Edited on Dec 4 • Originally published at yunkhngn.dev

Building an AI-powered product is not simply about connecting an application to an LLM API.

The real engineering challenge lies in transforming complex domain knowledge into reliable, accessible, and actionable intelligence.

Lawise is a LegalTech platform designed to make legal knowledge more accessible and simplify contract-related workflows through artificial intelligence.

The platform focuses on three primary capabilities:

The project explores an interesting intersection of software engineering, artificial intelligence, information retrieval, and domain-specific product design.

Rather than approaching Lawise as another AI chatbot, I approached it as an engineering challenge: building a system that connects legal knowledge, intelligent processing, and a practical user experience.

This article explores the architecture, technical decisions, and engineering considerations behind building Lawise.

Before discussing the architecture, it is important to understand the problems Lawise is designed to solve.

Legal documents are inherently complex. Contracts often contain lengthy provisions, interconnected clauses, formal terminology, and legal references that require contextual understanding.

For individuals and small businesses, reviewing these documents can become a time-consuming process.

Lawise aims to reduce this friction by combining AI capabilities with legal-domain workflows.

The distinction between these capabilities is important.

A legal assistant primarily helps users explore and understand legal information. Contract review, on the other hand, requires working with an existing document, identifying specific clauses, and presenting actionable findings.

These are different problems and require different processing workflows.

One of the most important decisions in building Lawise was adopting a distributed backend architecture.

The architecture separates the presentation layer, application services, data persistence, and AI integration.

High-level architecture illustrating the major technology layers.

flowchart TB USER["Users"] WEB["Next.js Frontend"] subgraph BACKEND["Polyglot Microservices"] API["Application APIs"] CONTRACT["Contract Workflows"] LEGAL["Legal Intelligence"] AI["AI Integration"] end subgraph DATA["Data Layer"] DB[("PostgreSQL")] VECTOR[("pgvector")] end LLM["OpenAI API"] USER --> WEB WEB --> API API --> CONTRACT API --> LEGAL CONTRACT --> AI LEGAL --> AI CONTRACT --> DB LEGAL --> DB LEGAL --> VECTOR AI --> LLM Conceptual architecture diagram. Individual service boundaries and communication paths should be aligned with the deployed implementation.

Instead of concentrating all backend responsibilities into a single application, Lawise adopts a multi-language microservices approach.

This architectural direction provides flexibility when different backend capabilities have different technical requirements.

It also encourages clearer separation of responsibilities.

However, microservices introduce additional engineering complexity.

Each service needs well-defined interfaces, communication contracts, error-handling strategies, and clear ownership of its responsibilities.

The important lesson is that service separation should solve an actual architectural problem rather than introduce unnecessary infrastructure.

AI-powered legal applications need to work with different types of information.

PostgreSQL provides the relational foundation, while pgvector extends that foundation with vector storage and similarity search.

The general vector retrieval process consists of several steps:

Legal Documents | v Text Extraction | v Text Processing | v Document Chunking | v Embedding Generation | v PostgreSQL + pgvector | v Semantic Retrieval Enter fullscreen mode Exit fullscreen mode Why pgvector? Choosing pgvector allows vector representations to coexist within the PostgreSQL ecosystem.

This provides several architectural advantages:

However, vector similarity alone does not guarantee legal relevance.

Two passages may be semantically similar while having different legal meanings or applicability.

For legal applications, retrieval quality must be evaluated in the context of the actual legal question.

The AI layer is one of the most interesting parts of Lawise.

Large language models provide powerful language-understanding and generation capabilities, but their outputs are not inherently reliable.

This is especially important in legal applications.

A fluent answer is not necessarily a correct answer. A convincing explanation does not automatically establish legal validity.

Therefore, the engineering challenge is not simply generating responses. It is building workflows that provide useful information while preserving context and making limitations clear.

A retrieval-oriented architecture can help ground model responses in relevant legal information.

flowchart TD Q["User Question"] E["Query Embedding"] R["Vector Retrieval"] C["Relevant Legal Context"] P["Prompt Construction"] L["OpenAI"] A["Generated Response"] U["User"] Q --> E E --> R R --> C C --> P P --> L L --> A A --> U The general idea is to retrieve relevant information before asking the language model to generate a response.

Instead of relying exclusively on its internal knowledge, the model can work with additional contextual information supplied by the application.

For a legal assistant, this approach is particularly valuable because users often need explanations grounded in specific legal provisions.

Legal interpretation depends heavily on context.

A clause cannot always be evaluated independently from the rest of a contract or the applicable legal framework.

This creates several engineering considerations:

The objective is not to make the model appear more confident.

It is to make its responses more useful, understandable, and appropriately grounded.

Contract review is a particularly interesting workflow because it requires more than natural-language generation.

The system needs to process document content, understand individual provisions, identify potential issues, and communicate findings in a format users can act upon.

A conceptual contract review pipeline can be represented as follows:

flowchart TD A["Contract Upload"] B["Document Content Extraction"] C["Content Preparation"] D["Clause Analysis"] E["AI-Assisted Evaluation"] F["Risk Identification"] G["Explanation & Recommendations"] H["User Review"] A --> B B --> C C --> D D --> E E --> F F --> G G --> H The workflow highlights an important distinction between analyzing a document and generating a response.

A useful contract review experience should make findings understandable and actionable.

Rather than returning an unrestricted block of text, a contract review interface benefits from presenting findings in a structured manner.

This structure helps users understand not only what the system has identified, but also why the finding matters.

It also makes the output easier to review and evaluate.

AI-generated content is difficult to integrate into complex document workflows when everything is returned as plain text.

Structured outputs create a more predictable interface between AI processing and application logic.

For example, a conceptual representation of a review finding could look like this:

{ "clause": "Penalty for breach of contract", "risk_level": "high", "issue": "Potentially unfavorable penalty provision", "explanation": "Requires further legal evaluation.", "recommendation": "Review the penalty provision against applicable regulations." } Enter fullscreen mode Exit fullscreen mode This is an illustrative data structure, not a representation of the production API schema.

The broader principle is that AI should produce information that the application can organize, display, and process consistently.

An AI system can be technically sophisticated and still fail as a product if users cannot understand or interact with its outputs.

This is particularly relevant to LegalTech.

The target audience may include individuals and business owners who do not have extensive legal knowledge.

The frontend therefore plays an important role in translating technical capabilities into understandable workflows.

Using Next.js provides the foundation for building the web application and organizing the user-facing experience.

Some important product considerations include:

The goal is to make the technology feel approachable without oversimplifying the underlying legal complexity.

Building Lawise involves several architectural and technical trade-offs.

LLMs are flexible, but legal workflows require consistency.

A system must account for incomplete context, unsupported conclusions, and potentially misleading generated content.

The application should communicate uncertainty appropriately and avoid presenting AI-generated information as definitive legal advice.

Polyglot microservices provide flexibility and separation of responsibilities.

The architectural benefits must justify the additional operational cost.

Vector search is useful for discovering semantically related content.

However, legal correctness depends on more than textual similarity.

The challenge is to ensure that retrieved information is relevant to the actual legal context, not simply close in embedding space.

AI-powered workflows can involve multiple processing stages.

Document analysis and retrieval-heavy workflows can increase token consumption and response latency.

Some important optimization directions include:

These considerations become increasingly important as an AI application moves beyond experimentation.

LayerTechnologyPurposeFrontendNext.jsWeb application and user experienceBackendPolyglot MicroservicesDistributed application servicesPrimary DatabasePostgreSQLRelational data persistenceVector SearchpgvectorVector storage and similarity searchAI ProviderOpenAILanguage-model capabilities

The technology choices reflect an architectural approach that separates application responsibilities while keeping the data and AI layers integrated into the overall product.

Working on Lawise reinforced several important lessons about building AI-powered software.

AI is only one component of an AI product.

The quality of the overall system depends on much more than the model itself. Data organization, retrieval, backend architecture, and user experience all contribute to the final result.

Architecture should reflect the problem domain.

Contract review and legal assistance are related capabilities, but they solve different problems. Treating their workflows as distinct concerns creates opportunities for clearer system design.

Vector search is not a replacement for domain understanding.

Similarity search helps locate potentially relevant information, but relevance is not equivalent to legal correctness.

Microservices introduce both flexibility and responsibility.

Distributed architecture creates opportunities for independent development, but it also requires discipline around interfaces, observability, and service boundaries.

A useful AI product needs to be designed around its users.

The most impressive model output is not necessarily the most useful one. What matters is whether users can understand the result, evaluate it, and take appropriate action.

Lawise represents my exploration of building software at the intersection of artificial intelligence, information retrieval, and domain-specific applications.

The project challenged me to think beyond implementing individual features and consider how different engineering layers work together to deliver a coherent product.

From a Next.js frontend and polyglot microservices backend to PostgreSQL, pgvector, and OpenAI integration, the architecture reflects an attempt to balance flexibility, maintainability, and practical AI capabilities.

More importantly, it reinforced a principle I find increasingly important in software engineering:

Building an AI-powered product is not about making an application that can talk. It is about engineering a system that can turn information into something genuinely useful.

Project: Lawise* Website: * https://lawisevn.com/ Domain: LegalTech · AI Engineering · Backend Architecture · Information Retrieval* Core Technologies: * Next.js · Polyglot Microservices · PostgreSQL · pgvector · OpenAI

Lawise — AI-powered legal assistance and contract review for the Vietnamese market.

Quelle: dev.to (dev.to). Original öffnen