# anujsoni9450/ai-pdf-assistant-llama3 architecture

> Architecture diagram of the GitHub repository anujsoni9450/ai-pdf-assistant-llama3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anujsoni9450/ai-pdf-assistant-llama3
- Repository: https://github.com/anujsoni9450/ai-pdf-assistant-llama3

## Overview

This is a Streamlit PDF question-answering app. A user uploads a PDF, the app saves it and indexes its text as embedded chunks in a local Chroma database. For questions, the app builds a retriever-backed RAG chain, which supplies relevant chunks to a Groq language model and displays the answer. The excerpts show the main calls and storage configuration; some framework-internal retrieval and service behavior is not shown.

Main entry points: [`app.py`](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/app.py) (Streamlit app), [`src/generator.py`](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py) (RAG chain), [`src/ingestion.py`](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py) (PDF loader), [`src/retrieval.py`](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/retrieval.py) (Retriever)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_indexing["PDF indexing"]
  node_pdf["PDF loader<br/>[ingestion.py]"]
  node_chunking["Text chunking<br/>[ingestion.py]"]
  node_embedding["Embeddings<br/>[ingestion.py]"]
  node_vector_store[("Chroma store<br/>[ingestion.py]")]
end

subgraph group_qa["Question answering"]
  node_retrieval["Retriever<br/>[retrieval.py]"]
  node_rag_chain["RAG chain<br/>[generator.py]"]
  node_prompt["Answer prompt<br/>[generator.py]"]
  node_llm["Groq LLM<br/>[generator.py]"]
end

node_user(("User"))
node_groq{{"Groq service"}}

node_user -->|"uploads PDF, asks"| node_app
node_app -->|"indexes PDF"| node_pdf
node_pdf -->|"loads documents for"| node_chunking
node_chunking -->|"embeds chunks for"| node_embedding
node_embedding -->|"stores vectors in"| node_vector_store
node_app -->|"gets retriever"| node_retrieval
node_retrieval -->|"opens persistent store"| node_vector_store
node_app -->|"creates chain with retriever"| node_rag_chain
node_rag_chain -->|"creates document-answer chain"| node_prompt
node_rag_chain -->|"configures chain with"| node_llm
node_llm -.->|"calls model"| node_groq
node_app -->|"invokes with question"| node_rag_chain
node_rag_chain -->|"returns answer"| node_app
node_app -->|"displays answer"| node_user

click node_app "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/app.py"
click node_pdf "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py"
click node_chunking "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py"
click node_embedding "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py"
click node_vector_store "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py"
click node_retrieval "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/retrieval.py"
click node_rag_chain "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py"
click node_prompt "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py"
click node_llm "https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.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_app,node_user toneBlue
class node_pdf,node_chunking,node_embedding,node_vector_store toneAmber
class node_retrieval,node_rag_chain,node_prompt,node_llm toneMint
class node_groq toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/app.py): `app.py`

### PDF indexing

- [PDF loader](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py): `src/ingestion.py`
- [Text chunking](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py): `src/ingestion.py`
- [Embeddings](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py): `src/ingestion.py`
- [Chroma store](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/ingestion.py): `src/ingestion.py`

### Question answering

- [Retriever](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/retrieval.py): `src/retrieval.py`
- [RAG chain](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py): `src/generator.py`
- [Answer prompt](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py): `src/generator.py`
- [Groq LLM](https://github.com/anujsoni9450/ai-pdf-assistant-llama3/blob/main/src/generator.py): `src/generator.py`

### Other components

- **User**
- **Groq service**

## Connections

- User → Streamlit app: uploads PDF, asks (evidence: `app.py`)
- Streamlit app → PDF loader: indexes PDF (evidence: `app.py`)
- PDF loader → Text chunking: loads documents for (evidence: `src/ingestion.py`)
- Text chunking → Embeddings: embeds chunks for (evidence: `src/ingestion.py`)
- Embeddings → Chroma store: stores vectors in (evidence: `src/ingestion.py`)
- Streamlit app → Retriever: gets retriever (evidence: `app.py`)
- Retriever → Chroma store: opens persistent store (evidence: `src/retrieval.py`)
- Streamlit app → RAG chain: creates chain with retriever (evidence: `app.py`)
- RAG chain → Answer prompt: creates document-answer chain (evidence: `src/generator.py`)
- RAG chain → Groq LLM: configures chain with (evidence: `src/generator.py`)
- Groq LLM → Groq service: calls model
- Streamlit app → RAG chain: invokes with question (evidence: `app.py`)
- RAG chain → Streamlit app: returns answer (evidence: `app.py`)
- Streamlit app → User: displays answer (evidence: `app.py`)
