> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphify.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The PyPI package is graphifyy, with two y's. The command is graphify.
> /graphify . is typed in an assistant chat, not in a shell.
> Use only commands, flags, and endpoints shown on these pages. Do not invent one.
> Choose the surface before you open a page. Local (Graphify Local) is the graphifyy package on the machine: the skill, the CLI, and the ten-tool MCP. Its pages are the Open Source tab (/open-source/) and the Graphify Local tab on each Integrations page. Graphify is the hosted workspace and https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). Its pages are the Graphify tab (/platform/, /concepts/) and the Graphify (hosted) tab on each Integrations page. Prefer Graphify unless the user asks for a local or offline setup. Cookbooks (/cookbooks/) and /mcp/docs-search apply to both. Each page's source frontmatter records this as surface: local, cloud, or both. Buildkite is the CI integration.
> In llms.txt, tell the surface from the page path. Graphify: /platform/ and /concepts/. Local: /open-source/. Most /integrations/ pages cover both, with a Graphify (hosted) tab and a Graphify Local tab. Everything else applies to both.
> graphifyy release notes are published at https://github.com/Graphify-Labs/graphify/releases and https://graphify.com/changelog. The current package version is on PyPI (https://pypi.org/project/graphifyy/).
> The official site is https://graphify.com. These docs are https://docs.graphify.com.
> The local MCP server is the ten tools in the MCP tool reference and reads a graph on the machine. The hosted server is https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). The JetBrains, ChatGPT, Codex, and Dots, and Vercel pages use the hosted server, not the ten-tool list. On pages with tabs, the Graphify (hosted) tab uses the hosted server and the Graphify Local tab uses the local skill or the ten-tool server.
> Read https://docs.graphify.com/llms.txt, then open one page's .md link. Use https://docs.graphify.com/llms-full.txt only when one page is not enough.

# Graph your Postgres schema next to your code

> Add your PostgreSQL schema to your code graph: Graphify reads tables, views, functions and foreign keys over a read-only connection, next to your code.

Graphify can read a live PostgreSQL database and add its schema to the same graph as your code. Tables, views, functions and foreign keys become nodes and edges, so you can ask how the code and the schema connect without opening a SQL client.

## What you'll build

* A graph that holds your code and your database schema together.
* Foreign-key edges between tables.
* Queries that cross from code to schema.

## Setup

Install the `postgres` extra. It adds `psycopg` and the SQL grammar Graphify uses to parse the schema:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
uv tool install "graphifyy[postgres]"
```

Use a role that can read the catalog. It doesn't need write access, because Graphify opens a read-only transaction.

## Step 1: Extract with a DSN

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
cd your-repo
graphify extract . --code-only --postgres "postgresql://readonly@localhost:5432/app"
```

Graphify connects, reads the schema from `information_schema` and the Postgres catalog, rebuilds the DDL, and parses it alongside your code. The connection runs `SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE`, so it can't change data.

## Step 2: Use PG environment variables instead

Leave the DSN empty and Graphify uses the standard `PG*` variables, which keeps credentials out of your shell history:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export PGHOST=localhost PGPORT=5432 PGDATABASE=app PGUSER=readonly
export PGPASSWORD="$(your-secret-tool get app-readonly)"
graphify extract . --code-only --postgres ""
```

## Step 3: Explore the schema

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify query "which tables reference users" --budget 1500
graphify explain "orders"
```

Each table, view and function is a node. Foreign keys become `references` edges between tables, and views get `reads_from` edges to the tables they select from. For a schema with `users`, `orders` (with a foreign key to `users`) and a `recent_orders` view, the graph holds:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
orders --references--> users
recent_orders --reads_from--> orders
```

Extract prints the count it added, as `[graphify extract] PostgreSQL: N nodes, M edges`. Columns aren't separate nodes, so ask about tables and their relations rather than single columns.

## Step 4: Connect code to schema

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify path "orders" "create_order()"
```

Whether a path exists depends on how your code names the table. Where none is found, try `--undirected`, then check how your code references the table. SQL built at runtime won't show up.

## When it goes wrong

**`psycopg is required for --postgres`.** Install the extra: `uv tool install "graphifyy[postgres]"`.

**The schema adds zero nodes.** The SQL grammar is missing, so parsing returns nothing. The `postgres` extra includes it. If you installed `psycopg` on its own, add `tree-sitter-sql`.

**`could not connect to PostgreSQL`.** Graphify trims the error to its first line so credentials don't leak into logs. Check the host, port and role with `psql` using the same settings.

## Production patterns

* Point Graphify at a replica or a schema-only copy, not your primary.
* Use a dedicated read-only role and pass the password through `PGPASSWORD` from your secret manager.
* Rebuild the schema graph when migrations land, for example in the CI job that runs them.
* Export to Neo4j to query code and schema in Cypher: [Load your graph into Neo4j](https://docs.graphify.com/cookbooks/neo4j-export.md).

## Complete example

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
uv tool install "graphifyy[postgres]"
cd your-repo
export PGHOST=localhost PGDATABASE=app PGUSER=readonly
graphify extract . --code-only --postgres ""
graphify query "which tables reference users" --budget 1500
graphify path "orders" "create_order()" --undirected
```

## What you built

One graph that holds your code and your database schema, read over a read-only connection and ready to query from the CLI, MCP or Neo4j.

## Next steps

> **[Supported inputs](https://docs.graphify.com/concepts/supported-inputs.md)**
>
> Every source Graphify can read.

> **[Load your graph into Neo4j](https://docs.graphify.com/cookbooks/neo4j-export.md)**
>
> Query code and schema together in Cypher.

> **[Try it in Graphify](https://docs.graphify.com/platform/quickstart.md)**
>
> We build and host the graph for you. Start with a 14-day Pro trial, then keep up to 3 repositories on Free. No card required.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.