# How DeepMorph Turns a Codebase into a Queryable Graph on Iceberg with PuppyGraph

> DeepMorph models codebases as graphs in Apache Iceberg so teams can trace how code changes affect data flows and business rules.

- Canonical URL: https://www.puppygraph.com/case-studies/deepmorph-codebase-graph-apache-iceberg

## Summary

Questions such as what breaks if a field changes, or which business rules depend on it, mean following connections from data through code to business logic, often across several repositories. DeepMorph models an enterprise codebase as a graph that makes those connections explicit, linking functions to the data they touch, the flows they serve and the rules they implement. The graph is stored in Apache Iceberg with a snapshot for every commit, and PuppyGraph runs Cypher directly on those tables, including past versions. On Kill Bill, an open-source billing platform, DeepMorph demonstrated impact and compliance questions answered as graph queries.

## The Challenge: Data Questions Whose Answers Live in Code

Data teams version their data, track its lineage and govern who can access it. The code that produces and uses that data rarely gets the same treatment. It sits in Git as text that nobody can query.

Yet many data questions are answered in that code. Which logic writes this column? What breaks if it changes? Where does this rule actually live? In a billing system, changing the invoice status field touches the code that validates it, the logic that filters on it and the business rules that depend on it. Today, someone who needs those answers usually files a ticket with the engineering team and hopes for a quick reply.

Reading the code by hand is slow. Asking an LLM is faster, but the model sees only what fits in its context window, which for a large codebase is a sample rather than the whole system. Ask twice and it may give two different answers, with no way to tell what it missed. The gap widens as AI coding agents write more code than people can read.

## The Solution: A Codebase Graph on Iceberg, Queried with PuppyGraph

DeepMorph's answer is to put the code in the lake as a graph, so that each of these questions becomes a query. A query covers every path and gives the same answer each time, traced back to the code.

![Architecture in five columns. Code, data and docs feed DeepMorph auto-learn, which learns the four-layer graph and updates on every commit. The graph is stored in Apache Iceberg as node and edge tables, with a snapshot per commit. Three query engines read Iceberg: a graph database serving the latest graph online with low latency, PuppyGraph querying in place on Iceberg for history and scale, and SQL engines such as Spark and Trino. AI agents use the graph via MCP, and people use it through DeepMorph's product.](https://o6xswp5m6ilbks2z.public.blob.vercel-storage.com/uploads/ab8e18ef4ebebeddc0b3152c/3fd76f49-9b15-48d1-bf9c-afd663c18950/deepmorph-code-graph-architecture-2f537e75fef1.png)

Iceberg holds every version of the code graph. A graph database serves the latest graph, while PuppyGraph queries the Iceberg tables in place for history and scale, both in Cypher.

### Learning the codebase in four layers

DeepMorph models a codebase in four layers:

-   **Structure:** files, functions and the calls between them.
-   **Data journeys:** the code that writes a field such as `invoice.status`, the tables that read it, and how a value moves from one system to another.
-   **Scenarios:** business flows, such as a customer paying an invoice.
-   **Business logic:** the rules, such as when an invoice's status may change.

Code tools typically stop at the structure layer. The questions about invoice status need a walk up all four.

![Four stacked layers for the invoice status example. In the business logic layer, the rule Void Restricted to DRAFT Invoices, which allows voiding only while status is DRAFT. It connects to the scenario Void Committed Invoice is Rejected, a failure path; to the invoice status field in the data journeys layer, with values DRAFT, COMMITTED, VOID or WRITTEN\_OFF; and to the voidInvoice REST endpoint in the structure layer, which calls InvoiceUserApi#voidInvoice. The status field also connects to changeInvoiceStatus, the status change handler.](https://o6xswp5m6ilbks2z.public.blob.vercel-storage.com/uploads/ab8e18ef4ebebeddc0b3152c/438490b6-e305-4be3-ab60-a1c7cd681a3e/deepmorph-invoice-status-layers-0a55ff06d68c.png)

In the Kill Bill demonstration, the check that only a draft invoice can be voided is a named rule, connected to the field it gates, the scenario it governs and the functions that enforce it.

DeepMorph builds the graph with a process it calls auto-learn. Structure and data journeys are derived deterministically from code, configuration and data flow. Scenarios and rules are proposed from code, data and documentation, each linked to its evidence and checked automatically against it before a person sees it. People then approve rules rather than reviewing every line, and where the code does not match the business's intention, a reviewer can correct the rule and DeepMorph keeps that decision. The graph updates on every commit.

### Keeping every version in Iceberg

DeepMorph stores the graph in Iceberg as node and edge tables. Snapshots were the main reason for that choice. A codebase changes through commits every day, and with an Iceberg snapshot matched to each commit, the business logic gets time travel: the graph can be queried as of any release, and any two versions can be compared.

Snapshots also make it possible to check a change after the code is written. DeepMorph compares the business-logic graph at the snapshot before a commit with the snapshot after it. The result is a business diff for a person to confirm: the rules that changed, the flows affected, and confirmation that everything else is unchanged. DeepMorph sees this as a way to validate code produced by AI agents.

Iceberg also puts the code graph in the same catalog as the tables it explains. A query can combine business rules and user journeys with business performance data, for example to ask which user journey produces the most revenue. Any engine can read the tables, with SQL for dashboards and Cypher for graph questions. Because code is sensitive, keeping it in Iceberg also keeps it inside the organization's own lake and governance.

### Querying the graph in place with PuppyGraph

Several engines serve the same graph, each for a different job. A separate graph database serves the latest graph online with low latency. PuppyGraph runs Cypher directly on the Iceberg tables, so every snapshot of the code graph can be queried without loading it into a separate store. DeepMorph uses it for history and scale. It chose PuppyGraph entirely for its performance, which matters most as a graph grows large. Both graph engines use Cypher, so graph questions are written the same way whether they target the live graph or its history. SQL engines such as Spark and Trino read the same tables.

> "We choose PuppyGraph... it's 100% due to its performance. So fast, especially when you have a large chunk of the data inside this graph."  
>   
> **Bin Ni**, Co-founder and CEO, DeepMorph

AI agents reach the graph through an MCP server, and engineers, analysts and data scientists use it through DeepMorph's product.

### Answering questions on Kill Bill

DeepMorph demonstrated the approach on Kill Bill, an open-source billing platform spread across four repositories.

Asked what breaks if the invoice status field changes, DeepMorph traced the field from the invoice record to the functions that validate, persist and filter on it, and up to the one business rule gated on it, Void Restricted to DRAFT Invoices, which allows an invoice to be voided only while it is a draft. Changing the status values therefore means revisiting a business rule, not only updating code. Twelve Cypher queries sat behind the answer.

A compliance question produced a capability map of audit trail retrieval, access control and account data export, each traced from user-facing behavior down to the rules enforcing it in code. The map also listed what the graph could not confirm, such as GDPR-specific handling, as items for source-level review.

## The Result: A Codebase That Can Be Queried Like Data

With the codebase modeled as a graph, questions that once meant reading code or filing a ticket become graph queries, and each answer traces back to the functions, flows and rules involved. Because the graph lives in Iceberg with a snapshot for every commit, and PuppyGraph queries those tables in place, every version of a codebase's business logic stays queryable without loading it into a separate graph store.

## Further resources

-   [Code as Data: Turning a Codebase into Business Logic on Iceberg, Bin Ni, Apache Iceberg Meetup Bay Area, November 2026](https://www.youtube.com/watch?v=WSHKJWCiAd8)
