A GraphRAG (Graph Retrieval-Augmented Generation) application for IBM Edge Application Manager (IEAM) documentation using Neo4j as the knowledge graph database.
This project implements a sophisticated RAG system that:
┌─────────────────┐
│ HTML Documents │
└────────┬────────┘
│
▼
┌─────────────────┐
│ HTML Parser │
│ & Processor │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌──────────────┐
│ Entity │────▶│ Embeddings │
│ Extraction │ │ (Ollama/ │
└────────┬────────┘ │ OpenAI) │
│ └──────────────┘
▼
┌─────────────────┐
│ Neo4j Graph │
│ Construction │
└────────┬────────┘
│
▼
┌─────────────────┐
│ GraphRAG │
│ Query Engine │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Express API │
│ Server │
└─────────────────┘
/api/query - Natural language queries/api/graph/stats - Graph statistics/api/graph/search - Entity search/api/health - Health checkundefinedNeo4j Aura or Local Instanceundefined
undefinedEmbedding Provider (choose one):
undefinedNode.js >= 18.x
# Clone or navigate to the project
cd ieam-graphrag
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Edit .env with your configuration
nano .env
Create a .env file with the following:
# Server Configuration
PORT=3000
HOST=localhost
# Neo4j Configuration
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your-password
NEO4J_DATABASE=neo4j
# Embedding Provider (ollama or openai)
EMBEDDING_PROVIDER=ollama
# Ollama Configuration (if using Ollama)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_LLM_MODEL=llama3.2:3b
# OpenAI Configuration (if using OpenAI)
OPENAI_API_KEY=your-api-key
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_LLM_MODEL=gpt-4
# Data Paths
HTML_DOCS_PATH=./data/ieam-html
PROCESSED_DATA_PATH=./data/processed
# Graph Configuration
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
SIMILARITY_THRESHOLD=0.75
MAX_GRAPH_DEPTH=3
# Build the project
npm run build
# Parse HTML and import to Neo4j
npm run import
# This will:
# - Parse all HTML files in data/ieam-html
# - Extract entities and relationships
# - Generate embeddings
# - Create knowledge graph in Neo4j
# Development mode with auto-reload
npm run dev
# Production mode
npm start
# Using curl
curl -X POST http://localhost:3000/api/query \
-H "Content-Type: application/json" \
-d '{"query": "How to register an edge node in IEAM?"}'
# Using the provided test script
npm run test:query
# Get graph statistics
curl http://localhost:3000/api/graph/stats
# Search for entities
curl "http://localhost:3000/api/graph/search?q=edge+node"
ieam-graphrag/
├── src/
│ ├── config/
│ │ └── index.ts # Configuration management
│ ├── parsers/
│ │ ├── html-parser.ts # HTML document parser
│ │ └── entity-extractor.ts # Entity extraction
│ ├── embeddings/
│ │ ├── base.ts # Base embedding interface
│ │ ├── ollama.ts # Ollama provider
│ │ └── openai.ts # OpenAI provider
│ ├── graph/
│ │ ├── neo4j-client.ts # Neo4j connection
│ │ ├── graph-builder.ts # Graph construction
│ │ └── graph-query.ts # Graph queries
│ ├── graphrag/
│ │ ├── query-processor.ts # Query processing
│ │ └── context-builder.ts # Context aggregation
│ ├── api/
│ │ ├── server.ts # Express server
│ │ └── routes.ts # API routes
│ ├── utils/
│ │ ├── logger.ts # Logging utility
│ │ └── helpers.ts # Helper functions
│ └── index.ts # Main entry point
├── data/
│ ├── ieam-html/ # HTML documentation
│ └── processed/ # Processed data
├── docs/
│ ├── ARCHITECTURE.md # Architecture details
│ ├── API.md # API documentation
│ └── NEO4J_SETUP.md # Neo4j setup guide
├── tests/
│ └── integration/ # Integration tests
├── .env.example # Environment template
├── package.json
├── tsconfig.json
└── README.md
undefinedDocumentundefined
id, title, url, content, embeddingundefinedSectionundefined
id, title, content, level, embeddingundefinedEntityundefined
id, name, type, description, embeddingConcept, Component, Command, API, ConfigurationundefinedTopicundefined
id, name, description// POST /api/query
{
"query": "How to register an edge node in IEAM?",
"maxResults": 5,
"includeGraph": true
}
// Response
{
"answer": "To register an edge node in IEAM...",
"sources": [
{
"title": "Registering Edge Nodes",
"url": "...",
"relevance": 0.95
}
],
"graph": {
"nodes": [...],
"relationships": [...]
}
}
// GET /api/graph/stats
{
"nodes": {
"Document": 150,
"Section": 450,
"Entity": 320,
"Topic": 25
},
"relationships": {
"HAS_SECTION": 450,
"MENTIONS": 1200,
"RELATES_TO": 850
},
"totalNodes": 945,
"totalRelationships": 2500
}
Automatically groups related concepts:
CALL gds.louvain.stream('myGraph')
YIELD nodeId, communityId
Identifies key concepts:
CALL gds.pageRank.stream('myGraph')
YIELD nodeId, score
Finds connections between concepts:
MATCH path = shortestPath(
(a:Entity {name: 'Edge Node'})-[*]-(b:Entity {name: 'Agent'})
)
RETURN path
# Test connection
npm run test:neo4j
# Check Neo4j logs in Aura console
# For Ollama, ensure model is pulled
ollama pull nomic-embed-text
# Check Ollama is running
curl http://localhost:11434/api/tags
# Check HTML files exist
ls -la data/ieam-html
# Verify Neo4j credentials
npm run test:config
# Run tests
npm test
# Run specific test
npm test -- graph-builder
# Lint code
npm run lint
# Format code
npm run format
# Type check
npm run type-check
# Build image
docker build -t ieam-graphrag .
# Run container
docker run -p 3000:3000 --env-file .env ieam-graphrag
See docs/DEPLOYMENT.md for cloud deployment guides.
ISC
For issues and questions:
docs/ folderundefinedMade with ❤️ for IEAM Documentationundefined
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.