# anujsonawane60/rag_pipeline_v3_docker architecture

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

- Interactive diagram: https://gitdiagram.com/anujsonawane60/rag_pipeline_v3_docker
- Repository: https://github.com/anujsonawane60/rag_pipeline_v3_docker

## Overview

- Frontend Client:
- Represented by the static HTML files (index.html, chatbot.html) housed in the “static” folder.
- This is the UI that users interact with via a web browser.
- Backend API Server:
- Represented by main.py, which is the FastAPI application serving as the backend.
- This component processes requests, handles file uploads, manages chatbots, validates documents (using tools like PyPDF2 and docx), and routes API calls.
- Language Model Integration:
- Incorporate components for each external service: OpenAI, Cohere, and TogetherAI.
- Document and Context Management:
- A dedicated module for managing document uploads, file validations (PDF, DOCX, TXT), and creating the necessary context for the chatbot.
- Vector Database/Indexing:
- Use a separate component for Pinecone, which is used to support vector-based retrieval during conversations.
- Deployment and Containerization:
- Docker container (via Dockerfile and .dockerignore) which encapsulates the application for deployment.

##### Relationships and interactions
- From the Backend API Server, illustrate outgoing API calls to each of the LLM providers (OpenAI, Cohere, TogetherAI) indicating which language model is used for generating responses.
- Backend API Server to the Pinecone component to show the flow of vector data for context retrieval.
- Document upload pathway by connecting the Frontend to the dedicated file parsing/validation module within the backend.

##### Important architectural patterns and design principles
- Separation of concerns between the frontend (static content) and the backend (API logic).
- That the system follows a modular design where each integration (LLM, Pinecone, file validation) is an independently replaceable or updateable component.
- It’s valuable to note that the use of FastAPI facilitates asynchronous handling of requests, an important detail for high-efficiency API communication.

##### Relevant technologies, frameworks, and libraries
- FastAPI as the main web framework.
- Uvicorn as the ASGI server.
- Python (with dependencies listed in requirements.txt).
- LLM integration services: OpenAI, Cohere, TogetherAI.
- Pinecone for vector search.
- File parsing libraries: PyPDF2 for PDFs and docx for DOCX files.
- Docker for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Client"
        FE1("Index Page"):::frontend
        FE2("Chatbot Page"):::frontend
    end

    %% Document & Context Management Module
    DOC("Document & Context Manager"):::backend

    %% Backend API Server
    BE("API Server"):::backend

    %% LLM Integration Nodes
    LLM1("OpenAI"):::integration
    LLM2("Cohere"):::integration
    LLM3("TogetherAI"):::integration

    %% Vector Database / Indexing
    VEC("Pinecone"):::external

    %% Deployment and Containerization Subgraph
    subgraph "Deployment"
        DC1("Dockerfile"):::container
        DC2(".dockerignore"):::container
    end

    %% Connections from Frontend to Backend and Document Processing
    FE1 -->|"loads"| BE
    FE2 -->|"user action"| BE
    FE2 -->|"uploadFile"| DOC
    DOC -->|"validatedDoc"| BE

    %% Backend API Server interactions with LLM Integrations
    BE -->|"modelCall"| LLM1
    BE -->|"modelCall"| LLM2
    BE -->|"modelCall"| LLM3

    LLM1 -->|"LLMResponse"| BE
    LLM2 -->|"LLMResponse"| BE
    LLM3 -->|"LLMResponse"| BE

    %% Backend interaction with Vector Database
    BE -->|"vectorSearch"| VEC
    VEC -->|"retrievedContext"| BE

    %% Deployment arrows
    BE -->|"containerized"| DC1
    BE -->|"containerized"| DC2

    %% Click Events
    click FE1 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/static/index.html"
    click FE2 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/static/chatbot.html"
    click BE "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click DOC "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click LLM1 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click LLM2 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click LLM3 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click VEC "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/main.py"
    click DC1 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/tree/main/Dockerfile"
    click DC2 "https://github.com/anujsonawane60/rag_pipeline_v3_docker/blob/main/.dockerignore"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef integration fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef container fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
