DEV Community

mohinimhetre
mohinimhetre

Posted on

Building CaseGraph: An AI Investigation Agent Powered by a Knowledge Graph

CaseGraph: AI-Powered Criminal Investigation Using Graph Databases and FalkorDB

Introduction

Criminal cases rarely exist in isolation. A person involved in one investigation might be connected to another case registered at a different police station. Discovering these hidden connections across people, evidence, and events can be challenging when data is stored as isolated records.

During a hackathon hosted by wemakedevs, I built CaseGraph, an AI-powered graph knowledge base and criminal investigation agent that explores how graph databases can help solve this problem.

Built using FalkorDB, Angular, .NET, and an AI agent, CaseGraph focuses on relationship discovery, case timeline reconstruction, and cross-station case correlation.

The central idea is simple: instead of treating a criminal case as an isolated record, represent it as part of a connected network of people, cases, evidence, and events.

Why Graph Databases?

Consider two cases registered at different police stations. They may appear unrelated until an investigator discovers that they share a person, witness, or another relevant connection.

In a graph database, entities are represented as nodes, and their connections are represented as relationships.

For example:

(Person A) ── INVOLVED_IN ──> (Case 101)
     |
    KNOWS
     |
(Person B) ── INVOLVED_IN ──> (Case 205)
Enter fullscreen mode Exit fullscreen mode

This structure makes relationship traversal a natural operation. Instead of reconstructing connections through complex joins or application-level logic, we can query paths between entities directly.

This is why graph databases are a strong fit for investigative systems: the relationships between records are often as important as the records themselves.

Architecture: Station Graphs and a Common Department Graph

One of the key architectural decisions in CaseGraph was to maintain a separate graph for each police station and a shared Department graph.

  • Station graphs: Store station-specific investigative information, including cases, people, evidence, and events.
  • Department graph: Maintains the department hierarchy and a shared view of relevant case information and associated people across stations.

The station graphs support local investigations, while the Department graph provides the shared context needed to discover connections across station boundaries.

For example, if a person appears in cases registered at two different stations, querying the Department graph can reveal that connection even when the cases belong to separate station graphs.

This separation provides a logical boundary for local investigation while enabling department-wide relationship analysis. The application must, of course, maintain consistency between the station-level data and the shared graph.

Why FalkorDB?

I chose FalkorDB as the graph storage and query layer for CaseGraph because the core problem revolves around connected entities and multi-hop relationships.

FalkorDB lets the application represent investigative data as a graph and query connections using Cypher-style graph queries.

For example, a simplified relationship query could look like this:

MATCH path = (a:Person {id: $personA})
             -[*1..5]-
             (b:Person {id: $personB})
RETURN path
LIMIT 50
Enter fullscreen mode Exit fullscreen mode

This illustrates how the database can retrieve paths between two people without requiring the application to know every intermediate connection beforehand. Production queries would also need appropriate relationship filters, identity handling, and access controls.

FalkorDB provides the graph traversal capabilities; CaseGraph's application architecture determines how the data is organized and how those capabilities are used for investigation.

the image below is showing 2 cases stored in Shivaji Nagar police station.

The AI Investigation Agent

To make graph-based investigation accessible through natural language, I built an AI agent with five specialized tools.

1. FindRelationship

Finds connections between two people by traversing the graph. It helps investigators understand how individuals are connected and retrieve the recorded interactions or cases linking them.

2. CaseTimeLine

Retrieves events associated with a case and organizes them chronologically, providing a structured view of how the investigation unfolded.

3. FindByName

Retrieves a person's available investigative context, including associated cases, relationships, events, and connected evidence.

4. CreateEvidence

Adds evidence to an ongoing case and links it to the relevant graph entities, making it discoverable through subsequent queries.

5. GetCasePattern

Identifies potential connections between cases registered at different police stations by querying the common Department graph. This enables cross-station link analysis beyond the scope of an individual station's data.

Together, these tools turn the graph into an interactive investigation layer rather than simply a data store.

                Department
                /        \
               /          \
         Station_A      Station_B
             |               |
          Case_101         Case_205
             \              /
              \            /
                 Person_X
Enter fullscreen mode Exit fullscreen mode

How the Components Work Together

CaseGraph separates the user interface, application logic, AI orchestration, and graph persistence.

Investigator
     |
Angular Frontend
     |
.NET Backend
     |
AI Agent ─LLM─> Five Investigation Tools
                     |
                  FalkorDB
                 /        \
         Station Graphs   Department Graph
Enter fullscreen mode Exit fullscreen mode
  • Angular provides the investigator-facing interface.
  • .NET handles backend workflows, validation, and integration.
  • The AI agent interprets requests and selects the appropriate tool.
  • FalkorDB stores connected entities and executes graph queries.

This separation keeps the AI layer focused on interpreting investigative intent while the backend controls database access and application operations.

Key Takeaways

Building CaseGraph reinforced three important ideas:

  • Relationships should be first-class data. Graphs make multi-hop connections and cross-case exploration more natural to express.
  • Shared context enables broader discovery. The Department graph provides a common view for identifying potential links across station boundaries.
  • AI and graph databases complement each other. The graph models and retrieves connections, while the agent makes those capabilities accessible through natural-language workflows.

For real-world deployment, entity resolution, authorization, data provenance, auditability, and human verification would be essential—especially when handling sensitive investigative information. A discovered relationship should be treated as a lead to examine, not proof of wrongdoing.

Conclusion

CaseGraph was my exploration of how graph databases and AI agents can work together to support relationship-driven investigations.

Using FalkorDB, I built a graph-based architecture with station-specific data and a shared Department graph, then exposed its capabilities through five focused investigation tools.

The most interesting part was moving beyond simple record retrieval toward discovering connections that might otherwise remain hidden across separate cases.

The graph provides the connected context. The AI agent makes that context easier to explore.

That is the idea behind CaseGraph.

Repository: https://github.com/mohinimhetre/CaseGraph
Falkor DB: https://www.falkordb.com/
Hackathon organizer: https://www.wemakedevs.org/home

Top comments (0)