# afreenshehanaaz/aws-agentic-rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/afreenshehanaaz/aws-agentic-rag-chatbot
- Repository: https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot

## Overview

This is an AWS documentation RAG assistant: PDFs are loaded, chunked, and stored; a Databricks-hosted retrieval-and-generation chain answers questions; and a Streamlit chat UI sends requests to its serving endpoint. The notebook also defines document-search, source-lookup, acronym, and topic tools, plus tracing and chat-memory features. The README is empty, and notebook excerpts omit some setup and wiring, so uncertain connections are left unasserted or marked dashed.

Main entry points: [`02_rag_chatbot.py`](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py) (Tool-calling agent), [`01_chunk_pdfs.py`](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/01_chunk_pdfs.py) (PDF loader and chunker), [`chatbot_app/app.py`](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/chatbot_app/app.py) (Streamlit chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document ingestion"]
  node_chunker["PDF loader and chunker<br/>[01_chunk_pdfs.py]"]
  node_chunks[("Chunk Delta table<br/>[01_chunk_pdfs.py]")]
  node_vector_index[("Vector Search index")]
end

subgraph group_rag["Retrieval and answers"]
  node_retriever["Document retriever<br/>[02_rag_chatbot.py]"]
  node_formatter["Context formatter<br/>[02_rag_chatbot.py]"]
  node_prompt["RAG prompt<br/>[02_rag_chatbot.py]"]
  node_llm["Hosted chat model<br/>[02_rag_chatbot.py]"]
  node_chain["Serving RAG chain<br/>[02_rag_chatbot.py]"]
end

subgraph group_serve["Serving and chat"]
  node_model_registry[("MLflow model registry")]
  node_endpoint["Databricks serving endpoint"]
  node_ui["Streamlit chat UI<br/>[app.py]"]
end

subgraph group_ops["Tools and observability"]
  node_search_tool["AWS document search<br/>[02_rag_chatbot.py]"]
  node_source_tool["Source lookup<br/>[02_rag_chatbot.py]"]
  node_acronym_tool["Acronym expansion<br/>[02_rag_chatbot.py]"]
  node_topics_tool["Topic listing<br/>[02_rag_chatbot.py]"]
  node_agent["Tool-calling agent<br/>[02_rag_chatbot.py]"]
  node_memory[("Conversation memory<br/>[02_rag_chatbot.py]")]
  node_tracking[("MLflow tracing<br/>[02_rag_chatbot.py]")]
end

node_user(("AWS questioner"))
node_pdfs["AWS PDF documents"]

node_pdfs -->|"loads pages"| node_chunker
node_chunker -->|"writes chunks"| node_chunks
node_chunks -.->|"indexes chunks"| node_vector_index
node_vector_index -.->|"retrieves documents"| node_retriever
node_retriever -->|"formats context"| node_formatter
node_formatter -->|"provides context"| node_prompt
node_prompt -->|"prompts model"| node_llm
node_llm -->|"generates answers"| node_chain
node_user -->|"asks question"| node_ui
node_ui -->|"posts invocation"| node_endpoint
node_endpoint -.->|"invokes model"| node_chain
node_chain -->|"logs model"| node_model_registry
node_agent -->|"calls tool"| node_search_tool
node_agent -->|"calls tool"| node_source_tool
node_agent -->|"calls tool"| node_acronym_tool
node_agent -->|"calls tool"| node_topics_tool
node_agent -.->|"uses history"| node_memory
node_retriever -->|"logs retrieval"| node_tracking
node_chain -->|"logs metrics"| node_tracking

click node_chunker "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/01_chunk_pdfs.py"
click node_chunks "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/01_chunk_pdfs.py"
click node_retriever "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_formatter "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_prompt "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_llm "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_chain "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_ui "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/chatbot_app/app.py"
click node_search_tool "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_source_tool "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_acronym_tool "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_topics_tool "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_agent "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_memory "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"
click node_tracking "https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py"

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_chunker,node_chunks,node_vector_index toneBlue
class node_retriever,node_formatter,node_prompt,node_llm,node_chain toneAmber
class node_model_registry,node_endpoint,node_ui toneMint
class node_search_tool,node_source_tool,node_acronym_tool,node_topics_tool,node_agent,node_memory,node_tracking toneRose
class node_user,node_pdfs toneIndigo
```

## Components

### Document ingestion

- [PDF loader and chunker](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/01_chunk_pdfs.py): `01_chunk_pdfs.py`
- [Chunk Delta table](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/01_chunk_pdfs.py): `01_chunk_pdfs.py`
- **Vector Search index**

### Retrieval and answers

- [Document retriever](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Context formatter](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [RAG prompt](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Hosted chat model](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Serving RAG chain](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`

### Serving and chat

- **MLflow model registry**
- **Databricks serving endpoint**
- [Streamlit chat UI](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/chatbot_app/app.py): `chatbot_app/app.py`

### Tools and observability

- [AWS document search](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Source lookup](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Acronym expansion](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Topic listing](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Tool-calling agent](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [Conversation memory](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`
- [MLflow tracing](https://github.com/afreenshehanaaz/aws-agentic-rag-chatbot/blob/main/02_rag_chatbot.py): `02_rag_chatbot.py`

### Other components

- **AWS questioner**
- **AWS PDF documents**

## Connections

- AWS PDF documents → PDF loader and chunker: loads pages (evidence: `01_chunk_pdfs.py`)
- PDF loader and chunker → Chunk Delta table: writes chunks (evidence: `01_chunk_pdfs.py`)
- Chunk Delta table → Vector Search index: indexes chunks
- Vector Search index → Document retriever: retrieves documents
- Document retriever → Context formatter: formats context (evidence: `02_rag_chatbot.py`)
- Context formatter → RAG prompt: provides context (evidence: `02_rag_chatbot.py`)
- RAG prompt → Hosted chat model: prompts model (evidence: `02_rag_chatbot.py`)
- Hosted chat model → Serving RAG chain: generates answers (evidence: `02_rag_chatbot.py`)
- AWS questioner → Streamlit chat UI: asks question (evidence: `chatbot_app/app.py`)
- Streamlit chat UI → Databricks serving endpoint: posts invocation (evidence: `chatbot_app/app.py`)
- Databricks serving endpoint → Serving RAG chain: invokes model
- Serving RAG chain → MLflow model registry: logs model (evidence: `02_rag_chatbot.py`)
- Tool-calling agent → AWS document search: calls tool (evidence: `02_rag_chatbot.py`)
- Tool-calling agent → Source lookup: calls tool (evidence: `02_rag_chatbot.py`)
- Tool-calling agent → Acronym expansion: calls tool (evidence: `02_rag_chatbot.py`)
- Tool-calling agent → Topic listing: calls tool (evidence: `02_rag_chatbot.py`)
- Tool-calling agent → Conversation memory: uses history (evidence: `02_rag_chatbot.py`)
- Document retriever → MLflow tracing: logs retrieval (evidence: `02_rag_chatbot.py`)
- Serving RAG chain → MLflow tracing: logs metrics (evidence: `02_rag_chatbot.py`)
