ESTÚDIO 68

PTENES

How do you follow public money with a graph database?

By Maria Alice Maia · · video, 38 min · Read in Portuguese

Short answer

By joining dozens of public datasets in a graph database, where each entity is a node and each relationship is a link. Instead of joining tables, the system walks from tax to budget, to the amendment, to the executing body and to the supplier. The graph in the video has more than 1.35 million entities and produced 80 case files for human review.

Key takeaways

For decision-makers

To track money or customers in an organization, what matters is the link between records, not the isolated number. A graph with source labels and human review allows prioritization with traceability.

Why is looking at each public dataset in isolation misleading?

The video opens a three-part series about a system that reads public spending using only open data. The datasets include electoral data from the TSE, parliamentary amendments, transfer agreements, contracts, sanctions on companies, civil servants and financial sector datasets.

Looked at one by one, these datasets seem to say nothing. Linked together, they form a picture: tax becomes budget, budget becomes an amendment, the amendment becomes a contract. The video cites the emendas Pix as an example of funds sent without proper accountability.

The tool, called Rastro, does four things in order. It joins the datasets in a graph, scores anomalous cases with a trained algorithm, passes the cases through a funnel and produces case files for human review. The content has already been sent to state and federal Public Prosecutor's Offices.

What is the difference between a table database and a graph database?

A table database stores lists, such as companies, payments and partners. To find out who links a company to a politician, you need to join table after table, and each step gets slower and more fragile.

A graph database stores entities as nodes and relationships as edges. To find out who links to whom, you just walk along the links, like on a subway map where each station is a company, a payment or an amendment.

For security, everything runs locally, without the cloud, with encrypted data. The data is compressed in Parquet format, between 50 and almost 100 GB, and read with DuckDB. The links live in the graph database, and relational databases appear only at the periphery.

What patterns does the graph help find?

The central pattern is the circle. Money leaves an amendment, passes through an executing body, reaches a supplier and comes back as a donation to the campaign of whoever directed the amendment. The video stresses that this is not proof and may be a coincidence.

Other signals include a company opened three days before receiving 5 million as its first payment and the same owner on both sides of a transaction. Some of these signals are deterministic and serve as a first filter. The list, the weights and the cutoffs are not disclosed for security reasons.

An isolated entity says nothing. The picture lies in the group, such as entities that receive split amounts on close dates. In a demonstration, Rastro traversed 147 nodes with 236 links and found 23 paths tied to 17 distinct authors, with identities masked.

How do you ensure the map does not invent money?

Each link gets a label with the data source, the rule that created it, the signal's confidence, the creation run and a fingerprint that identifies the edge.

With this, all the money that entered the map was totaled and compared with the direct total from the official source. The difference was 0.00%. The map neither loses nor invents money along the way, and this supports confidence in what comes next.

The sieve starts from about 11 thousand pairs with some signal, goes through deterministic rules and machine learning, reaches 2 thousand scored executing bodies and ends with 80 case files. Of the referrals sent, about 60, very few were dismissed, one of them due to the statute of limitations.

What does the data show about elected officials?

Among authors of federal amendments who could appear in the graph, 15% of those elected or reelected had some anomalous link. Among those not elected, 12%. Among those who did not run, 2%. Those who run and get elected appear almost six times more often than those who do not run.

The video does not disclose names. Having fewer case files is not a certificate of honesty, it only indicates less signal. The proposed reading is that open data only becomes citizenship when there is a bridge to read it, and that a thousand spreadsheets without cross-referencing are window-dressing transparency.

The main product is the method. A graph that links datasets that do not talk to each other, a model that prioritizes and a human in the loop also work for health, public procurement and tracking customers within an organization.

Key concepts

Graph database
A database that stores entities and the links between them, ideal for questions about paths and connections.
Node and edge
A node is an entity, such as a company or a legislator. An edge is the link between two entities, such as paid or donated.
Parquet
A file format that compresses large volumes of data for efficient storage and reading.
DuckDB
A database that fits in a single file, used in the project to read the compressed data.
Deterministic signal
A simple yes or no rule, such as a company opened shortly before being paid, used as a first filter before the probabilistic model.

FAQ

Is public spending data in Brazil really open?

Yes. According to the video, the data has been public since 2004, when the government launched the Portal da Transparência, and in 2009 publication became law for municipalities, states and the federal government. The problem is that each agency publishes its part in a different place and format, which makes cross-referencing hard.

When is a graph database not the best choice?

For simple calculations, such as sums and averages, a graph database gets in the way. It works well for problems where the value of the discovery lies in the connection between entities, such as following the path of public money. That is why the project keeps some relational databases at the periphery of the architecture, alongside the main graph.

Why does the system run on a local computer and not in the cloud?

For data security. The project handles many CPFs and relationships with serious implications, since they support referrals to the Public Prosecutor's Office. Even running locally, the data stays encrypted and compressed in Parquet format, and is read with DuckDB, without passing through cloud servers.

Does an anomalous link in the graph prove corruption?

No. The case file indicates an anomaly, a possible lead, not proof of a crime. The tool can make mistakes, for example confusing people with similar names. That is why there is human review before anything is sent, and it is the Public Prosecutor's Office that decides whether to investigate or dismiss.

Translated text based on the transcript of the video, which is in Portuguese. The full reasoning and caveats are in the video.

Get new content in English

One email when a new guide, analysis or course comes out.