# codinghub27/chat_with_pdf architecture

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

- Interactive diagram: https://gitdiagram.com/codinghub27/chat_with_pdf
- Repository: https://github.com/codinghub27/chat_with_pdf

## Overview

Chat with PDF is a Django study assistant: users authenticate, upload private PDFs, and ask questions whose answers are grounded in the selected document and saved as per-PDF conversation history. The documented RAG stages run from PDF chunking and HuggingFace embeddings through FAISS retrieval to Groq generation. The graph reflects calls visible in the sampled views and documented RAG behavior; the LangChain implementation, route details, and login flow were not sampled, so their internal wiring is shown only where supported.

Main entry points: [`myapp/views.py`](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/views.py) (PDF views), [`myapp/langchain_utils.py`](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/langchain_utils.py) (RAG pipeline), [`mysite/urls.py`](https://github.com/codinghub27/chat_with_pdf/blob/main/mysite/urls.py) (Project routes), [`myapp/urls.py`](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/urls.py) (PDF routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and accounts"]
  node_project_routes["Project routes<br/>[urls.py]"]
  node_pdf_routes["PDF routes<br/>[urls.py]"]
  node_account_routes["Account routes<br/>[urls.py]"]
  node_account_views["Account views<br/>[views.py]"]
  node_django_auth["Django auth"]
end

subgraph group_documents["PDF management"]
  node_pdf_views["PDF views<br/>[views.py]"]
  node_upload_form["Upload form<br/>[forms.py]"]
  node_pdf_file["Uploaded PDF"]
end

subgraph group_rag["Question answering"]
  node_rag_pipeline["RAG pipeline<br/>[langchain_utils.py]"]
  node_faiss_index[("FAISS index<br/>[langchain_utils.py]")]
  node_embeddings["HuggingFace embeddings"]
  node_groq_llm["Groq LLM"]
end

subgraph group_state["Persistence and services"]
  node_pdf_profile["PDF profile<br/>[models.py]"]
  node_chat_history["Chat messages<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

node_reader(("Reader"))

node_reader -->|"sends requests"| node_project_routes
node_project_routes -->|"routes PDF requests"| node_pdf_routes
node_project_routes -->|"routes account requests"| node_account_routes
node_pdf_routes -->|"dispatches"| node_pdf_views
node_account_routes -->|"dispatches"| node_account_views
node_account_views -->|"logs out"| node_django_auth
node_django_auth -.->|"persists accounts"| node_postgres
node_pdf_views -->|"validates upload"| node_upload_form
node_pdf_views -->|"creates and lists"| node_pdf_profile
node_pdf_views -->|"stores upload"| node_pdf_file
node_pdf_views -->|"processes PDF"| node_rag_pipeline
node_rag_pipeline -->|"embeds chunks"| node_embeddings
node_rag_pipeline -->|"stores vectors"| node_faiss_index
node_pdf_views -->|"retrieves chunks"| node_faiss_index
node_pdf_views -->|"requests answer"| node_rag_pipeline
node_rag_pipeline -->|"generates answer"| node_groq_llm
node_pdf_views -->|"saves and reads history"| node_chat_history
node_pdf_profile -->|"persists PDF records"| node_postgres
node_chat_history -->|"persists messages"| node_postgres

click node_project_routes "https://github.com/codinghub27/chat_with_pdf/blob/main/mysite/urls.py"
click node_pdf_routes "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/urls.py"
click node_account_routes "https://github.com/codinghub27/chat_with_pdf/blob/main/users/urls.py"
click node_pdf_views "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/views.py"
click node_upload_form "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/forms.py"
click node_account_views "https://github.com/codinghub27/chat_with_pdf/blob/main/users/views.py"
click node_pdf_profile "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/models.py"
click node_chat_history "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/models.py"
click node_rag_pipeline "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/langchain_utils.py"
click node_faiss_index "https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/langchain_utils.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_project_routes,node_pdf_routes,node_account_routes,node_account_views,node_django_auth toneBlue
class node_pdf_views,node_upload_form,node_pdf_file toneAmber
class node_rag_pipeline,node_faiss_index,node_embeddings,node_groq_llm toneMint
class node_pdf_profile,node_chat_history,node_postgres toneRose
class node_reader toneIndigo
```

## Components

### Web and accounts

- [Project routes](https://github.com/codinghub27/chat_with_pdf/blob/main/mysite/urls.py): `mysite/urls.py`
- [PDF routes](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/urls.py): `myapp/urls.py`
- [Account routes](https://github.com/codinghub27/chat_with_pdf/blob/main/users/urls.py): `users/urls.py`
- [Account views](https://github.com/codinghub27/chat_with_pdf/blob/main/users/views.py): `users/views.py`
- **Django auth**

### PDF management

- [PDF views](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/views.py): `myapp/views.py`
- [Upload form](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/forms.py): `myapp/forms.py`
- **Uploaded PDF**

### Question answering

- [RAG pipeline](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/langchain_utils.py): `myapp/langchain_utils.py`
- [FAISS index](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/langchain_utils.py): `myapp/langchain_utils.py`
- **HuggingFace embeddings**
- **Groq LLM**

### Persistence and services

- [PDF profile](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/models.py): `myapp/models.py`
- [Chat messages](https://github.com/codinghub27/chat_with_pdf/blob/main/myapp/models.py): `myapp/models.py`
- **PostgreSQL**

### Other components

- **Reader**

## Connections

- Reader → Project routes: sends requests
- Project routes → PDF routes: routes PDF requests
- Project routes → Account routes: routes account requests
- PDF routes → PDF views: dispatches
- Account routes → Account views: dispatches
- Account views → Django auth: logs out
- Django auth → PostgreSQL: persists accounts
- PDF views → Upload form: validates upload
- PDF views → PDF profile: creates and lists
- PDF views → Uploaded PDF: stores upload
- PDF views → RAG pipeline: processes PDF
- RAG pipeline → HuggingFace embeddings: embeds chunks
- RAG pipeline → FAISS index: stores vectors
- PDF views → FAISS index: retrieves chunks
- PDF views → RAG pipeline: requests answer
- RAG pipeline → Groq LLM: generates answer
- PDF views → Chat messages: saves and reads history
- PDF profile → PostgreSQL: persists PDF records
- Chat messages → PostgreSQL: persists messages
