# zeussama0001/rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/zeussama0001/rag-chatbot
- Repository: https://github.com/zeussama0001/rag-chatbot

## Overview

##### Main Components

a) Input Layer:
- User Interface (Chainlit Web Interface)
- Document Ingestion System (PDF Handler)

b) Processing Layer:
- Vector Store System (FAISS)
- LLM Integration (Llama-2-7B-Chat)
- RAG Pipeline Orchestrator

c) Storage Layer:
- FAISS Vector Database
- Document Storage

##### Component Relationships and Data Flow

a) Document Processing Flow:
- PDF Documents → Ingestion System → Vector Embeddings → FAISS Storage

b) Query Processing Flow:
- User Query → Vector Embedding → FAISS Retrieval → LLM Context Enhancement → Response Generation → User Interface

##### Specific Implementation Details

- Blue rectangles for user-facing components (Chainlit UI)
- Green rectangles for processing components (LLM, Vector Store)
- Purple rectangles for integration components (Sentence Transformers, Langchain)

##### Key Technical Elements to Highlight

a) Infrastructure Components:
- FAISS Vector Store (/vectorstore/db_faiss)
- PDF Document Storage (/data)
- Llama2 Model Integration

b) Processing Components:
- Document Ingestion (ingest.py)
- Model Interface (model.py)
- Chainlit Web Interface

##### Architectural Patterns to Emphasize

- RAG Architecture Pattern
- Vector Similarity Search
- Asynchronous Processing
- Document Processing Pipeline

##### Implementation Notes

- Component relationships
- Technology stack references

Key Considerations:

##### Two main workflows
- Document ingestion pipeline
- Query processing pipeline

##### Clear separation between
- Storage layer (FAISS, document storage)
- Processing layer (LLM, embedding generation)
- Presentation layer (Chainlit interface)

##### Integration points
- Document processing integrations
- LLM model integration
- Vector store interactions

This system design should clearly communicate how the RAG bot processes documents, handles queries, and generates responses using the combination of vector storage and language model capabilities.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        UI[Chainlit Web Interface]
        DI[Document Ingestion System]
    end

    subgraph Processing
        VP[RAG Pipeline Orchestrator]
        LLM[Llama-2-7B-Chat]
        ST[Sentence Transformers]
    end

    subgraph Storage
        VS[(FAISS Vector Store)]
        DS[(Document Storage)]
    end

    %% Data Flow
    DI -->|PDF Processing| ST
    ST -->|Generate Embeddings| VS
    DS -->|Source Documents| DI
    
    UI -->|User Query| VP
    VP -->|Query Embedding| ST
    ST -->|Vector Search| VS
    VS -->|Retrieved Context| VP
    VP -->|Enhanced Context| LLM
    LLM -->|Generated Response| VP
    VP -->|Final Answer| UI

    %% Styling
    classDef interface fill:#6495ED
    classDef processing fill:#98FB98
    classDef storage fill:#FFD700
    classDef integration fill:#DDA0DD

    class UI interface
    class DI processing
    class VP processing
    class LLM processing
    class ST integration
    class VS storage
    class DS storage

    %% Click Events
    click DI "https://github.com/ZeusSama0001/RAG-chatbot/blob/main/ingest.py"
    click UI "https://github.com/ZeusSama0001/RAG-chatbot/blob/main/chainlit.md"
    click VP "https://github.com/ZeusSama0001/RAG-chatbot/blob/main/model.py"
    click VS "https://github.com/ZeusSama0001/RAG-chatbot/tree/main/vectorstore/db_faiss/"
    click DS "https://github.com/ZeusSama0001/RAG-chatbot/tree/main/data/"

    %% Legend
    subgraph Legend
        L1[User Interface]:::interface
        L2[Processing Component]:::processing
        L3[(Storage)]:::storage
        L4[Integration]:::integration
    end
```
