lawbase lawbase Legal Engineering Blog

As-you-type search and version control for legal research

The most common form of legal research is looking up a single section of a law, usually dozens of times a day. Clicking around Google and the official state websites took me about six full seconds per lookup. That annoyed me so much that I built a site with an almost instant as-you-type search. It also diffs the old and new versions of each law, so you get an easy overview of every update to the legal text directly where you need it (yes, that did not exist before).

Konstantin Richter, IT lawyer and software developer

As-you-type search

Version control

Änderung vom 27.09.2026

§ 5 UWG im Reader, Absatz 1 und der Anfang von Absatz 2: In Absatz 2 Nummer 1 sind die zum 27.09.2026 eingefügten Wörter, etwa „ökologische oder soziale Merkmale“ und „Zirkularitätsaspekte wie Haltbarkeit, Reparierbarkeit oder Recyclingfähigkeit“, grün markiert, die ersetzten Wörter rot durchgestrichen.

Technical Infrastructure

Semantic search on 426 German and European laws

Lawyers would not admit it, but they don't always know the exact norm number they are looking for. So Lawbase can search all 426 laws it currently covers by meaning: describe the case in plain words, like Täuschung Geschäft, and the right norm comes up, here § 5 UWG (Irreführende geschäftliche Handlungen).

To make this work, I run a small multilingual-e5 embedding model on my server, next to a self-hosted Typesense instance. Typesense holds one chunk per Absatz, each with a 384-dimensional embedding, and answers keyword and vector queries from the same index. Interestingly, the self-hosted model needs only about 18 ms per query on two CPU cores, which makes it much faster than calling OpenAI's embedding API, without losing significant accuracy for this particular task.

Speed, speed, speed

Lawbase runs on a single Hetzner server in Germany, close to the people using it. An SQLite database holds the law versions, changes and cross-references, and every law is sent to the client as one Brotli-compressed file, roughly 88 % smaller than the raw file.

A powerful, but thin client

The client is a minimal Svelte shell. Since the BGB alone would put around 30,000 elements into the DOM, the reader uses TanStack Virtual to render only the norms on screen, plus a few above and below. That way, scrolling stays smooth, and jumping from § 1 to § 2385 needs no network round trip, because the whole law is already in the browser.

Laws are cached locally in IndexedDB for faster loading and only downloaded again when their content hash changes.

Better UI for lawyers

Lawbase makes lawyers' lives easier (it certainly made mine easier) by highlighting important data and connecting different data sources in a single, consolidated view. Two examples:

Pinpoint cross-references

§ 111f StPO Vollziehung des Vermögensarrestes

You really should not have to read the full norm just to see the one sentence that a legal reference actually points to. What a waste of time and energy! Lawbase pinpoints the exact target of a legal reference, via a legal data pipeline in the backend that uses Grok 4.7's API to review a deterministic parser's output.

Every change, in the text

Lawyers have multiple tools for keeping up with changes to the law. None of them is integrated where the information is actually needed: in the law itself! Instead of starting your day by reading a list of changes, you should see a change exactly when and where you need it: while you read the law. Lawbase shows these changes in one consolidated view, using deterministic code.

The SEO problem

Lawyers usually start at Google when they want to look something up in the law. Printed statute books are only mandatory for students; practitioners have, thank God, largely stopped using them.

This makes SEO very important for any legal text website and seems to put programmers in a dilemma: It makes a lot of sense to give legal readers a scrollable version of the whole law, where they can jump around and follow the many interlinked sections with ease. But Googlebot ranks a page that serves the whole law unacceptably low for the typical search, as lawyers mostly look for a single norm, with queries like "312 bgb" as the starting point of their research. Serving the whole law (the Bürgerliches Gesetzbuch (BGB) is ~2.2 MB of data) is slow, and the page is not clearly tied to § 312 BGB. I suspect that is one of the reasons why most legal text sites serve only single sections.

Hydration

Lawbase solves this with hydration: it serves SEO-friendly HTML for a single norm, then loads the full law a moment later and makes it fully usable. Try it out and notice how § 29 StPO loads first: lawbase.me/gesetz/stpo/29.

Next steps: A legal data pipeline for official reasoning

I am currently building out another legal data pipeline. It extracts the official reasoning behind a law from the Bundestag archives and shows it next to the norm in Lawbase, so that readers know the why behind a recent change.

§ 434 Abs. 3 S. 2 BGB

BT-Drs. 21/5923, S. 24

Setting this up to run automatically, with only a reviewing human-in-the-loop (me), is tricky. The material is spread over several PDF documents in the Bundestag archives, which carry input from multiple parliamentary groups and committees, and only some of it makes it into the final version (e.g. for a recent change to German sales law). Since no consolidated version of the official reasoning exists, you have to backtrack from each section of the passed law to find the "winning" proposal and the reasoning attached to it. Building this into an automated pipeline with reliable AI decision gates requires solid legal knowledge of the Bundestag's procedures and Art. 76 GG.