How bayu-siddhi/graph-rag-arangodb works
Main Components
• User Interface: Represented by the Gradio-based UI (launched by main.py). This is the entry point where users interact with the system.
• Backend Processing:
• Query & Retrieval Engine: Modules like app/graph_rag/agent.py and app/graph_rag/prompt.py manage the retrieval process, integrating LLM responses with graph data.
• Knowledge Graph Handler: Files in app/graph_rag (models.py, tools.py) combine with app/database.py and app/custom_adbnx.py to handle ArangoDB connectivity and query execution using AQL.
• Data & Graph Analytics: The file app/dataset.py along with integration of NetworkX (as mentioned in the README) handles graph analytics (e.g., shortest paths, influences, community detection).
• Data Storage & Graph Data:
• External ArangoDB: The project assumes an ArangoDB instance (credentials in .env, and instructions in README), serving as the primary data store for nodes, edges, and legal documents.
• Static Data Files: The “data” directory contains both raw data (data/raw) and preprocessed graph JSON files (nodes and various edge types) that can be used for visualization and validation.
• Auxiliary Components:
• Helper utilities: Such as app/helper.py and any additional configuration files (.env.example) that support runtime setup and configuration.
Relationships and Data Flow
• User Query Path: Begin with the Gradio UI (main.py) where a user submits a legal question.
• Query Processing: The input is then handed off to the retrieval engine (app/graph_rag/agent.py) which uses custom prompts (from app/graph_rag/prompt.py) and model configurations (in app/graph_rag/models.py).
• Graph Analytics: Indicate a data flow to NetworkX-powered analytics (hinted at in the README) where algorithms assess connectedness, centrality, and community structures from the legal data.
• Response Assembly: The combined insights from graph analytics and LLM results are then composed into a context-aware response that is delivered back to the UI.
Architectural Patterns & Design Principles
• Modular Design: The separation between data handling (knowledge graph operations), analytics (NetworkX), and NLP tasks (RAG with LLM) is clear in the directory structure.
• Separation of Concerns: Highlight how the project separates data storage, retrieval logic, and user interaction.
• External Dependency Integration: Emphasize integration with third-party tools and services such as ArangoDB for storage and Gradio for the UI.
• Extensibility: The project’s structure (with various submodules within app/graph_rag) suggests that components can be extended or modified in isolation.