Graph Sleuth
Building GraphSleuth: An Agentic Investigator for Connected Transaction Networks
Introduction
Financial transaction networks can be difficult to investigate because suspicious activity may not be visible in a single transaction. An account might receive funds from one account, transfer them to another, and form part of a much larger network of connected transactions.
This is where graph databases become useful.
For the WeMakeDevs × FalkorDB Graph Hacks hackathon, I built GraphSleuth, a graph-powered transaction investigation prototype using Python, Streamlit, and FalkorDB.
The goal was to explore how connected-data queries and explainable analysis can help investigators understand transaction relationships and identify accounts that may deserve further investigation.
What is GraphSleuth?
GraphSleuth is an interactive application that analyzes a synthetic transaction network.
Its main features include:
Multi-hop path discovery: Finds transaction paths connecting accounts through multiple transfers.
Heuristic risk ranking: Highlights accounts using explainable indicators derived from transaction-network activity.
Transaction evidence: Retrieves connected incoming and outgoing transfers for closer inspection.
Account investigation: Helps examine the role of accounts in connected transaction paths.
Intervention simulation: Provides a way to explore how excluding an account affects transaction paths, where supported by the running implementation.
Interactive dashboard: Presents the analysis through a Streamlit interface.
The project is designed as an investigative aid, not an automated fraud-detection authority. A high heuristic score is a reason to investigate, not proof of wrongdoing.
Why FalkorDB?
A conventional transaction table is useful for examining individual records, but following the relationships between multiple accounts can require increasingly complex queries.
A graph database models these relationships directly.
In GraphSleuth, the graph data model is simple:
Nodes:
Accountnodes represent accounts.Relationships: Directed
TRANSFERrelationships represent money transfers between accounts.Properties: Account identifiers and transfer details, such as amounts and timestamps, support investigation queries.
A simplified representation looks like this:
Account A → Account B → Account C
Instead of treating these as unrelated records, GraphSleuth can query the connected path and investigate the intermediate account.
FalkorDB is the graph database behind this workflow, while Python performs the analysis and Streamlit provides the user interface.
Discovering multi-hop transaction paths with Cypher
One of the central features of GraphSleuth is discovering paths that contain multiple transfers.
The following Cypher query searches for directed paths of two to four transfer relationships:
MATCH p = (source:Account)-[:TRANSFER*2..4]->(destination:Account)
WHERE source <> destination
RETURN [node IN nodes(p) | node.account_id] AS accounts,
length(p) AS hops
ORDER BY hops ASC
LIMIT 20
Here is what the query does:
Matches paths containing between two and four
TRANSFERrelationships.Excludes paths where the source and destination are the same account.
Returns the account identifiers along each path.
Calculates the number of transfer steps.
Orders results by path length and limits the output to twenty paths.
This makes it possible to inspect connected transaction flows without manually following each transfer record.
Examining chronological transaction flows
GraphSleuth also uses a more selective path query to retrieve transfer amounts and timestamps and check that the timestamps follow a non-decreasing order.
MATCH p = (source:Account)-[:TRANSFER*2..4]->(destination:Account)
WITH p,
[r IN relationships(p) | r.amount] AS amounts,
[r IN relationships(p) | r.timestamp] AS times
WHERE ALL(amount IN amounts WHERE amount IS NOT NULL)
AND ALL(
i IN range(0, size(times) - 2)
WHERE times[i] <= times[i + 1]
)
RETURN [n IN nodes(p) | n.account_id] AS accounts,
amounts,
times,
length(p) AS hops
ORDER BY hops DESC
LIMIT 20
This query requires transfer amounts to be present and checks that each timestamp is no earlier than the preceding timestamp. It then returns the account sequence, amounts, timestamps, and path length.
The result is a collection of candidate paths for investigation. It does not establish that a path is fraudulent or that the transfers represent a real-world crime.
From graph queries to an investigation workflow
GraphSleuth combines FalkorDB queries with Python-based analysis.
The application examines the discovered paths and counts how often accounts appear as intermediate nodes. An account that frequently appears between the beginning and end of candidate paths can be selected for closer inspection.
The application can then retrieve incoming and outgoing transfers associated with the selected account and calculate the corresponding totals.
These steps help provide context around an account's position in the network.
Importantly, incoming and outgoing totals describe the transactions returned by the relevant database queries. They should not automatically be interpreted as totals for a single suspicious path or as evidence of fraud.
Why explainability matters
A risk score without supporting evidence can be difficult to interpret.
GraphSleuth uses heuristic indicators to prioritize accounts for review. Its approach is intended to make the investigation easier to follow by connecting account rankings with graph paths and transaction evidence.
The prototype does not rely on an external LLM API to generate its findings. Its investigation workflow is based on deterministic Cypher queries and Python analysis.
This makes it possible to inspect the query logic and understand how the candidate paths and account rankings are produced.
Technology stack
The project uses:
FalkorDB: Graph storage and Cypher-based relationship queries.
Python: Path analysis, heuristic ranking, and transaction calculations.
Streamlit: Interactive application interface.
Docker: Local FalkorDB environment.
CSV: Synthetic transaction data for testing and demonstration.
The application can be run locally using the setup instructions in the project repository.
Limitations and future improvements
GraphSleuth is a hackathon prototype, and there are several opportunities to improve it.
Future work could include:
More sophisticated graph algorithms for identifying unusual network structures.
Configurable risk indicators and transparent explanations for each score.
Larger synthetic datasets for evaluating performance.
Automated tests for graph queries and investigation results.
More detailed audit trails for investigation decisions.
Carefully evaluated methods for comparing network changes under different intervention scenarios.
Any future risk model should be evaluated against appropriate test data before being used for consequential decisions.
What I learned
Building GraphSleuth gave me an opportunity to explore how graph databases can support an application where relationships are central to the problem.
The most important lesson was that the graph should do real work. FalkorDB is not just a place to store data or a way to draw a network: its queries are used to discover multi-hop paths, examine transfer sequences, and retrieve connected evidence.
Combining those queries with Python analysis and an interactive dashboard creates a practical starting point for exploring connected transaction networks.
Try GraphSleuth
GitHub repository: https://github.com/SamruddhiKoparde/Graph\_Sleuth
Demo video: https://youtu.be/5x-QltCpvt4?si=jb6pVaostrHq-c4g
GraphSleuth was built for the WeMakeDevs × FalkorDB Graph Hacks hackathon using synthetic transaction data.
AI assistance was used for development support and documentation. The project's code, queries, and architecture should be reviewed in the repository to understand the implementation.
The project is a prototype for investigative decision support. Its heuristic indicators are not proof of fraud, and its findings require human review.
Thanks for reading!
Comments
Join the discussionNo comments yet. Be the first to comment.
