Aller au contenu
SectionsOverview

Outil de recherche · En ligne

Hunter

Hunter maps ownership, political mandates and Swiss federal contracts from public sources into one graph that anyone can search.

Cette documentation technique est disponible uniquement en anglais.

Overview

Hunter answers one question. How is this company, person or federal supplier connected to the others? It combines Wikidata, Lobbywatch, Swiss federal procurement records, SEC filings and reviewed research into one graph.

The live site is read-only. It serves a JSON export of the database, so public requests never reach Postgres.

What you can do with it

  • Search the 7,027 entities in the graph by name.
  • Open a network around one entity, or view its ownership as a hierarchy or on a world map.
  • Ask for the shortest connections between two entities.
  • Compare the graph at two dates to see which links appeared or ended.
  • Read the politician mandates and the federal contracts tied to an organization.
  • Check the source of each claim, and report an error through a prepared email to info@neano.ch.

Sources

Source Provides Licence or status
Wikidata Companies, people, ownership, parents, founders CC0
Lobbywatch Swiss politicians, mandates, pay status Public export
Swiss federal contracts Awards over CHF 50,000 in 2025 Published by the Confederation
SEC EDGAR Filings and XBRL company facts US public record
World Bank Reserves and country finance figures Open data
UN Comtrade Trade flows from the public preview Public preview
Reviewed research Hand-checked company claims with citations Neano

How the data reaches the browser

From public sources to the browser

Public sources feed Neon Postgres. A build step exports JSON, which Cloudflare Pages serves to the browser as a static app and a read-only API.

Sources

  • Wikidata
  • Lobbywatch
  • Contracts
  • SEC EDGAR
  • World Bank
  • UN Comtrade

Storage

  • Neon Postgresentities, edges, mandates, contracts

Build

  • data:exportfolds aliases, writes JSON
  • Vite buildSolid app

