# gridlogic-dk/graphify architecture

> Architecture diagram of the GitHub repository gridlogic-dk/graphify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gridlogic-dk/graphify
- Repository: https://github.com/gridlogic-dk/graphify

## Overview

Graphify turns a project corpus into a queryable knowledge graph and presents it as visualizations and reports. The primary workflow is discovery and extraction, graph assembly, analysis, then export; users can also query through the serving interface or keep a graph updated as files change. Documented capabilities include call-flow pages, MCP ingestion, pull-request analysis, and direct LLM extraction. Some subsystem links below rely on README descriptions or SOURCE INDEX references; unsampled implementations are not asserted beyond those connections.

Main entry points: [`graphify/__main__.py`](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/__main__.py) (CLI), [`graphify/watch.py`](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/watch.py) (Change watcher), [`graphify/build.py`](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/build.py) (Graph assembly), [`graphify/analyze.py`](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/analyze.py) (Graph insights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and updates"]
  node_cli["CLI<br/>[__main__.py]"]
  node_watch["Change watcher<br/>[watch.py]"]
end

subgraph group_corpus["Corpus processing"]
  node_detect["File discovery<br/>[detect.py]"]
  node_extract["Code extraction<br/>[extract.py]"]
  node_ingest["URL ingestion<br/>[ingest.py]"]
  node_mcp["MCP ingestion<br/>[mcp_ingest.py]"]
  node_llm["LLM extraction<br/>[llm.py]"]
  node_cache[("Extraction cache<br/>[cache.py]")]
  node_security["Security helpers<br/>[security.py]"]
end

subgraph group_graph["Graph and analysis"]
  node_build["Graph assembly<br/>[build.py]"]
  node_validate["Graph validation<br/>[validate.py]"]
  node_dedup["Node deduplication<br/>[dedup.py]"]
  node_cluster["Community clustering<br/>[cluster.py]"]
  node_analyze["Graph insights<br/>[analyze.py]"]
end

subgraph group_access["Query and presentation"]
  node_report["Graph report<br/>[report.py]"]
  node_export["Graph export<br/>[export.py]"]
  node_callflow["Call-flow pages<br/>[callflow_html.py]"]
  node_treehtml["Interactive graph view<br/>[tree_html.py]"]
  node_serve["Query server<br/>[serve.py]"]
  node_querylog[("Query log<br/>[querylog.py]")]
  node_prs["Pull-request analysis<br/>[prs.py]"]
end

node_user(("Engineer or agent"))

node_user -->|"runs"| node_cli
node_cli -->|"discovers files"| node_detect
node_cli -->|"extracts code"| node_extract
node_cli -->|"fetches sources"| node_ingest
node_cli -->|"indexes MCP"| node_mcp
node_cli -->|"extracts semantically"| node_llm
node_cli -->|"builds graph"| node_build
node_extract -->|"uses cache"| node_cache
node_extract -->|"classifies files"| node_detect
node_build -->|"validates"| node_validate
node_build -->|"deduplicates"| node_dedup
node_cli -->|"analyzes graph"| node_analyze
node_analyze -->|"reads graph"| node_build
node_analyze -->|"uses communities"| node_cluster
node_cli -->|"writes report"| node_report
node_report -->|"summarizes insights"| node_analyze
node_cli -->|"exports graph"| node_export
node_export -->|"uses analysis"| node_analyze
node_export -->|"reads graph"| node_build
node_export -->|"sanitizes output"| node_security
node_cli -->|"renders graph"| node_treehtml
node_cli -->|"exports call flows"| node_callflow
node_cli -->|"starts server"| node_serve
node_serve -->|"loads graph"| node_build
node_serve -->|"queries insights"| node_analyze
node_serve -->|"routes PR analysis"| node_prs
node_serve -->|"logs queries"| node_querylog
node_cli -->|"watches changes"| node_watch
node_watch -->|"checks changes"| node_detect
node_watch -->|"re-extracts files"| node_extract
node_watch -->|"rebuilds graph"| node_build
node_watch -->|"refreshes insights"| node_analyze
node_watch -->|"refreshes report"| node_report
node_watch -->|"refreshes export"| node_export
node_watch -->|"reclusters graph"| node_cluster
node_watch -->|"refreshes pages"| node_callflow
node_ingest -->|"fetches safely"| node_security

click node_cli "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/__main__.py"
click node_watch "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/watch.py"
click node_detect "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/detect.py"
click node_extract "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/extract.py"
click node_ingest "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/ingest.py"
click node_mcp "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/mcp_ingest.py"
click node_llm "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/llm.py"
click node_cache "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/cache.py"
click node_build "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/build.py"
click node_validate "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/validate.py"
click node_dedup "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/dedup.py"
click node_cluster "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/cluster.py"
click node_analyze "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/analyze.py"
click node_report "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/report.py"
click node_export "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/export.py"
click node_callflow "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/callflow_html.py"
click node_treehtml "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/tree_html.py"
click node_serve "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/serve.py"
click node_querylog "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/querylog.py"
click node_prs "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/prs.py"
click node_security "https://github.com/gridlogic-dk/graphify/blob/v8/graphify/security.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_watch toneBlue
class node_detect,node_extract,node_ingest,node_mcp,node_llm,node_cache,node_security toneAmber
class node_build,node_validate,node_dedup,node_cluster,node_analyze toneMint
class node_report,node_export,node_callflow,node_treehtml,node_serve,node_querylog,node_prs toneRose
class node_user toneIndigo
```

## Components

### Entry and updates

- [CLI](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/__main__.py): `graphify/__main__.py`
- [Change watcher](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/watch.py): `graphify/watch.py`

### Corpus processing

- [File discovery](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/detect.py): `graphify/detect.py`
- [Code extraction](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/extract.py): `graphify/extract.py`
- [URL ingestion](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/ingest.py): `graphify/ingest.py`
- [MCP ingestion](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/mcp_ingest.py): `graphify/mcp_ingest.py`
- [LLM extraction](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/llm.py): `graphify/llm.py`
- [Extraction cache](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/cache.py): `graphify/cache.py`
- [Security helpers](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/security.py): `graphify/security.py`

### Graph and analysis

- [Graph assembly](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/build.py): `graphify/build.py`
- [Graph validation](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/validate.py): `graphify/validate.py`
- [Node deduplication](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/dedup.py): `graphify/dedup.py`
- [Community clustering](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/cluster.py): `graphify/cluster.py`
- [Graph insights](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/analyze.py): `graphify/analyze.py`

### Query and presentation

- [Graph report](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/report.py): `graphify/report.py`
- [Graph export](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/export.py): `graphify/export.py`
- [Call-flow pages](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/callflow_html.py): `graphify/callflow_html.py`
- [Interactive graph view](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/tree_html.py): `graphify/tree_html.py`
- [Query server](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/serve.py): `graphify/serve.py`
- [Query log](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/querylog.py): `graphify/querylog.py`
- [Pull-request analysis](https://github.com/gridlogic-dk/graphify/blob/v8/graphify/prs.py): `graphify/prs.py`

### Other components

- **Engineer or agent**

## Connections

- Engineer or agent → CLI: runs (evidence: `README.md`)
- CLI → File discovery: discovers files (evidence: `graphify/__main__.py`)
- CLI → Code extraction: extracts code (evidence: `graphify/__main__.py`)
- CLI → URL ingestion: fetches sources (evidence: `graphify/ingest.py`)
- CLI → MCP ingestion: indexes MCP (evidence: `graphify/mcp_ingest.py`)
- CLI → LLM extraction: extracts semantically (evidence: `graphify/llm.py`)
- CLI → Graph assembly: builds graph (evidence: `README.md`)
- Code extraction → Extraction cache: uses cache (evidence: `graphify/extract.py`)
- Code extraction → File discovery: classifies files (evidence: `graphify/extract.py`)
- Graph assembly → Graph validation: validates (evidence: `graphify/build.py`)
- Graph assembly → Node deduplication: deduplicates (evidence: `graphify/build.py`)
- CLI → Graph insights: analyzes graph (evidence: `graphify/__main__.py`)
- Graph insights → Graph assembly: reads graph (evidence: `graphify/analyze.py`)
- Graph insights → Community clustering: uses communities (evidence: `graphify/analyze.py`)
- CLI → Graph report: writes report (evidence: `README.md`)
- Graph report → Graph insights: summarizes insights (evidence: `graphify/report.py`)
- CLI → Graph export: exports graph (evidence: `README.md`)
- Graph export → Graph insights: uses analysis (evidence: `graphify/export.py`)
- Graph export → Graph assembly: reads graph (evidence: `graphify/export.py`)
- Graph export → Security helpers: sanitizes output (evidence: `graphify/export.py`)
- CLI → Interactive graph view: renders graph (evidence: `graphify/__main__.py`)
- CLI → Call-flow pages: exports call flows (evidence: `README.md`)
- CLI → Query server: starts server (evidence: `graphify/__main__.py`)
- Query server → Graph assembly: loads graph (evidence: `graphify/serve.py`)
- Query server → Graph insights: queries insights (evidence: `graphify/serve.py`)
- Query server → Pull-request analysis: routes PR analysis (evidence: `graphify/serve.py`)
- Query server → Query log: logs queries (evidence: `graphify/serve.py`)
- CLI → Change watcher: watches changes (evidence: `graphify/__main__.py`)
- Change watcher → File discovery: checks changes (evidence: `graphify/watch.py`)
- Change watcher → Code extraction: re-extracts files (evidence: `graphify/watch.py`)
- Change watcher → Graph assembly: rebuilds graph (evidence: `graphify/watch.py`)
- Change watcher → Graph insights: refreshes insights (evidence: `graphify/watch.py`)
- Change watcher → Graph report: refreshes report (evidence: `graphify/watch.py`)
- Change watcher → Graph export: refreshes export (evidence: `graphify/watch.py`)
- Change watcher → Community clustering: reclusters graph (evidence: `graphify/watch.py`)
- Change watcher → Call-flow pages: refreshes pages (evidence: `graphify/watch.py`)
- URL ingestion → Security helpers: fetches safely (evidence: `graphify/ingest.py`)
