# paragd004/llm_and_rag architecture

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

- Interactive diagram: https://gitdiagram.com/paragd004/llm_and_rag
- Repository: https://github.com/paragd004/llm_and_rag

## Overview

##### Project type and purpose
- This is an “AI demo” repository showcasing several Jupyter-based pipelines that combine local LLMs (via Ollama) with Retrieval-Augmented Generation (RAG).
- Key use cases provided as notebooks:
- Airline AI Assistant
- Expert Knowledge Worker (with a local markdown knowledge base)
- Webpage Summarizer

##### File structure
- Top-level notebooks (Airline AI Assistant.ipynb, Web Page Summarizer.ipynb) and one subfolder “Expert Knowledge worker” containing:
- A Jupyter notebook for the Expert Knowledge Worker workflow
- A “knowledge-base” directory full of markdown docs grouped into company, contracts, employees, products
- Configuration file `.env.local.txt` for secrets (vector DB credentials, Ollama settings)

##### README for additional insights
- States reliance on Ollama to run open-source LLMs locally
- Requires Python + the `ollama` client library for RAG code
- Mentions a Vector DB storing embeddings (“RAG enhances by retrieving relevant docs…”)

##### Main components
a. User Interface (Jupyter Notebooks)
b. RAG Orchestration Service (Python code invoked in the notebooks)
c. Knowledge Base (local markdown files)
d. Vector Database (e.g., Pinecone, Weaviate) storing your document embeddings
e. Ollama LLM Engine (local LLaMA-3 process managed by Ollama)
f. Configuration Layer (.env.local.txt for secrets/config)

##### Relationships and interactions
1. The user writes/executes code in a notebook (Airline AI Assistant / Expert Knowledge Worker / Webpage Summarizer).
2. Notebook code reads `.env.local.txt` → initializes Vector DB client and Ollama client.
3. RAG pipeline:
- Load selected docs from Knowledge Base → compute or retrieve embeddings → query Vector DB for top-k relevant docs
- Assemble prompt: user question + retrieved docs context
- Send prompt via Ollama Python client → Ollama spawns or routes to local LLaMA-3 model → returns generated answer
4. Notebook renders the “Informed Answer.”

##### Architectural patterns/design principles
- Separation of concerns: UI (notebook) vs. orchestration (RAG code) vs. data (markdown KB + vector store) vs. compute (LLM engine)
- RAG as a two-step pipeline: Retrieve then Generate
- Local-first AI: all heavy compute runs in your environment (no external API calls)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface Layer
    subgraph "User Interface" 
        direction TB
        NotebookAirline["Airline AI Assistant.ipynb"]:::ui
        NotebookExpert["Expert Knowledge Worker.ipynb"]:::ui
        NotebookWeb["Web Page Summarizer.ipynb"]:::ui
    end

    %% Orchestrator Service
    Orchestrator["Python RAG Orchestrator"]:::service

    %% Configuration Layer
    Config[".env.local.txt"]:::config
    Docs["README.md"]:::docs

    %% Data Storage
    KB["Local Knowledge-Base (Markdown files)"]:::storage
    VecDB["Vector DB (Embeddings store)"]:::storage

    %% LLM Engine
    Ollama["Ollama LLM Engine (LLaMA-3)"]:::llm

    %% Connections
    NotebookAirline -->|"execute RAG pipeline"| Orchestrator
    NotebookExpert -->|"execute RAG pipeline"| Orchestrator
    NotebookWeb -->|"execute RAG pipeline"| Orchestrator

    Config -->|"load config"| Orchestrator
    Docs -.->|"documentation"| Orchestrator

    Orchestrator -->|"load docs"| KB
    Orchestrator -->|"query embeddings"| VecDB

    Orchestrator -->|"send prompt"| Ollama
    Ollama -->|"return text"| Orchestrator

    Orchestrator -->|"display answer"| NotebookAirline
    Orchestrator -->|"display answer"| NotebookExpert
    Orchestrator -->|"display answer"| NotebookWeb

    %% Click Events
    click NotebookAirline "https://github.com/paragd004/llm_and_rag/blob/main/Airline AI Assistant/Airline AI assistant.ipynb"
    click NotebookExpert "https://github.com/paragd004/llm_and_rag/blob/main/Expert Knowledge worker/Expert Knowledge Worker.ipynb"
    click NotebookWeb "https://github.com/paragd004/llm_and_rag/blob/main/Webpage Summarizer/Web Page Summarizer.ipynb"
    click Config "https://github.com/paragd004/llm_and_rag/blob/main/.env.local.txt"
    click KB "https://github.com/paragd004/llm_and_rag/tree/main/Expert Knowledge worker/knowledge-base/"
    click Docs "https://github.com/paragd004/llm_and_rag/blob/main/README.md"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0094FF,color:#000
    classDef service fill:#DFFFE0,stroke:#28A745,color:#000
    classDef config fill:#FFF5C2,stroke:#FFC107,color:#000
    classDef docs fill:#EEEEEE,stroke:#666666,color:#000,stroke-dasharray: 5 5
    classDef storage fill:#FFE0B2,stroke:#FF9800,color:#000
    classDef llm fill:#E1D5FF,stroke:#6F42C1,color:#000
```
