# chandana2556/chat-with-pdfs architecture

> Architecture diagram of the GitHub repository chandana2556/chat-with-pdfs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandana2556/chat-with-pdfs
- Repository: https://github.com/chandana2556/chat-with-pdfs

## Overview

Chat with PDFs is a Streamlit application for indexing uploaded PDFs and answering questions with retrieved document context and page citations. The principal workflow runs from upload and page extraction through chunking, local embeddings, FAISS retrieval, and a configurable LLM response; session chat history and source citations are presented in the UI. The graph follows documented architecture and sampled call sites; provider selection is explicit in source, while vector-store persistence helpers are present but no app-level save/load invocation is shown.

Main entry points: [`src/rag_pipeline.py`](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/rag_pipeline.py) (RAG pipeline), [`app.py`](https://github.com/chandana2556/chat-with-pdfs/blob/main/app.py) (Streamlit UI), [`src/llm.py`](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/llm.py) (Answer generation), [`src/vector_store.py`](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/vector_store.py) (FAISS vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_app["Streamlit UI<br/>[app.py]"]
  node_chatstate[("Session chat<br/>[app.py]")]
  node_uploads["Uploaded PDFs"]
end

subgraph group_indexing["PDF indexing"]
  node_extract["Page extraction<br/>[pdf_processor.py]"]
  node_split["Chunk splitting<br/>[text_splitter.py]"]
  node_embed["Local embeddings<br/>[embeddings.py]"]
  node_vector[("FAISS vector store<br/>[vector_store.py]")]
end

subgraph group_retrieval["Search and generation"]
  node_pipeline["RAG pipeline<br/>[rag_pipeline.py]"]
  node_retriever["Chunk retrieval<br/>[retriever.py]"]
  node_llm["Answer generation<br/>[llm.py]"]
end

subgraph group_integrations["Models and storage"]
  node_config["App configuration<br/>[config.py]"]
  node_diskindex[("Saved index")]
  node_anthropic{{"Anthropic API"}}
  node_openai{{"OpenAI API"}}
  node_gemini{{"Gemini API"}}
end

node_user(("PDF user"))

node_user -->|"uploads, asks"| node_app
node_app -->|"writes files"| node_uploads
node_app -->|"processes PDFs"| node_pipeline
node_app -->|"submits question"| node_pipeline
node_app -->|"updates history"| node_chatstate
node_chatstate -->|"supplies history"| node_app
node_pipeline -->|"extracts pages"| node_extract
node_extract -->|"passes page text"| node_split
node_pipeline -->|"splits pages"| node_split
node_pipeline -->|"builds index"| node_vector
node_vector -->|"gets model"| node_embed
node_pipeline -->|"requests chunks"| node_retriever
node_retriever -->|"searches index"| node_vector
node_pipeline -->|"generates answer"| node_llm
node_llm -.->|"calls when selected"| node_anthropic
node_llm -.->|"calls when selected"| node_openai
node_llm -.->|"calls when selected"| node_gemini
node_config -->|"sets model"| node_embed
node_config -->|"selects provider"| node_llm
node_vector -->|"saves or loads"| node_diskindex
node_pipeline -->|"returns answer, citations"| node_app

click node_app "https://github.com/chandana2556/chat-with-pdfs/blob/main/app.py"
click node_chatstate "https://github.com/chandana2556/chat-with-pdfs/blob/main/app.py"
click node_uploads "https://github.com/chandana2556/chat-with-pdfs/tree/main/data/uploads"
click node_pipeline "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/rag_pipeline.py"
click node_config "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/config.py"
click node_extract "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/pdf_processor.py"
click node_split "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/text_splitter.py"
click node_embed "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/embeddings.py"
click node_vector "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/vector_store.py"
click node_diskindex "https://github.com/chandana2556/chat-with-pdfs/tree/main/vectorstore"
click node_retriever "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/retriever.py"
click node_llm "https://github.com/chandana2556/chat-with-pdfs/blob/main/src/llm.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_chatstate,node_uploads,node_user toneBlue
class node_extract,node_split,node_embed,node_vector toneAmber
class node_pipeline,node_retriever,node_llm toneMint
class node_config,node_diskindex,node_anthropic,node_openai,node_gemini toneRose
```

## Components

### Chat interface

- [Streamlit UI](https://github.com/chandana2556/chat-with-pdfs/blob/main/app.py): `app.py`
- [Session chat](https://github.com/chandana2556/chat-with-pdfs/blob/main/app.py): `app.py`
- [Uploaded PDFs](https://github.com/chandana2556/chat-with-pdfs/tree/main/data/uploads): `data/uploads`

### PDF indexing

- [Page extraction](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/pdf_processor.py): `src/pdf_processor.py`
- [Chunk splitting](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/text_splitter.py): `src/text_splitter.py`
- [Local embeddings](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/embeddings.py): `src/embeddings.py`
- [FAISS vector store](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/vector_store.py): `src/vector_store.py`

### Search and generation

- [RAG pipeline](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/rag_pipeline.py): `src/rag_pipeline.py`
- [Chunk retrieval](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/retriever.py): `src/retriever.py`
- [Answer generation](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/llm.py): `src/llm.py`

### Models and storage

- [App configuration](https://github.com/chandana2556/chat-with-pdfs/blob/main/src/config.py): `src/config.py`
- [Saved index](https://github.com/chandana2556/chat-with-pdfs/tree/main/vectorstore): `vectorstore`
- **Anthropic API**
- **OpenAI API**
- **Gemini API**

### Other components

- **PDF user**

## Connections

- PDF user → Streamlit UI: uploads, asks
- Streamlit UI → Uploaded PDFs: writes files
- Streamlit UI → RAG pipeline: processes PDFs
- Streamlit UI → RAG pipeline: submits question
- Streamlit UI → Session chat: updates history
- Session chat → Streamlit UI: supplies history
- RAG pipeline → Page extraction: extracts pages
- Page extraction → Chunk splitting: passes page text
- RAG pipeline → Chunk splitting: splits pages
- RAG pipeline → FAISS vector store: builds index
- FAISS vector store → Local embeddings: gets model
- RAG pipeline → Chunk retrieval: requests chunks
- Chunk retrieval → FAISS vector store: searches index
- RAG pipeline → Answer generation: generates answer
- Answer generation → Anthropic API: calls when selected
- Answer generation → OpenAI API: calls when selected
- Answer generation → Gemini API: calls when selected
- App configuration → Local embeddings: sets model
- App configuration → Answer generation: selects provider
- FAISS vector store → Saved index: saves or loads
- RAG pipeline → Streamlit UI: returns answer, citations
