DEV Community

Johan
Johan

Posted on

How I Modeled 13,000 Political Entities into 86,000 Searchable Pages

Most political information online lives in flat pages.

A country article.
A politician bio.
A party overview.
An election page.

That works for facts, but it breaks down when people want to understand how power actually moves.

Who appoints whom?
How do coalition partners connect?
What office inherits power during a resignation?
How do institutions interact during a constitutional crisis?

Those are graph problems.

So I started building PoliticaHub, a global political knowledge graph designed to map countries, politicians, parties, offices, institutions, and elections as connected entities rather than isolated articles.

Today the graph models 13,000+ political entities and powers 86,000 searchable pages.

Why politics naturally becomes a graph

Politics is almost never about standalone facts.

A president is connected to:

country
office
predecessor and successor
party
election
legislature
cabinet
constitutional powers

A legislature is connected to:

chambers
governing coalition
opposition blocs
party seat distributions
electoral systems
confidence rules

A single relationship can unlock multiple ways to understand the same system.

That means one clean graph layer can power:

country dashboards
office timelines
election hubs
coalition scenarios
compare pages
institutional explainers
succession chains

Instead of manually writing thousands of disconnected pages, the graph creates reusable political structure.

The Firestore model

I’m using Firestore as the main data layer.

The core collections are intentionally simple:

entities
relationships
entity_metadata
office_terms

Each entity has a type:

country
politician
party
office
institution
election

The real power comes from typed relationships:

holds_office
member_of
governs
succeeded_by
coalition_with
participated_in
reports_to

Pages are generated by traversing those relationships.

A country page, for example, can resolve:

current leadership
current government
party ecosystem
legislature structure
next election
recent office transitions
constitutional system

without hardcoding country-specific logic.

That abstraction layer is what allowed the page count to scale.

How the graph became 86,000 pages

The interesting part is that the site was never designed around “let’s make thousands of SEO pages.”

The page explosion came naturally from the relationships.

Once the graph stabilized, each entity and relationship family started creating its own route surfaces:

/country/[slug]
/politician/[slug]
/party/[slug]
/office/[slug]
/election/[slug]
compare pages
system explainers
derived leadership pages
historical office term pages

The result is now 86,000+ searchable pages, but each page is rooted in real graph truth rather than thin templates.

That distinction matters a lot.

At scale, the only sustainable SEO is relationship-backed usefulness.

The hardest problem: time-aware truth

The hardest problem wasn’t scale.

It was time.

Political facts expire constantly:

elections happen
cabinets reshuffle
coalitions collapse
resignations happen overnight
legislatures dissolve
succession rules activate instantly

“Person X is prime minister” is only true for a bounded period.

That’s why office_terms became critical.

Once terms became time-aware, the graph unlocked:

leadership timelines
succession after crises
historical governments
office overlap with elections
“who was in power during X”
coalition memory

That temporal truth layer is probably the strongest long-term moat in the system.

Biggest engineering lesson

The biggest thing I’ve learned is this:

politics is easier to understand as connected state than as articles.

Editorial writing still matters, but the graph makes the writing structurally smarter.

Instead of explaining isolated facts, pages can explain how power flows through institutions over time.

That’s the real goal.

If you want to see the live graph in action, it’s here:

https://politicahub.com

Would love feedback from anyone working in civic tech, graph systems, Firestore, or large-scale SEO architectures.

Top comments (0)