Hosting

  • Static appCloudflare Pages
  • /api/*read-only Pages Function

Client

  • Browser

The database is only used at build time. No database credential exists at runtime.

Database size

Rows per Postgres table
  • entities13,945
  • edges10,955
  • contracts9,603
  • mandates3,527
  • org_supplier_links45
  • entity_aliases13
  • datasets3

Architecture

Hunter is a static Solid app with one read-only Cloudflare Pages Function. Postgres is used at build time only.

Hunter separates writing data from serving it. Ingestion scripts write to Neon Postgres. A build step turns the database into JSON files. The public site reads only those files.

Runtime path

What happens on a request

The browser loads a static Solid app and calls a read-only Pages Function. The function queries an in-memory index built from bundled graph JSON and fetches profile facts from Wikidata and Commons.

Browser

  • Solid appcanvas, globe, profiles
  • Hash routeshareable view state

Edge

  • Static assetsCloudflare Pages
  • /api/*read-only Pages Function

Engine

  • KnowledgeQueriesfilters, paths, summaries
  • Adjacency mapbuilt once per instance

Data

  • graph.jsonbundled with the function
  • Wikidata and Commonsprofile facts and images

Postgres does not appear on this path.

Stack

Layer Technology
Interface Solid 1.9, Vite, Tailwind 4, lucide-solid
Graph rendering Sigma 3, graphology, ForceAtlas2 in a web worker, square node program
API Cloudflare Pages Function in TypeScript
Storage Neon Postgres 18 with pg_trgm
Scripts Node 24 or later running TypeScript directly, pg as a development dependency
Hosting Cloudflare Pages

Why the database stays out of the request path

The graph changes when a person or a data refresh changes it, not on each visit. Serving a build artifact gives three properties.

  • No database credential exists in the browser or the function.
  • Public traffic cannot add database load or compute cost.
  • A deployed version is a fixed snapshot, so one link keeps showing one state of the data until the next build.

The function responds with Cache-Control: public, max-age=60. A bad query returns status 400 with a JSON error.

Code layout

Path Role
functions/api/[[path]].ts Pages Function that bundles the graph and calls the engine
server/queries.ts KnowledgeQueries, the filter, summary and path logic
server/entity-info.ts Server-side Wikidata and Commons lookups
src/components/ Explorer shell, canvas, world, hierarchy and profile views
src/lib/explorer-state.ts URL codec, request cancellation, bounded caches
src/lib/publish.ts Folds aliases and shapes each exported file
scripts/ Ingestion, migration and export commands
db/migrations/ Plain SQL schema migrations
data/research/ Reviewed research files

Browser security

The site sends these response headers on every page.

Header Value
Strict-Transport-Security One year
X-Frame-Options DENY
X-Content-Type-Options nosniff
Referrer-Policy strict-origin-when-cross-origin
Permissions-Policy Denies camera, microphone, geolocation, payment and USB

The Content-Security-Policy starts from default-src 'self'.

Directive Allows
script-src Same origin only
style-src Same origin and inline styles
img-src Same origin, data:, blob: and two Wikimedia image hosts
connect-src Same origin only
worker-src Same origin and blob:, needed by the graph layout worker
object-src None
frame-ancestors None

Data model

Seven Postgres tables hold every entity, sourced claim, mandate and contract. Reviewed merges are stored as reversible aliases.

The schema keeps one row per source entity and treats every relationship as a claim with its own evidence. Merging two records never edits them.

Tables

Postgres schema

Arrows point to the referenced table. All references cascade on delete. A separate schema_migrations table records applied migrations.

Rows per table
  • entities13,945
  • edges10,955
  • contracts9,603
  • mandates3,527
  • org_supplier_links45
  • entity_aliases13
  • datasets3

Entities

Every person and organization from every source has one row. The unique pair (source, source_id) stops a re-run from adding copies. Source-specific fields sit in the attrs JSONB column so a new source does not need a schema change. A GIN trigram index on name supports fuzzy matching when looking for the same entity under different names.

The published graph has 7,027 nodes because it does not include every entity row. Lobbywatch and contract records are exported through their own files.

Edges are claims

One pair of entities can hold several sourced claims, for example direct and ultimate ownership. The original unique key on (from_id, to_id, relation) was removed for that reason. A unique position now identifies each claim instead.

Column Meaning
relation, property Hunter’s relation type and the source property
start_date, end_date YYYY, YYYY-MM or YYYY-MM-DD, enforced by a check constraint
share Ownership percentage when the source gives one
credits, role Film credits and the role held
refs Citations for the claim
research Reviewed evidence, including the disclosure date

Dates are text because sources often state only a year or a month. Converting them to full dates would invent precision.

Swiss tables

mandates links a politician to an organization, with a role, a pay status of unknown, unpaid or member, and the source URL. contracts records a federal award by supplier, department, unit, subject and amount in CHF, with a procedure of open, selective, invitation or direct.

org_supplier_links holds 45 matches between Lobbywatch organizations and contract suppliers. Each row states whether the match used name and city, or the name only, so the interface can show how strong it is.

Alias folding

Different sources often describe the same organization. Hunter stores a reviewed decision in entity_aliases and applies it during export.

How a merge reaches the public files

Two source entities stay in the database. An alias row points one at the other. The export resolves all references to the canonical entity and omits the alias from the published files.

Stored

  • Alias entityrow stays unchanged
  • Canonical entityrow stays unchanged

Decision

  • entity_aliasesalias_id points to canonical_id, with a note

Export

  • publish.ts resolverrewrites edges, mandates, contracts and links

Published

  • One entityalias omitted, its claims attached to the canonical

Deleting the alias row and exporting again restores the two separate entities.

Thirteen reviewed merges are active. That is why the database has 4,180 supplier entities and the published data has 4,167.

Data pipeline

Scripts fetch public sources, load them into Postgres and export the JSON files the site serves.

Each data source has one script. Scripts that feed the graph write to Postgres. Two aggregate scripts write small JSON files straight to the repository.

Flow

From source to published file

Wikidata, Lobbywatch and federal contracts and reviewed research load into Postgres. The export writes graph, Swiss and contract JSON. Finance and trade scripts write money and resources JSON directly.

Fetch

  • fetch-dataWikidata SPARQL
  • fetch-swissLobbywatch, contracts
  • enrich-companiesreviewed research
  • fetch-financeSEC, World Bank
  • fetch-tradeUN Comtrade

Store

  • Neon Postgresgraph and Swiss data
  • Repository JSONmoney, resources, world

Export

  • data:exportpublish.ts folds aliases, then writes each file

Files

  • graph.json
  • swiss.json
  • contracts.json
  • world.json
  • money.json
  • resources.json

Graph, Swiss and contract files are generated at build time and are not stored in Git.

Commands

Command Effect
npm run db:migrate Applies pending SQL migrations and records them in schema_migrations
npm run data Fetches Wikidata, then runs the research step
npm run data:research Exports, applies reviewed research, exports again
npm run data:swiss Fetches Lobbywatch and federal contracts, then exports
npm run data:finance Builds money.json and finance claims
npm run data:trade Builds resources.json
npm run data:export Writes the three generated JSON files from Postgres

Sources in detail

Wikidata. A set of SPARQL queries collects companies, states, people and ownership claims. Responses are cached on disk during a run.

Lobbywatch and federal contracts. The Swiss script reads the Lobbywatch export and the 2025 spreadsheet of federal contracts over CHF 50,000. It groups rows by supplier and matches organizations to suppliers by name and city, or by name alone.

Reviewed research. Files in data/research hold company claims that a person checked against filings, including authors, Nestle and SEC-registered companies. enrich-companies merges them into the graph with their evidence.

Finance and trade. The finance script uses SEC submissions and XBRL facts along with World Bank reserves. The trade script uses the UN Comtrade public preview. The world basemap comes from Natural Earth.

Published files

Size of each published file
  • graph.json6,100 KB
  • contracts.json1,860 KB
  • swiss.json495 KB
  • world.json254 KB
  • money.json15 KB
  • resources.json3 KB

Rounded sizes before compression.

Measure Published value
Graph nodes 7,027
Graph edges 10,955
Politicians 246
Suppliers 4,167
Contract value CHF 6,095,254,009.83

Evidence rules

  • A claim keeps its citations in refs and its reviewed evidence in research.
  • A missing date stays unknown. It is not read as “always true”.
  • A disclosure’s as-of date shows when a source reported a holding. It does not prove the holding existed earlier.
  • Name-only matches between organizations and suppliers are labelled as name-only.

Graph engine and API

A read-only query engine runs inside the Pages Function, with validated filters, bounded path search and JSON endpoints.

KnowledgeQueries loads the bundled graph and answers every API call from memory. Its adjacency map is built once per function instance, so traversal does not scan the full edge list.

Filters

Most endpoints accept the same query parameters.

Parameter Effect
relations Limits results to the listed relation types
cited=1 Keeps only claims with a citation
past=1 Includes links that have ended
date=YYYY-MM-DD Shows the graph at one date

The date must be a real calendar date, or the request returns status 400. An edge is excluded only when its known dates rule it out. Edges with missing dates stay in the result and are counted as unknown in date comparisons.

The path finder answers “how are A and B connected?” within fixed work limits.

Finding connections between two entities

The request is validated, then a breadth-first search runs over filtered edges within budgets. It finds up to three paths by excluding single edges and reports whether limits were reached.

Input

  • from, to, depthdepth defaults to 4, clamped from 1 to 6

Filter

  • Adjacency maponly edges that pass the active filters

Search

  • Breadth-first searchshortest path first
  • Single-edge exclusionsbounded retries for other paths

Budget

  • 30,000visited nodes
  • 200,000edge checks
  • 3paths returned at most

Output

  • Paths and limited flaglimited means the search stopped at a budget

Each edge can be walked in either direction. The result keeps its original direction, so the claim reads as the source stated it.

When a budget runs out, the response sets limited. The interface can then say that no path was found within the limit, which differs from saying none exists.

Endpoints

All endpoints use GET under /api/ and return JSON.

Endpoint Parameters Returns
search q Up to 8 matching entities, query cut to 120 characters
summary filters, country Totals for the current view
graph filters A bounded network snapshot and a truncated flag
entity id, offset, sector, limit One entity with a page of up to 30 claims
paths from, to, depth Up to 3 connecting paths
changes date, compare Links added and removed between two dates
globe filters, focus, country, offset, all Country-level connections
headquarters id Headquarters details
financials id Official financial rows
ownership id, filters Owners at a date, up to 1,000 claims, with the total
hollywood cited The film industry study
about id Profile facts, image and sources

Limits

Limit Value
Canvas nodes 120
Canvas edges 240
Evidence page 30 claims
Ownership page 1,000 claims
Path depth 6

Responses that hit a limit say so through truncated, limited or a total field.

Comparing two dates

changes builds a snapshot for each date and compares their edges. It returns added, removed, the count of edges with incomplete dates and whether either snapshot was truncated.

Entity profiles

about combines reviewed facts with Wikidata statements and a Commons image. For research entities it uses the SEC identifier to find the matching Wikidata item. If the public lookup fails, the response still returns the reviewed facts.

Interface

The explorer offers network, hierarchy and world views over one URL-encoded state, with evidence beside every claim.

The interface is one Solid application. An explorer shell owns the state and passes it to whichever view is open.

Structure

Explorer structure

The URL hash defines the state. The explorer shell renders network, hierarchy or world modes and profile, about, collections or saved views, and requests data from the API with cancellation and bounded caches.

URL state

  • focusselected entity
  • modenetwork, hierarchy, world
  • viewprofile, about, more
  • filtersrelations, cited, date

Shell

  • Explorerdecodes the URL and owns selection

Modes

  • NetworkCanvasSigma and ForceAtlas2
  • Hierarchyowners and parents
  • Worldmap and globe

Panels

  • EntityProfilefacts, financials
  • Evidencepages of 30 claims
  • Collectionscurated lists
  • Saveddevice only

Data

  • API clientstale requests cancelled, caches bounded

Saved items stay on the device. Nothing about a visitor is sent to a server.

Views

Network. Sigma 3 draws the graph on WebGL. ForceAtlas2 computes the layout in a web worker, so the page stays responsive. The canvas shows at most 120 nodes and 240 edges.

Hierarchy. This view walks parent, owner and owns claims to show who controls an entity.

World. Connections are shown by country on a map and on the home globe, using a Natural Earth basemap.

Profile. A profile combines the description, an image, official financial figures, the ownership chart, mandates and federal contracts.

URL state

src/lib/explorer-state.ts encodes the whole view in the hash, for example #focus=Q312&mode=network. A copied link opens the same entity, mode and filters.

Key Values
focus Entity ID
mode network, hierarchy, world
view explore, connections, profile, about, collections, saved
limit Node limit, clamped from 12 to 120
hidden Up to 120 entity IDs removed from the canvas

The codec validates each value, so a malformed link falls back to defaults.

Requests

Changing focus cancels the previous request, so a slow response cannot overwrite a newer one. Responses are held in caches with fixed size limits.

Evidence

Every claim can open its citations. Claims from reviewed research also show the as-of date of their disclosure. The filter cited=1 hides anything without a citation.

Operations

How Hunter is tested, built from Postgres and deployed to Cloudflare Pages.

A push to main rebuilds the site from the current database. Pull requests go through the same export and build, then receive a preview deployment.

Build and deploy

Pipelines

A pull request exports data, runs format, lint, tests and build, then deploys a preview. A push to main or a manual run exports data, builds and deploys production.

Pull request

  • Export
  • Format, lint
  • Tests
  • Build
  • PreviewCloudflare Pages

Main

  • Export
  • Build
  • ProductionCloudflare Pages

Both pipelines run on a self-hosted runner. Credentials are passed only to the export and deploy steps.

Changing data needs no code change. Update Postgres and run the deploy workflow by hand, and the site publishes the new export.

Schema changes

Migrations are plain SQL files in db/migrations, applied in name order by npm run db:migrate. Each one is recorded in schema_migrations.

Migration Change
0001_init Creates the tables, indexes and pg_trgm
0002_edge_claims Allows several claims per pair, adds research, stores partial dates as text

Quality checks

Check Command
Format npm run format:check
Lint npm run lint
Tests npm test
Build npm run build

About 151 tests in 30 files cover the query engine, alias folding, URL state, filters and interface components.

Storage cost

Generated files in each deploy
  • graph.json6,100 KB
  • contracts.json1,860 KB
  • swiss.json495 KB

These three files are written at build time and stay out of Git.

Keeping generated data out of Git means the repository does not grow on each refresh.

Adding a data source

  1. Add a fetch script that stores rows under a new source value.
  2. Put source-specific fields in attrs, and add a migration only for a new relationship shape.
  3. Extend publish.ts if the source needs a new published field.
  4. Add a test for the shaping logic.
  5. Run npm run data:export, check the result, then deploy.

Reviewing merges

To merge two records, review the pair and insert one row in entity_aliases with a note. To undo a merge, delete the row. The next export applies either change.