# parth1609/ragveda architecture

> Architecture diagram of the GitHub repository parth1609/ragveda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parth1609/ragveda
- Repository: https://github.com/parth1609/ragveda

## Overview

##### Project type and purpose
- This is a full-stack Retrieval-Augmented Generation (RAG) application for intelligent document ingestion, knowledge-graph creation, and natural-language question answering.
- It uses Streamlit as a lightweight frontend, Neo4j as a graph database backend, and Groq LLM for response generation.

##### File structure
- Top-level files:
- main.py (or app.py) – entry point for the Streamlit UI
- requirements.txt, .env.example – environment and dependency configuration
- notebooks (RAGVeda.ipynb, graphrag.ipynb) – exploratory/Colab demos
- modules/ directory:
- config.py – loads environment variables and settings
- document_processor.py – PDF ingestion, chunking, entity extraction
- neo4j_manager.py – Neo4j connection, schema setup, CRUD APIs for graph
- retrieval.py – graph-based search logic
- llm_chain.py – prompt construction, Groq API calls, LLM orchestration
- ui_components.py – Streamlit UI widgets and layouts
- dataset/ and output/ – sample input CSV and generated graph visuals

##### README for additional insights
- Features: knowledge graph integration, natural-language QA, custom prompts
- Tech stack: Streamlit (UI), Neo4j (DB), Groq LLM
- Document processing flow and query processing flow are spelled out
- Core components named: GraphRAG, Neo4jGraph, GraphQAChain

a. Main Components
1. Streamlit Frontend (modules/ui_components.py + main.py)
2. Configuration Loader (modules/config.py)
3. Document Processing Pipeline (modules/document_processor.py)
4. Graph Database Manager (modules/neo4j_manager.py + Neo4j instance)
5. Retrieval Engine (modules/retrieval.py)
6. LLM Chain (modules/llm_chain.py + external Groq API)
7. Data Stores: Neo4j Graph DB, local dataset directory
b. Relationships and Interactions
- Ingestion flow: User → UI → Document Processor → Neo4j Manager → Neo4j
- Query flow: User Query → UI → LLM Chain → Retrieval Engine → Neo4j → Context → LLM Chain → UI
- Configuration feeds into all modules at startup
c. Architectural Patterns and Principles
- Pipeline pattern for ingestion and query processing
- Single-page-style interactive UI with separated business logic
- Clear separation of concerns: UI, config, processing, data access, LLM orchestration
d. Relevant Technologies
- Python
- Streamlit
- Neo4j (Bolt protocol)
- Groq LLM API
- Environment variables (.env)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Configuration Layer
    subgraph "Configuration"
        Config["Configuration Loader\nmodules/config.py"]:::config
        Env[".env.example"]:::config
    end

    %% UI Layer
    subgraph "UI Layer"
        UI_main["Streamlit UI\nmain.py"]:::ui
        UI_comp["UI Components\nmodules/ui_components.py"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        DocProc["Document Processor\nmodules/document_processor.py"]:::logic
        Retrieval["Retrieval Engine\nmodules/retrieval.py"]:::logic
        LLMChain["LLM Chain\nmodules/llm_chain.py"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        NeoMgr["Neo4j Manager\nmodules/neo4j_manager.py"]:::db
        NeoDB["Neo4j Graph DB"]:::db
        Dataset["Local Dataset Store\ndataset/"]:::db
        Output["Graph Outputs\noutput/"]:::db
    end

    %% External Services
    subgraph "External Services"
        Groq["Groq LLM API"]:::external
    end

    %% Documentation
    subgraph "Documentation"
        Docs1["RAGVeda Notebook\nnotebooks/RAGVeda.ipynb"]:::docs
        Docs2["GraphRAG Notebook\nnotebooks/graphrag.ipynb"]:::docs
    end

    %% Data Flows
    Config --> UI_main
    Config --> UI_comp
    Config --> DocProc
    Config --> Retrieval
    Config --> LLMChain

    UI_main --> UI_comp
    UI_main -->|ingest document| DocProc
    DocProc -->|read sample| Dataset
    DocProc -->|chunk & extract| DocProc
    DocProc -->|push graph| NeoMgr
    NeoMgr -->|setup & CRUD| NeoDB
    DocProc -->|store visuals| Output

    UI_main -->|user query| Retrieval
    Retrieval -->|cypher query| NeoMgr
    NeoMgr -->|query data| NeoDB
    NeoDB -->|entities| Retrieval
    Retrieval -->|context| LLMChain
    LLMChain -->|prompt| Groq
    Groq -->|response| LLMChain
    LLMChain -->|answer| UI_main

    %% Documentation Links
    UI_main --> Docs1
    UI_main --> Docs2

    %% Click Events
    click UI_main "https://github.com/parth1609/ragveda/blob/main/main.py"
    click UI_comp "https://github.com/parth1609/ragveda/blob/main/modules/ui_components.py"
    click Config "https://github.com/parth1609/ragveda/blob/main/modules/config.py"
    click Env "https://github.com/parth1609/ragveda/blob/main/.env.example"
    click DocProc "https://github.com/parth1609/ragveda/blob/main/modules/document_processor.py"
    click NeoMgr "https://github.com/parth1609/ragveda/blob/main/modules/neo4j_manager.py"
    click Retrieval "https://github.com/parth1609/ragveda/blob/main/modules/retrieval.py"
    click LLMChain "https://github.com/parth1609/ragveda/blob/main/modules/llm_chain.py"
    click Dataset "https://github.com/parth1609/ragveda/tree/main/dataset/"
    click Output "https://github.com/parth1609/ragveda/tree/main/output/"
    click Docs1 "https://github.com/parth1609/ragveda/blob/main/notebooks/RAGVeda.ipynb"
    click Docs2 "https://github.com/parth1609/ragveda/blob/main/notebooks/graphrag.ipynb"

    %% Styles
    classDef config fill:#d3d3d3,stroke:#999,stroke-width:1px,color:#000
    classDef ui fill:#e0f7fa,stroke:#0288d1,stroke-width:2px,color:#01579b
    classDef logic fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px,color:#1b5e20
    classDef db fill:#fff9c4,stroke:#f9a825,stroke-width:2px,color:#f57f17
    classDef external fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px,color:#e65100
    classDef docs fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px,color:#4a148c
```
