A document processing system that extracts and visualizes knowledge graphs from PDF documents using LangGraph and AI agents.
graphRAG Agent processes PDF documents through a multi-agent workflow that:
- Ingests PDF files
- Extracts entities and relationships
- Evaluates the extracted knowledge graph
- Stores the graph in Supabase
- Visualizes the graph in an interactive web interface
Here's an example of the knowledge graph visualization generated from a PDF document:
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.
- 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
- Node.js (v18 or higher)
- npm or yarn
- Supabase account and project
- Clone the repository:
git clone <repository-url>
cd graphRAG-Agent- Install backend dependencies:
npm install- Install frontend dependencies:
cd frontend
npm install
cd ..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_keyEnsure your Supabase database has the following tables:
nodestable with columns:id,node_id,type,propertiesedgestable 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);- Start the backend server:
npm run devThe server will run on http://localhost:3001
- Start the frontend (in a new terminal):
cd frontend
npm run devThe frontend will run on http://localhost:3000
- Open
http://localhost:3000in your browser - Upload a PDF document using the file input
- Click "Process PDF" to extract and visualize the knowledge graph
- Use "Reset to Default" to load the default graph from the database
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
- Backend: Express.js, LangChain, LangGraph, Supabase
- Frontend: Next.js, React, TypeScript, Tailwind CSS, vis-network
- AI: Google GenAI (via LangChain)
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
