Work

dina.

A legal knowledge base and exam edition for European patent law.

dina.
Aramaic for “the law”, as in dina de-malkhuta dina.

dina. is my personal legal knowledge base for European Patent Attorney training. It brings the EPC, Implementing Regulations, Rules relating to Fees, Protocols, the Guidelines for Examination, the PCT and Boards of Appeal case law into one reader, and adds a personal layer on top: highlights, Markdown notes, typed links between provisions, and a wiki of practice notes.

Its main purpose is a printed exam edition: every Article with its Rules, my commentary in the margin, and page-referenced cross-links, typeset for A4.

It runs privately at dina.cdkara.ch (login required).

Reader

Every provision is an addressable unit with a citation-style ID (EPC:A123(2)), rebuilt reproducibly from the EPO’s official HTML.

One index across all legal texts and case law.

Notes in the margin

Highlights and Markdown notes anchored to the exact passage, Word-comment style.

Linking the law

Typed relations (“implemented by”, “exception to”, “case law”) capture the practitioner’s reflex: amend a claim → check 123(2), 84, 123(3).

Case law

Boards of Appeal decisions from the EPO’s bulk dataset, with headnotes and a link to the original.

Pages

A small Markdown wiki with wiki-links into the law and backlinks from each provision.

Exam edition

Paged.js typesetting: law text left, commentary right, Rules interleaved under their Articles.

For the technically curious.

Under the hood

dina. is a Next.js 16 / React 19 app on two SQLite databases. The design rule is a hard split between the law, which is disposable and can be rebuilt at any time from source, and my own work, which is never touched by a rebuild.

Two databases, one query

  • official.db holds the legal texts and case law. It is a build artefact: a single command wipes and rebuilds it from the parsed source snapshots.
  • user.db holds everything I write: highlights, notes, ratings, tags, typed links, and the index of my Markdown pages. Its schema evolves through versioned migrations (14 so far) and is never rebuilt.

At runtime the app opens official.db and ATTACHes user.db into the same connection, so a single SQL query can join a provision to my notes on it. Both run through better-sqlite3 in WAL mode with foreign keys on. The Markdown pages themselves live as plain files in a folder (Obsidian-style); SQLite only indexes them.

A reproducible pipeline for the law

The legal texts come from the EPO’s and WIPO’s official per-provision HTML pages, never from PDFs, in four offline-separable stages:

URL manifest → snapshot (dated, add-only, rate-limited)
             → parse (pure, no network) → import into official.db

Every snapshot’s SHA-256 is recorded in its manifest, so a rebuild provably starts from the same inputs. The official PDFs are kept as authority snapshots and used only to cross-check the parsed text.

As of September 2026 the corpus holds about 5,700 addressable provisions across the EPC, Implementing Regulations, Rules relating to Fees, Protocols, Guidelines and PCT, and about 49,000 Boards of Appeal decisions, streamed from the EPO’s bulk XML dataset rather than scraped.

Every provision has an address

Each unit of law gets a stable, citation-style ID that survives new editions:

EPC:A123(2)      EPC:A52(2)(a)      IR:R71a(3)
RFEES:A2(1)[item3]      PCT:R46.5      GL:H-IV-2.1

Notes attach to these IDs, not to page positions, which is what lets them survive when the EPO publishes a new edition.

The law as a graph

While parsing, every cross-reference in the text (“in accordance with Article 94(3)”) becomes a directed edge with its exact character position. About 26,800 references are extracted, of which roughly 92 % resolve automatically to a target provision. Citations that point outside the corpus (case law, Official Journal, EPC 1973) are kept separately. My own typed links (“implemented by”, “exception to”, “case law”) sit on top of this graph in user.db.

Anchoring a note to a passage

Text is stored as plain strings plus a list of formatting spans, with offsets in UTF-16 code units so they match the browser exactly. A highlight is anchored twice, by position and by quotation, the same idea as the W3C Web Annotation selectors:

{
  "field": "lead", "start": 122, "end": 176,
  "exact": "extends beyond the content of the application as filed",
  "prefix": "t contains subject-matter which ",
  "suffix": "."
}

When a new edition shifts the text, a re-anchoring pass uses the quotation and its context to find the passage again. Anything it cannot place with confidence lands in a review queue instead of being silently moved; notes on provisions that disappear are marked orphaned, never deleted.

Search and editions

Full-text search is SQLite FTS5 (Porter stemming, Unicode tokeniser) over provisions, my notes and case law, with a citation-aware parser in front of it, so typing EPC:A52 jumps straight to the provision. Only the current edition is indexed. Older editions stay in the database in full; a precomputed change index plus a token-level diff produces the red/green comparison view.

Print

The exam edition is a dedicated HTML template paginated by Paged.js in headless Chromium, in two passes: the first records on which page every provision lands, the second fills in the cross-references with real page numbers. Large volumes are rendered in chunks to fit a small server’s memory and merged with pdf-lib.

Running it

It ships as a Docker image built by GitHub Actions and deployed to a small Swiss VPS behind a single-user login. The server’s user.db and page folder are the source of truth for my notes; the legal database is pushed separately whenever the pipeline changes. Behind it: over 200 unit test files (Vitest) and a Playwright end-to-end test for the reader.


Built with: Next.js, TypeScript, SQLite, Playwright, Paged.js, Docker.