Skip to content

A GraphRAG system extracts knowledge graphs from PDF documents using LangGraph mult agent. Graph visualization, chat querying, Supabase storage.

License

Notifications You must be signed in to change notification settings

SumanMadipeddi/graphRAG-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphRAG Agent

A document processing system that extracts and visualizes knowledge graphs from PDF documents using LangGraph and AI agents.

Overview

graphRAG Agent processes PDF documents through a multi-agent workflow that:

  1. Ingests PDF files
  2. Extracts entities and relationships
  3. Evaluates the extracted knowledge graph
  4. Stores the graph in Supabase
  5. Visualizes the graph in an interactive web interface

Graph Visualization

Here's an example of the knowledge graph visualization generated from a PDF document:

Knowledge Graph Visualization

The graph shows entities (nodes) and their relationships (edges), with different colors representing different entity types. Nodes without connections are automatically filtered out for a cleaner visualization.

Architecture

  • Backend: Express.js server with LangGraph workflow
  • Frontend: Next.js application with React and vis-network for graph visualization
  • Database: Supabase for persistent graph storage
  • AI: LangChain with Google GenAI for document processing

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Supabase account and project

Installation

  1. Clone the repository:
git clone <repository-url>
cd graphRAG-Agent
  1. Install backend dependencies:
npm install
  1. Install frontend dependencies:
cd frontend
npm install
cd ..

Configuration

Create a .env file in the root directory with the following variables:

SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
GOOGLE_API_KEY=your_google_genai_api_key

Database Setup

Ensure your Supabase database has the following tables:

  • nodes table with columns: id, node_id, type, properties
  • edges table with columns: source_node_id, target_node_id, type

Add a unique constraint on edges:

ALTER TABLE edges ADD CONSTRAINT edges_unique_relationship UNIQUE (source_node_id, target_node_id, type);

Running the Application

  1. Start the backend server:
npm run dev

The server will run on http://localhost:3001

  1. Start the frontend (in a new terminal):
cd frontend
npm run dev

The frontend will run on http://localhost:3000

Usage

  1. Open http://localhost:3000 in your browser
  2. Upload a PDF document using the file input
  3. Click "Process PDF" to extract and visualize the knowledge graph
  4. Use "Reset to Default" to load the default graph from the database

Project Structure

graphRAG-Agent/
├── src/
│   ├── agents/          # LangGraph agents (ingestion, extraction, evaluation, storage)
│   ├── app/             # Express server
│   ├── data/            # Supabase integration
│   └── types/           # TypeScript type definitions
├── frontend/
│   └── src/
│       └── app/         # Next.js application and components
└── uploads/             # Temporary PDF storage

Technologies

  • Backend: Express.js, LangChain, LangGraph, Supabase
  • Frontend: Next.js, React, TypeScript, Tailwind CSS, vis-network
  • AI: Google GenAI (via LangChain)

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

A GraphRAG system extracts knowledge graphs from PDF documents using LangGraph mult agent. Graph visualization, chat querying, Supabase storage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages