Ontology first, hexagon second: how I engineered two research sites
I run two research sites from a server in my house. One is public: the Vital Records Index, which reads 80 printed volumes of colonial Massachusetts town records into one searchable index. The other is private: my family’s genealogy research, about 4,300 people, each relationship graded by what the records actually prove.
They share an engine and, more importantly, two design decisions I would make again on any system that has to last:
- Ontology first. Write down what the data means, as a formal vocabulary and a set of rules it must satisfy, before writing the code that handles it.
- Hexagon second. Build the code as a core that knows nothing about files, formats or databases, and talks to all of them through ports.
I built both with an AI pair, Claude, doing a lot of the reading and typing. That turned out to be the strongest argument for both decisions, and I’ll come back to it.
The problem: conclusions without evidence
A family tree is a set of conclusions: this woman was that man’s daughter. What it usually lacks is the evidence. Most online trees copy each other, so one bad guess from 1950 shows up in a thousand trees, and none of them can tell you why they believe it.
Genealogists already have a rigorous method for this. The problem was a data model that couldn’t hold it. Software that stores “born 1729” in a field can’t tell you which record said so, whether the clerk wrote it in the Old Style calendar, or who decided it applied to this person and on what reasoning.
So I started with the model, not the code.
Ontology first
The ontology rests on a few principles that turned out to matter more than any line of Go:
- Evidence and conclusion are separate. A record says something (an assertion). A researcher decides something (a conclusion). Both are stored and linked, never merged into one field.
- Provenance on every statement. Each assertion and conclusion records who made it, when, in which research session, from which citation, and why.
- Stable identity. Every entity gets a permanent id. The family-tree program’s record numbers and FamilySearch ids are external identifiers mapped to it, never the key.
- Append, then supersede. A correction is a new conclusion that supersedes an older one. Nothing is overwritten in place.
RDF is a natural fit. Every fact is a triple (subject, predicate, object), and a fourth field can name the graph a triple belongs to. Putting everything from one research session in its own named graph gives you provenance for free. Here is one real chain, shortened: an obituary names a woman’s brothers, which supports a conclusion about her parents.
<urn:gx:ses_2026-10-18> {
<urn:gx:cit_pirkey36> a ellis:Citation ;
ellis:locator "Dandridge Banner, late March 1936, image 491" ;
ellis:quote "four brothers, Ben, R. A., Don and Rev. A. J. Lockhart" .
<urn:gx:asr_sibs36> a ellis:Assertion ;
ellis:citation <urn:gx:cit_pirkey36> ;
ellis:informationType ellis:Secondary .
<urn:gx:con_lockhart_parents> a ellis:Conclusion ;
ellis:grade ellis:Probable ;
ellis:indirectEvidence <urn:gx:asr_sibs36>, <urn:gx:asr_census1870> ;
ellis:reasoning "Ben, Rankin and Margaret are her siblings in the 1870 household" ;
prov:wasAttributedTo <urn:gx:agt_claude> .
}
I reused published vocabularies where they existed: W3C PROV-O for provenance, Dublin Core for works, GEDCOM X terms for people and facts. I invented terms only where nothing existed: personas, assertions, conclusions, grades.
SHACL is the contract
The vocabulary says what things are. SHACL shapes say what must be true. A few of the rules:
- Every conclusion above “unproven” has reasoning text and at least one assertion.
- Every assertion has exactly one citation.
- Every citation has a source, a locator and an accessed date.
- A confirmed parent-child link needs a direct statement, or two independent indirect ones.
- Ids are unique across the whole store.
The engine validates every write against the shapes before it lands. The RDF store I chose for serving, Oxigraph, has no SHACL engine, so the application is the validator: nothing reaches the store except through it. After every change, four checks run: structure, SHACL, RDF consistency, and a citation-style audit that must report zero problems.
JSON-LD in git, RDF at the edge
The research store is JSON-LD: ordinary JSON with a context that maps every key to an RDF term. That gave me the best of both:
- Today, the store is plain files in git. Every change is a reviewable diff with a commit message, and history is free.
- At build time, the same files become RDF quads (about 400,000 of them), loaded into a read-only Oxigraph instance. The private site is generated entirely from SPARQL queries against it.
Choosing JSON-LD meant I never had to pick between “files I can review” and “a graph I can query”. The ontology made both views of the same data.
Hexagon second
The engine is Go, built as a hexagon: ports and adapters. The rule is simple and enforced by the import graph: the core imports nothing from the adapters.
core/ the hexagon
domain/ dates, places, historical jurisdictions
research/ the evidence model
ontology/ JSON-LD context and SHACL shapes (embedded)
ports/ TreeEditor, TreeStore, MediaStore, RuleEngine ...
usecases/engine/ the build: research sessions -> tree edits
adapters/
inbound/cli/ the command line (composition root)
outbound/gedcom/ GEDCOM 5.5.1 and 7, lossless
outbound/jsonld/ the research store
outbound/oxigraph/ SHACL validator, N-Quads
outbound/cel/ rules in YAML, compiled from CEL
Four ports carry everything:
| Port | Direction | What it does | Adapter today |
|---|---|---|---|
| Research API | into the core | add, grade, link, supersede; queries | the CLI |
| Evidence store | out of the core | load and save entities with provenance | JSON-LD files in git |
| Tree exchange | out of the core | read and write a family tree | GEDCOM 5.5.1 and 7 |
| Record source | out of the core | search records, fetch images | archives, local scans |
What this bought me in practice:
- Lossless round trips. The GEDCOM adapter keeps every line’s original text until something edits it, so untouched records come out byte for byte. Every build re-imports its own output and must report it identical.
- Judgement as data. Every judgement call the engine makes is a named rule in YAML, evaluated through a
RuleEngineport. The change log names the rule behind every edit. - Cheap change. A new GEDCOM version, or a new store, is one adapter package and its tests. The core doesn’t move.
- Reproducible builds. A build applies every research session, in order, to a clean export of the tree. Run it twice and you get the same tree.
The second site: same pattern, different data
The Vital Records Index reuses the pattern on a different problem. The parser reads scanned, OCR’d town records (“ADAMS, John, s. Peter and Rachel, …”) into RDF nodes with their own vocabulary and shapes. Three details came straight from the ontology-first habit:
- Dates are kept as the clerk wrote them. Before 1752 the legal year began on 25 March, and some towns numbered months from March. Each record carries the date as written, the dual-dated form (“23 Jan 1657/58”), and the Gregorian date.
- One named graph per layer. The printed text, the parsed records and the reconstructed families live in separate graphs, so you can always tell what the book says from what the software inferred.
- Verifications are tests. When a record is checked against its page image, the reading goes into a file, and every build confirms the index still reads it the same way. An OCR fix that breaks a verified record fails the build.
How it runs
Both sites run on one small home server:
- Each service is a rootless Podman container, managed as a systemd unit.
- The SPARQL store runs read-only.
- Each site is published through its own Cloudflare Tunnel, with no open ports on the house’s network.
- The private site signs in with passkeys.
- The public containers are built from scratch images: one Go binary, no shell, running as an unprivileged user.
Why this matters more with an AI pair
I built most of this with Claude as a pair programmer and research assistant. It reads records, drafts entries, writes Go and runs the builds. That is a lot of throughput, and throughput without guardrails is how bad data spreads.
The ontology and the shapes are the guardrails. The assistant cannot hand-edit the store; every change goes through the engine, which validates it against the shapes and records the session, the citation and the reasoning. If an entry doesn’t validate, it doesn’t land. When the assistant gets something wrong, and it does, the provenance shows exactly what it decided and why, and a correction supersedes it without erasing the history.
The hexagon matters for the same reason. A clear core with narrow ports gives an AI pair (or a new engineer) a small, well-defined surface to change, and the import rule keeps it from quietly coupling the domain to a file format.
What carries over
None of this is specific to genealogy. Any modernization of an old system faces the same three questions, and these two decisions answer them:
- What does the data mean? Write it down formally before you move it. An ontology and its constraints outlive every system that touches the data, including the one you’re replacing.
- Where are the seams? A hexagonal core is a migration seam: swap the adapter for the old platform for the adapter to the new one, and the business logic doesn’t move.
- How do you know it’s still right? Validate at the boundary, keep provenance on every change, and make round trips prove themselves on every build.
Old records, modern systems, and nothing taken on faith. That’s the bridge I like to build.