The legal brain
A knowledge graph that turns a legal corpus into a navigable network: you see the whole at a glance and follow the links between concepts, instead of reading article by article. Live demo on Quebec's Loi 25.
- Python
- SQLite + FTS5
- LLM (card and concept generation)
- d3.js (force-directed graph)
- Public data — LégisQuébec
The problem
On a matter that runs for months — a transaction, an investigation, a regulatory reform — the hard part isn’t reading a document, it’s holding the whole thing in your head. Notions answer each other across the corpus: an obligation here points to an exception there, the same concept recurs under three wordings over fifty pages. Linear, document-by-document reading loses those threads. After a while, no one holds the full map any more.
What I built
I borrowed an idea from personal knowledge management — those systems where you link your notes so that thinking emerges as a network rather than a list. People use them for monitoring a topic, for research that stretches over months, for life in general. I applied it to a legal corpus: each article becomes a card, the notions become concepts, and the AI weaves the links between them. The result is a navigable graph where you see the structure at a glance and follow connections step by step.
It’s a bit like delegating part of your brain: the model reads everything, summarizes each piece, and makes the logical connections between elements that would never meet on a linear read. What’s left for the lawyer is judgment — but on material that’s already mapped.
How
For this public example I used Loi 25 (P-39.1 modernized), an open, rights-free text. The pipeline ingests the 155 articles, generates one FR card per article, extracts the concepts and normalizes them (bilingual aliases, one canonical key per notion, never a duplicate), then weaves the links card↔card and card↔concept. It’s all full-text indexed and rendered as a force-directed graph: 237 concepts, 864 links. The demo runs on pre-computed data — no live model calls.
The corpus is a statute because it’s public. But the engine is content-agnostic: the same graph could run on one matter or a set of matters — an M&A data room, legal monitoring of a topic tracked over time, compliance monitoring where you want to see how a new obligation connects to what already exists.
The limits
- A demo on public data only, on a single coherent corpus.
- The cards and links are model-generated: useful to orient yourself, never to take at face value. A “related” link suggests kinship, it doesn’t prove it.
- No weighting of authority or time: the graph is a map, not a ranking or an analysis.
- Showcase version: it could be tooled further — finer control over the linking, personal notes anchored to a precise spot, human validation of links, incremental updates.
Ethics note
Everything rests on the official text of a public statute (LégisQuébec); zero employer, client or confidential data. It is a big-picture and discovery tool, not legal advice. Like any language-model output, the cards and the connections may contain errors: verification at the source remains the rule before any use.
See
The demo is live: explore the graph of all 155 articles, click a node to open its card and concepts, follow the links, or search for a term.