A production-grade Hybrid Retrieval-Augmented Generation (Graph-RAG) engine combining Knowledge Graph Traversal (Neo4j) with Dense Semantic Vector Search (HuggingFace Embeddings) and Ultra-Fast LLM Reasoning (Groq Cloud).
Designed specifically for complex multi-hop reasoning over unstructured cloud infrastructure topology, IAM permission boundaries, and cybersecurity threat vectors (e.g., CVE dependency attack chains).
Traditional Vector-only RAG systems perform similarity matching on isolated text chunks, failing to resolve multi-step relationship chains (
+------------------------+
| Raw Text Documentation |
+-----------+------------+
| (Groq LLM Entity & Relation Extraction)
v
+-------------------------------------------+
| Neo4j Knowledge Graph Storage |
+---------------------+---------------------+
| Graph Nodes/Edges | Dense Vector Index |
+----------+----------+----------+----------+
| |
Multi-Hop Cypher | | Cosine Similarity (all-MiniLM-L6-v2)
Traversal Paths | | Top-K Seed Entities
v v
+-------------------------------------------+
| Hybrid Context Fusion |
+---------------------+---------------------+
|
v
+-------------------------------------------+
| LLM Synthesis & Reasoning (Groq) |
+-------------------------------------------+
- Domain Schema: Nodes (
Service,Role,Policy,Vulnerability,Resource) and Edges (ATTACHED_TO,PERMITS,TARGETS,DEPENDS_ON,EXPOSES). - Multi-Hop Traversal: Resolves path connections up to 4 hops deep using native Cypher pattern matching.
- Interactive 2D Visualization: Dynamic, physics-based network topology rendering via Pyvis inside a Streamlit web interface.
- Rich CLI Telemetry: Formatted terminal outputs, progress steps, and relation tables powered by
rich.
- Language & Runtime: Python 3.10+
- Graph Database: Neo4j Community Edition 5.20 (via Docker)
- LLM & Inference: Groq Cloud API (
openai/gpt-oss-120b,qwen/qwen3.8-27b,llama-3.3-70b-versatile) - Vector Store & Embeddings: Neo4j Vector Index + HuggingFace
all-MiniLM-L6-v2 - Visualization & Frontend: Streamlit, Pyvis Interactive Network
- Telemetry & CLI: Rich
graph-rag-engine/
├── assets/ # Dashboard preview and UI media
├── app.py # Interactive Streamlit Web UI Dashboard
├── docker-compose.yml # Neo4j Container with APOC plugins
├── main.py # Headless CLI execution & rich logging
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── data/
│ └── sample_docs.txt # Multi-hop cloud & vulnerability dataset
└── src/
├── __init__.py
├── extractor.py # LLM-based entity & relation triple extractor
├── graph_db.py # Neo4j connection pool and DB reset operations
├── logger.py # Rich CLI telemetry, tables, and panels
├── retriever.py # Hybrid (Vector + Cypher Traversal) engine
└── visualizer.py # Pyvis 2D network generation modulegit clone https://github.com/ekrmcakir/graph-rag-engine.git
cd graph-rag-engine
cp .env.example .envConfigure your credentials in .env:
GROQ_API_KEY=gsk_your_groq_api_key_here
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=graphragpasswordGet your free Groq API key from Groq Console.
Run the database container in the background:
docker compose up -dNeo4j Browser will be available at http://localhost:7474 (Auth:
neo4j/graphragpassword).
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txtLaunch the visual interface to inspect nodes, drag graph structures, and run dynamic queries:
streamlit run app.pyOpen http://localhost:8501 in your browser.
Run the automated pipeline with full terminal logging:
python main.pyQuery:
"Which S3 bucket is indirectly put at risk by vulnerability CVE-2024-3094?"
Traversed Graph Path:
CVE-2024-3094
--[TARGETS]--> PaymentService
--[ATTACHED_TO]--> PaymentAdminRole
--[ATTACHED_TO]--> S3AccessPolicy
--[PERMITS]--> ProductionDataS3
Synthesized Resolution:
The
ProductionDataS3bucket is identified as the indirect target ofCVE-2024-3094via the propagation path of the associated IAM role and permission policy.
MIT License. Open source and built for security & cloud infrastructure research.
