Inspiration

A Spanish-language tech newsroom publishes dozens of stories a day, and its most valuable asset — its own archive — is the hardest thing to search. Before a new article goes out, an editor (or an AI agent drafting it) needs answers keyword search gives badly: Have we already told this story? Which of our articles share topics, people or sources with this one? What have we published about this person, and which sources did we rely on? Contexto Geek stores the archive as a connected graph in Relate, so those questions become simple graph traversals with the reasoning attached.

What it does

Contexto Geek models a newsroom's published archive as a graph: every Article is linked to the Topics it covers, the People and Organizations it mentions, and the Sources it cites. The command-line tool (src/contexto.py) gives an editor or an AI agent these commands:

  • init — create or reset the persistent graph store.
  • ingest — load articles from a JSON file (idempotent: re-ingesting updates instead of duplicating; shared topics, people, organizations and sources are deduplicated with MERGE).
  • related — the pre-publish context check: every article connected to a given one, ranked by how many connections they share, with the exact connections named.
  • dossier — everything the newsroom has on a person or organization: their articles, the topics covered, and the sources relied on.
  • links — internal-link suggestions for an article, ranked by shared connections.
  • stats — node and relationship counts by type. The sample graph ships with 15 articles, 45 nodes and 68 relationships, with dense overlaps (OpenAI in 4 articles, Microsoft in 4, one source cited in 3) so every query returns meaningful, inspectable results.

How we built it

Contexto Geek is a single-file Python CLI built on Relate (relate-db 1.2.0, imported as relate). The whole graph lives in one persistent .rl file (data/newsroom.rl, committed to the repository) — Relate runs embedded in the Python process, so queries execute in-process with Cypher, with no server to deploy, no network calls and no signup. That portability is deliberate: a judge can clone the repo, open the same file, and inspect the exact graph the demo queries. All queries are parameterized Cypher (db.execute(cypher, {...})), never string-built. Ingest is per-article idempotent: MERGE the article node, SET its properties, delete and recreate its outgoing COVERS / MENTIONS / CITES relationships. Read commands (related, dossier, links, stats) open the store read-only, which both respects Relate's single-writer design and doubles as a persistence proof between processes.

Challenges we ran into

  • Single-writer locking. Our first prototype reopened the store in the same process to check persistence and hit "storage locked" — Relate allows one writing process per store. The fix shaped the architecture: close before reopening, and make every read command open the store read-only.
  • Idempotency without duplicates. Loading the same news file twice had to update, not duplicate. Per-article MERGE plus relationship rebuilds made ingest safely repeatable (verified: a second ingest of the sample file reports 0 new, 15 updated, identical counts).
  • Making connections explain themselves. A list of "related articles" is not enough for an editor; every result carries why it appeared — the shared topics, people, organizations or sources, counted and named — so the agent's context is auditable, not a black box.

Accomplishments that we're proud of

  • A complete, working graph tool — not a mockup: ingest, query and dossier commands all run against a real persistent Relate store that ships inside the repo.
  • The pre-publish check an actual newsroom needs, answered in one command with its reasoning visible.
  • Zero infrastructure: one Python file, one .rl file, one pip install. The graph is inspectable by anyone with the repo.

What we learned

Graph questions are different from search questions. "What connects to this?" with the path named is worth more to an editor than ten keyword matches — and modeling the archive as articles, topics, people and sources made questions we hadn't planned (dossiers, link ranking) fall out of the same three relationship types for free. We also learned to respect the store's single-writer discipline instead of fighting it: read-only readers are a feature.

What's next for Contexto Geek

  • An MCP server wrapper so an AI writing agent can call related, dossier and links as tools while drafting.
  • Automatic ingest from the newsroom's WordPress archive (the two sites publish ~50 stories a day).
  • Entity extraction from article text, so topics, people and sources are proposed by the graph itself instead of typed by hand.

Built With

Share this project:

Updates

Submission history