An intelligent chatbot system combining Knowledge Graphs with RAG for enhanced contextual understanding.
Features • Architecture • Installation • Usage • Contributing
GraphRAG enhances traditional chatbots by leveraging Knowledge Graphs, combining structured and unstructured data into a comprehensive Graph Database. This approach enriches the standard RAG (Retrieval-Augmented Generation) system with relationship-aware context, enabling more accurate and contextual responses to complex queries.
- 🔍 Advanced Query Understanding: Utilizes graph-based context for better query comprehension
- 🧠 Intelligent Response Generation: Combines GPT-4 with graph-based knowledge retrieval
- 📊 Knowledge Graph Integration: Neo4j-powered data relationships
- 🎯 Contextual Awareness: Maintains context through graph relationships
- 💨 Real-time Processing: Fast response generation with optimized retrieval
- 🎨 Modern UI: Sleek interface built with Next.js and TailwindCSS
For a detailed understanding of the system architecture, data flow, and component interactions, please see our detailed architecture documentation.
graph TB
subgraph Frontend["Frontend (Next.js)"]
UI[Chat Interface]
State[React State Management]
API[Axios API Client]
end
subgraph Backend["Backend (FastAPI)"]
FastAPI[FastAPI Server]
SearchEngine[Neo4j Search Engine]
LLM[GPT-4 Integration]
QueryEmbedding[Query Embedding Service]
end
subgraph DataSources["Data Sources"]
SQL[(SQLite Database)]
PDF[PDF Documents]
end
subgraph EmbeddingProcess["Embedding Process"]
ArtistEmbed[Artist Embedding]
AgentEmbed[Sales Agent Embedding]
DocEmbed[Document Embedding]
TextSplitter[Text Splitter]
end
subgraph Database["Knowledge Graph (Neo4j)"]
Neo4j[(Neo4j Database)]
Artists[Artist Nodes]
Agents[Sales Agent Nodes]
Documents[Document Nodes]
Relationships{Graph Relationships}
end
%% Frontend Flow
UI --> State
State --> API
API -->|HTTP POST| FastAPI
%% Data Source Processing
SQL -->|Extract Data| ArtistEmbed
SQL -->|Extract Data| AgentEmbed
PDF -->|Load| TextSplitter
TextSplitter -->|Chunks| DocEmbed
%% Embedding Process
ArtistEmbed -->|Embedded Data| Artists
AgentEmbed -->|Embedded Data| Agents
DocEmbed -->|Embedded Data| Documents
%% Query Processing
FastAPI -->|User Query| QueryEmbedding
QueryEmbedding -->|Search Similar| SearchEngine
SearchEngine -->|Graph Query| Neo4j
SearchEngine -->|Generate Response| LLM
%% Database Relationships
Artists -->|MANAGED| Relationships
Agents -->|MENTIONS| Relationships
Documents -->|RELATED_TO| Relationships
%% Response Flow
LLM -->|Structured Response| FastAPI
FastAPI -->|JSON| API
API -->|Update| State
State -->|Render| UI
classDef frontend fill:#6366f1,color:#fff,stroke:#4338ca
classDef backend fill:#16a34a,color:#fff,stroke:#15803d
classDef database fill:#0891b2,color:#fff,stroke:#0e7490
classDef process fill:#8b5cf6,color:#fff,stroke:#7c3aed
classDef datasource fill:#ea580c,color:#fff,stroke:#c2410c
class UI,State,API frontend
class FastAPI,SearchEngine,LLM,QueryEmbedding backend
class Neo4j,Artists,Agents,Documents,Relationships database
class ArtistEmbed,AgentEmbed,DocEmbed,TextSplitter process
class SQL,PDF datasource
- Framework: Next.js with TypeScript
- Styling: TailwindCSS with custom animations
- Components:
- Chat interface with real-time updates
- Markdown rendering for formatted responses
- Loading states and animations
- API: FastAPI server handling query processing
- LLM Integration: OpenAI GPT-4 for response generation
- Embedding: OpenAI Ada-002 for text embeddings
- Database: Neo4j for graph storage and querying
- 🎨 Artists: Music artists with revenue data and embeddings
- 👥 Sales Agents: Representatives managing artists
- 📄 Documents: Embedded text chunks from documentation
MANAGED: Links sales agents to their managed artistsMENTIONS: Connects documents to referenced entitiesRELATED_TO: Creates semantic connections between similar documents
The graph structure enables:
- Contextual information retrieval
- Relationship-aware querying
- Semantic similarity search
- Multi-hop reasoning capabilities
- Node.js (v18+)
- Python (v3.8+)
- Neo4j Database
- OpenAI API Key
- Clone the repository
bash
git clone https://github.com/yourusername/graphrag.git
cd graphrag- Frontend Setup
cd src/frontend
npm install- Backend Setup
cd src/backend
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt- Neo4j Setup
- Install Neo4j Desktop
- Create a new database
- Set password to '12345678' or update in configuration
- Start the database
- Environment Variables
Create
.envfile in backend directory:
OPENAI_API_KEY=your_api_key_here
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=12345678- Start the Backend
cd src/backend
uvicorn generateResponse:app --reload- Start the Frontend
cd src/frontend
npm run dev- Access the Application Open http://localhost:3000 in your browser
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- OpenAI for GPT-4 and embeddings
- Neo4j for graph database
- Vercel for Next.js
- All contributors and supporters
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by @hrithikkoduri