How shettysach/imdb-knowledge-graph-rag works
Project type and purpose
• This is a full-stack knowledge-graph application with a Retrieval-Augmented Generation (RAG) pipeline.
• It ingests the IMDb Top 250 dataset, builds a Neo4j knowledge graph (nodes: Movie, Genre, Person; relationships: ACTED_IN, DIRECTED, WROTE, BELONGS_TO), then exposes a Streamlit front-end that lets users ask natural-language questions. Questions are processed by LangChain + Gemini to generate Cypher, query Neo4j, and return answers.
File structure
• Top level:
• .env_template / .gitignore / requirements.txt – environment and dependencies
• assets/ – static visuals (graph screenshots)
• data/ – raw CSV (imdb.csv)
• src/ – core Python and notebooks
– Knowledge_Graph.ipynb – offline graph-construction pipeline
– Graph_RAG.ipynb – RAG pipeline demonstration
– App.py – Streamlit application
Key insights from the README
• Components: Neo4j database, LangChain + Gemini API, Streamlit UI
• Workflow: data ingestion → graph construction → RAG query pipeline → UI presentation
• External dependencies: Neo4j server, Gemini API key
Main components & interactions
a. Data Ingestion & Graph Construction (batch/offline)
• Component: “CSV Dataset” (data/imdb.csv)
• Component: “Graph Builder Notebook” (Knowledge_Graph.ipynb)
b. Runtime RAG Pipeline
• Component: “User Interface (Streamlit App)” (App.py)
• Component: “RAG Engine” (LangChain orchestrator)
• Component: “LLM Service” (Gemini API)
• Component: “Graph Database” (Neo4j)
• Flow: User enters prompt → Streamlit App → RAG Engine
→ (1) send prompt to Gemini → receive LLM response (Cypher query)
→ (2) send Cypher to Neo4j → get JSON result
→ (3) RAG Engine processes JSON → returns natural-language answer
→ Streamlit displays answer
c. Supporting components
• Component: “Environment & Config” (.env) – contains Neo4j credentials and Gemini API key
• Component: “Dependencies” (requirements.txt)
Architectural patterns & design principles
• Layered architecture:
• Presentation layer (Streamlit UI)
• Application/service layer (RAG Engine orchestrating LLM + DB calls)
• Data layer (Neo4j)
• Batch vs. real-time separation: graph build offline, query pipeline online
• Use of external microservice (Gemini API) and managed graph store (Neo4j)
• Clear separation of concerns: data ingestion, graph storage, LLM orchestration, UI