# backblaze-b2-samples/ai-rag-examples architecture

> Architecture diagram of the GitHub repository backblaze-b2-samples/ai-rag-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/backblaze-b2-samples/ai-rag-examples
- Repository: https://github.com/backblaze-b2-samples/ai-rag-examples

## Overview

This repository is a pair of notebook-based LLM demonstrations, not a packaged application. The principal workflow is the RAG notebook: a user asks a question, the notebook uses PDF context from Backblaze B2 and conversation history to generate a response. A separate notebook demonstrates local GPT4All question answering without custom context. The README documents these capabilities, but notebook source was not provided, so internal component boundaries and implementation-level calls cannot be verified.

Main entry points: [`rag_demo.ipynb`](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb) (RAG chatbot), [`gpt4all_demo.ipynb`](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/gpt4all_demo.ipynb) (GPT4All demo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demos["LLM demos"]
  node_gpt4all_demo["GPT4All demo<br/>[gpt4all_demo.ipynb]"]
  node_rag_demo["RAG chatbot<br/>[rag_demo.ipynb]"]
end

subgraph group_rag["RAG workflow"]
  node_pdf_context["PDF context<br/>[rag_demo.ipynb]"]
  node_conversation_history["Message history<br/>[rag_demo.ipynb]"]
end

subgraph group_services["External services"]
  node_local_llm["Local LLM"]
  node_b2_bucket[("B2 bucket")]
  node_langchain["LangChain"]
end

node_user(("User"))

node_user -->|"asks questions"| node_gpt4all_demo
node_gpt4all_demo -->|"loads model"| node_local_llm
node_gpt4all_demo -->|"answers questions"| node_user
node_user -->|"asks questions"| node_rag_demo
node_rag_demo -->|"uses framework"| node_langchain
node_rag_demo -->|"loads PDF context"| node_b2_bucket
node_b2_bucket -->|"provides PDFs"| node_pdf_context
node_rag_demo -->|"uses history"| node_conversation_history
node_rag_demo -->|"returns responses"| node_user

click node_gpt4all_demo "https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/gpt4all_demo.ipynb"
click node_rag_demo "https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb"
click node_pdf_context "https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb"
click node_conversation_history "https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gpt4all_demo,node_rag_demo,node_user toneBlue
class node_pdf_context,node_conversation_history toneAmber
class node_local_llm,node_b2_bucket,node_langchain toneMint
```

## Components

### LLM demos

- [GPT4All demo](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/gpt4all_demo.ipynb): `gpt4all_demo.ipynb`
- [RAG chatbot](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb): `rag_demo.ipynb`

### RAG workflow

- [PDF context](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb): `rag_demo.ipynb`
- [Message history](https://github.com/backblaze-b2-samples/ai-rag-examples/blob/main/rag_demo.ipynb): `rag_demo.ipynb`

### External services

- **Local LLM**
- **B2 bucket**
- **LangChain**

### Other components

- **User**

## Connections

- User → GPT4All demo: asks questions (evidence: `README.md`)
- GPT4All demo → Local LLM: loads model (evidence: `README.md`)
- GPT4All demo → User: answers questions (evidence: `README.md`)
- User → RAG chatbot: asks questions (evidence: `README.md`)
- RAG chatbot → LangChain: uses framework (evidence: `README.md`)
- RAG chatbot → B2 bucket: loads PDF context (evidence: `README.md`)
- B2 bucket → PDF context: provides PDFs (evidence: `README.md`)
- RAG chatbot → Message history: uses history (evidence: `README.md`)
- RAG chatbot → User: returns responses (evidence: `README.md`)
