# sebulba46/document-rag-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/sebulba46/document-rag-pipeline
- Repository: https://github.com/sebulba46/document-rag-pipeline

## Overview

##### Main components
- Open-WebUI & Pipelines Container: This component hosts the RAG pipeline logic (e.g., document_RAG.py) and the necessary Python libraries (like llama-index libraries) for document processing. It is responsible for managing document ingestion, processing, and invoking the RAG pipeline.
- VLLM Container: This container runs the local LLM (the small 7B Mistral model) and is deployed via its own Docker Compose configuration.
- Docker Compose Environment: Represents the orchestration layer managing the two containers.
- External/Local Resources: These can include the PDF documents (or other documents) that are parsed for information, as well as any configuration details such as file paths or embedding choices.

##### Out relationships and interactions
- The Open-WebUI/pipelines container interacts with the user interface and serves as the front-facing endpoint where users can upload documents or define prompts.
- The pipelines container executes the RAG document pipeline (via document_RAG.py) by calling the necessary libraries to process documents and generate embeddings.
- Once a document is processed, the container forwards requests (or queries) to the VLLM container, which runs the local 7B Mistral model that generates responses based on the processed inputs.
- The Docker Compose setup interlinks these containers, ensuring network communication and dependency management.
- There is an inherent data flow from document ingestion, through processing, to LLM-based generation.

##### Important architectural patterns/design principles
- Microservices/Containerization: Each major functionality is isolated in its own container (i.e., one for Open-WebUI and one for VLLM), following a microservice-like approach.
- Pipeline Pattern: The RAG pipeline processes documents sequentially through several stages (embedding extraction, prompt configuration, model inference).
- Modular Deployment: Flexibility is provided by docker-compose files for both components, allowing independent scaling or modifications.

##### Relevant technologies, frameworks, or libraries
- Docker & Docker Compose: For deploying and orchestrating containers.
- Open-WebUI: Provides the front-end and interaction capabilities.
- VLLM Container: Runs the local LLM (7B Mistral).
- Python Libraries: llama-index and its variants (llama-index-core, llama-index-llms-openai-like, etc.), which are crucial for document processing and integration with LLM.
- Local File System & External Document Path: The README even explains modifications to PDF paths, which should be noted.

- For example, use rectangles for containers (Open-WebUI/Pipelines and VLLM).
- From the user (or document input source) to the Open-WebUI.
- From Open-WebUI to the pipelines execution (document_RAG.py) to indicate processing.
- From the pipelines to the VLLM container to illustrate LLM query invocation.
- Back from the VLLM container to the pipelines and then returning the response to the UI.
- Configuration and library-level dependencies (e.g., “llama-index libraries”) as annotations near the pipelines component.
- Optionally, include the Docker Compose symbols to show how both containers are orchestrated, indicating shared networks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User"]:::external
    B["Document Input (PDF/Docs)"]:::external

    subgraph "Open-WebUI & Pipeline Container"
        U["Open-WebUI Interface"]:::container
        P["Pipeline Script (document_RAG.py)"]:::container
    end

    C["VLLM Container (Local 7B Mistral Model)"]:::container
    D["User Response"]:::external
    E["Docker Compose Orchestration"]:::orchestration

    A -->|"uploads"| B
    B -->|"triggers"| U
    U -->|"initiates"| P
    P -->|"queries"| C
    C -->|"returns"| P
    P -->|"sends"| D

    E -.->|"orchestrates"| U
    E -.->|"orchestrates"| C

    click U "https://github.com/sebulba46/document-rag-pipeline/blob/main/Open-Webui compose/docker-compose.yml"
    click P "https://github.com/sebulba46/document-rag-pipeline/blob/main/Open-Webui compose/document_RAG.py"
    click C "https://github.com/sebulba46/document-rag-pipeline/blob/main/vllm compose/docker-compose.yml"

    classDef container fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef orchestration fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
```
