Brain GraphRAG Entity Relation

Brain hafiza katmaninda entity-relationship graph kurarak Microsoft GraphRAG mimarisi uygular.

An implementation guide for building a Microsoft GraphRAG-style knowledge graph over your memory layer using Apache AGE, the Postgres graph extension, instead of a separate graph database. It extracts entities and relationships from your notes, clusters them with Leiden community detection, and answers multi-hop questions that plain vector search cannot. It injects only the relevant connected entities into an agent's context, replacing a large document dump with a compact, related subgraph.

$15 one-time
Add to a kit →

Prices include 20% VAT. · Forged on real agency work · one-time, no lock-in

  • Type Skill
  • Category Data & Analytics
  • Delivery Email · instant
  • License One-time
Run preview
forgehouse, brain-graphrag-entity-relation

Inside the run · no black box

See the actual work before you buy it.

Before a single entity reaches a model, PII gets masked. From there the pipeline runs hybrid extraction, Apache AGE graph building, nightly Leiden clustering and capped Cypher traversal, turning memory dumps into a queryable entity map.

  1. Masks PII before anything touches a model: phone, email, national ID and IBAN patterns are redacted by regex first, only then does entity extraction run, so no raw personal data ever reaches the LLM.
  2. Extracts entities with a hybrid pass: spaCy NER handles the cheap high-confidence cases, the remainder goes to an LLM with a strict JSON schema, a known-entity catalog in the system prompt and a closed list of six relation types; anything outside the schema is dropped because graph health beats recall.
  3. Builds the graph in Apache AGE on the existing Postgres: entities become nodes, subject-verb-object triples become edges, duplicates are merged through lowercase canonical names so Acme, acme and ACME never become three separate nodes, with GIN indexes and tenant-level RLS on every label.
  4. Runs Leiden community detection as a nightly cron with a fixed seed: the whole graph is exported to igraph, clustered, and each node gets a stable community_id written back, which later answers questions like which customers resemble each other.
  5. At query time it goes hybrid: vector search returns the top relevant chunks, the entities mentioned in them are expanded one hop through the graph, and both are merged into the agent context with a hard 3000-token cap, replacing a 50K-token document dump with a 2K entity map.
  6. Guards every Cypher query: parameters only, never string concatenation, traversal depth capped at three hops and LIMIT on every query, because four-plus hops blow up exponentially.
Use cases · what happens when you plug it in

One power source. 6 lines out.

brain-graphrag-entity-relation · core

core active · 6 lines

  1. Answering relationship questions like which skills one project used that another did not

    ✓ answering relationship q…
  2. Adding multi-hop reasoning where single-shot semantic similarity falls short

    ✓ adding multi-hop reasoning
  3. Building entity-based semantic SEO and topic clusters from a knowledge graph

    ✓ building entity-based se…
  4. Injecting a focused set of related entities into an agent's context to save tokens

    ✓ injecting a focused set
  5. Modeling course, module, lesson, user, and progress relationships for cohort analysis

    ✓ modeling course, module
  6. Self-hosting a graph layer alongside pgvector in the same Postgres instance

    ✓ self-hosting a graph layer
Benefits · what you walk away with

Yours to keep.

Drag time forward. Watch what stays.

Forever

That's what owning means.

The rented stack

ai writing tool: subscription

expired · access lost

analytics suite: subscription

expired · access lost

design platform: subscription

expired · access lost

(nothing left)

Your forge

  1. Compositional, multi-hop answers that vector-only retrieval cannot produce

    license: perpetual
  2. Dramatically smaller agent context by injecting a related-entity subgraph instead of a full document dump

    license: perpetual
  3. No separate graph database to run or pay for, since Apache AGE lives in your existing Postgres

    license: perpetual
  4. Safer queries with PII masking before extraction, parameterized Cypher, and tenant-isolating row-level security

    license: perpetual

subscriptions expire · deeds don't

What's included · the full manifest

Everything in the box.

Pick a piece up. Watch it work.

Apache AGE setup with vertex and edge labels, GIN indexes, and tenant-isolating RLS

part 01 of 06 · in the box

6 parts · one working system · ships instantly by email

Who it's for

This wasn't forged for everyone.

  • Not for you if you'd rather rent a tool than own one.
  • Not for you if you want someone else to run your stack.
  • Not for you if you're happy guessing.
Still here? Good.

Engineers and AI teams building a retrieval layer who need relationship-aware, multi-hop recall and want to self-host a graph alongside pgvector in Postgres.

then this was forged for you.

Works with

Universal by design: these run in any AI. Delivered in the open Agent Skills + MCP format (native in Claude); ChatGPT, Gemini, Cursor and Copilot adapt the same files their own way.

  • Claude Native format
  • ChatGPT Adapts via open standards
  • Gemini Adapts via open standards
  • Cursor Adapts via open standards
  • Copilot Adapts via open standards
Questions · still in the air

Catch what's on your mind.

the air is clear. nothing between you and the forge.
catch a spark: the forge will answer

  1. Do I need to stand up Neo4j or a separate graph database for this?

    No: it runs on Apache AGE, the Postgres graph extension, so the graph lives in the database you likely already have. You add multi-hop querying without operating a second datastore.

  2. Vector search already pulls relevant notes. Why add a graph at all?

    Because semantic similarity is single-shot, it finds notes that look alike, but it can't answer 'which skills did project A use that project B didn't.' That kind of question needs traversing relationships, which is exactly what the graph layer adds over flat retrieval.

  3. Does the entity extraction just work, or do I have to babysit it?

    Extraction quality bounds the whole system, and from messy notes it needs review, bad entities make bad edges. The guide gives you the pipeline and the Leiden clustering, but treat the communities it finds as a heuristic starting point, not ground truth.

  4. How is it delivered?

    By email right after purchase: ready to run, downloaded instantly, no setup wait.

  5. One-time or subscription?

    A one-time purchase; no subscription or hidden fees. VAT (20%) is included.

  6. Can I get a refund?

    As a digital product, it can’t be refunded once downloaded. That’s why we show exactly what’s inside and who it’s for, right here.