About Portfolio Cases Services Blog Contact 🎙 Talk to AI
EN DE RU
🎙 Talk to AI
August 8, 2026 · 3 min read

How to Turn Codebase Chaos into a Queryable Knowledge Graph in 1 Day: The Graphify Case

I’m Denis Shokhirev, Agentic AI Systems Architect based in Freiburg im Breisgau. At DennisCraft AI Studio, I deploy autonomous multi-agent AI systems for DACH B2B clients. My stack: Claude, Supabase, n8n, Doppler, and self-hosted Postgres. Recently, a production fire forced me to investigate why an agent invoked a deprecated API endpoint three times in a row—traced to a mismatch between code, docs, and real deployment state. Codebase entropy: a real production risk Most teams keep code, docs,

Denis Shokhirev
Denis Shokhirev
Agentic AI Systems Architect
Telegram LinkedIn

I’m Denis Shokhirev, Agentic AI Systems Architect based in Freiburg im Breisgau. At DennisCraft AI Studio, I deploy autonomous multi-agent AI systems for DACH B2B clients. My stack: Claude, Supabase, n8n, Doppler, and self-hosted Postgres. Recently, a production fire forced me to investigate why an agent invoked a deprecated API endpoint three times in a row—traced to a mismatch between code, docs, and real deployment state.

Codebase entropy: a real production risk

Most teams keep code, docs, and architecture diagrams in separate silos. Even with Swagger, Confluence, and README files, no one knows which endpoints are actually deployed at any given time. On a recent integration, I found six conflicting definitions of a single method: in .py, OpenAPI, Notion, and an outdated PDF. An LLM-based agent, acting on this fractured “truth,” triggered a production incident for a client.

According to ACM Queue, 2004, 40% of production bugs are linked to outdated or incomplete documentation. Two decades later, LLM agents and automated pipelines have only accelerated the accumulation of fragmented knowledge and error-prone logic.

The knowledge graph pattern: a practical antidote to chaos

What is a queryable knowledge graph?

Forget the hype: a knowledge graph is simply a structured set of nodes (functions, classes, APIs, business rules) and edges (calls, documents, updates, references). The value is in making this “truth graph” queryable: “Which endpoints are actually deployed, and where are they documented?”

Why 1 day is realistic

You don’t need heavy solutions like Neo4j or managed cloud graphs. I use Supabase Postgres, pgvector for embeddings, and standard SQL tables for relationships. ETL is handled with n8n (extracting code, docstrings, markdown), Claude Code for structuring, and semgrep for static analysis. No black-box magic—just repeatable, auditable steps.


import openai
import psycopg2

def extract_functions(file_path):
    with open(file_path) as f:
        code = f.read()
    # Use semgrep or AST for function extraction
    # ... (invoke via subprocess)
    return functions_list

def insert_to_pg(functions):
    conn = psycopg2.connect(dbname="graphify", ...)
    with conn.cursor() as cur:
        for func in functions:
            cur.execute(
                "INSERT INTO nodes (type, name, source) VALUES (%s, %s, %s)",
                ('function', func['name'], func['file'])
            )
    conn.commit()

Step-by-step: building the knowledge graph pipeline

1. Artifact extraction

  • Code files: parsed via semgrep and AST
  • Documentation: markdown and docstrings via n8n
  • API specs: OpenAPI if available; otherwise, manual extraction

2. Normalization and unification

Claude Code API unifies everything into a single schema: type, name, description, relationships. For edge cases, I use custom prompts to extract business logic from “human” descriptions.

3. Loading into the graph

Supabase (Postgres) holds tables: nodes (id, type, name, source, embedding), edges (from_id, to_id, relation). Embeddings are via pgvector and a model from the OpenAI cookbook.


curl -X POST 'https://api.openai.com/v1/embeddings' \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{"input": "get_user_profile", "model": "text-embedding-ada-002"}'

4. Querying and audit

Now, in seconds, I can answer: where is an endpoint declared, actually implemented, and who last touched it? Any agent—or human—can query the graph API for up-to-date knowledge structure.


def find_conflicts(pg_conn):
    # Find endpoints declared in docs but missing in code
    with pg_conn.cursor() as cur:
        cur.execute("""
            SELECT d.name FROM nodes d
            LEFT JOIN nodes c ON d.name = c.name AND c.type='function'
            WHERE d.type='doc' AND c.id IS NULL
        """)
        return cur.fetchall()

Comparison: legacy vs graph-based knowledge

MethodAudit TimeUp-to-date?Chaos Resistance
Manual search2–3 hoursLowDegrades with codebase size
Swagger + Notion30–60 minutesMediumTeam-discipline dependent
Knowledge graph (Graphify)2–5 minutesHighStable at any scale

FAQ

How fast can I stand up a usable knowledge graph?

For a codebase under 1,000 files, you can get a working MVP in one business day using Supabase, n8n, semgrep, and a Claude API key.

Will this make my pipeline more complex?

No—if anything, the graph becomes your “single source of truth.” Any new agent or integration gets real-time access to current structure.

How do I keep the graph up to date?

n8n triggers updates on every push to main. New code or docs? The graph updates automatically.

Is it safe to store knowledge graphs in the cloud?

I store only metadata, not source code. For sensitive projects, use self-hosted Postgres—no external APIs involved.

Can this scale to microservices?

Yes—the schema is extensible: each service is a subgraph, with cross-service edges in the same graph.

Where in your stack do code and documentation diverge—and how many prod issues has that caused? What’s your real “source of truth”—docs, code, or something else? I run a free 30-min stack audit for DACH founders building AI in regulated markets. DM me on LinkedIn or write to @ger_dennis_ai.

Continue reading
Your AI Agent Can Be Hacked via Plugins: How to Secure Claude Code and Codex Skills in Production
OpenAI Codex hard resets usage limits after unexpected drains — how to protect production from API quota shocks
172 Production-Ready Claude Code Skills: How to Accelerate AI Agent Integration into Business Workflows (Without the Pain)
Cutting AI Agent Costs: Free Model Routing for Claude Code, Codex, and More
All articles →
Ready to build?

Turn your process into an AI system

Fixed price. Production quality. DACH B2B focus.

Start a project → ← All articles