How karanjain09/graph-rag-ai-bot works
Project type and purpose
• This is a full-stack AI-driven chatbot application (“Graph-RAG-AI-Bot”) that lets users enter a website URL, scrapes and processes its content into a knowledge graph, and uses an LLM to answer user queries in a chat interface.
File structure
• Top-level scripts and modules:
• app.py – orchestrates HTTP server (Chainlit) and routes user input/queries
• web_scraper.py – fetches and parses HTML (BeautifulSoup)
• text_chunker.py – splits markdown text into logical chunks
• neo4j_manager.py – interfaces with Neo4j for storage and semantic retrieval
• llm_client.py – calls Groq’s API for LLaMA 3.3 inference
• config.py – loads environment variables (Neo4j URI/creds, Groq API key)
• requirements.txt lists dependencies; .gitignore excludes env files, caches, etc.
Extract architecture from the README
• Eight-step flow (Input → Scrape → Convert → Chunk → Store → Query → Generate → Output)
• Frontend: Chainlit chat interface served by app.py
• Persistence: Neo4j graph database
• External service: Groq LLaMA API
Main components
a. Presentation Layer
• User’s web browser
• Chainlit UI (within app.py process)
b. Application Layer
• Web Scraper module
• HTML→Markdown Converter (can be shown as part of web_scraper or a separate submodule)
• Text Chunker module
• Neo4j Manager module
• LLM Client module
• Orchestrator / Router (app.py)
c. Data Layer
• Neo4j Graph Database
d. External Services
• Groq API endpoint for LLaMA 3.3 inference
e. Configuration
• Environment/config module (config.py) feeding credentials to the Neo4j Manager and LLM Client
Relationships and data flow
• URL → Web Scraper → HTML
• HTML → Markdown Converter → Markdown
• Markdown → Text Chunker → Content Chunks
• Chunks → Neo4j Manager → Neo4j (store / index)
• For user queries:
• User → Chainlit UI → Orchestrator
• Orchestrator → Neo4j Manager → retrieve relevant chunks
• Retrieved chunks → LLM Client → Groq API → Response Text
• Response → Chainlit UI → User
Architectural patterns and design principles
• Modular pipeline: each processing step in its own module (single responsibility)
• Layered architecture: clear separation between presentation, application logic, persistence, and external services
• Dependency injection of config values (via config.py and environment variables)
• Graph-based retrieval pattern (RAG) for semantic search
Relevant technologies & libraries
• Python 3.8+
• Chainlit (chat UI framework)
• BeautifulSoup (web_scraping)
• Markdown converter library (e.g., markdownify)
• Neo4j with official Python driver
• Groq API for LLaMA 3.3
• Environment management (.env)
Next steps for the principal software engineer
• Validate with stakeholders and iterate, ensuring every module and its interaction is captured succinctly.