# arunnegi112/deepdive architecture

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

- Interactive diagram: https://gitdiagram.com/arunnegi112/deepdive
- Repository: https://github.com/arunnegi112/deepdive

## Overview

DeepDive is a PDF-grounded research assistant with optional live web search. A user uploads a PDF for indexing, then asks a question through the chat API; the LangGraph workflow retrieves document evidence, judges whether it suffices, optionally searches the web, and synthesizes a cited answer. The graph shows the documented ingestion and answer stages plus persistence and external services. The README describes streaming, accounts, and tracing, but the sampled API excerpt shows synchronous invocation and no account implementation; those details are not expanded into unsupported components.

Main entry points: [`workflow.py`](https://github.com/arunnegi112/deepdive/blob/main/workflow.py) (Strategy router), [`main.py`](https://github.com/arunnegi112/deepdive/blob/main/main.py) (Chat endpoint), [`indexing.py`](https://github.com/arunnegi112/deepdive/blob/main/indexing.py) (Page loader), [`vector_db_1`](https://github.com/arunnegi112/deepdive/tree/main/vector_db_1) (Chroma store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_upload["PDF upload<br/>[main.py]"]
  node_chat["Chat endpoint<br/>[main.py]"]
end

subgraph group_ingestion["PDF ingestion"]
  node_pdf_loader["Page loader<br/>[indexing.py]"]
  node_chunker["Text chunker<br/>[indexing.py]"]
  node_embedder["Local embeddings<br/>[indexing.py]"]
end

subgraph group_answering["Answer workflow"]
  node_router["Strategy router<br/>[workflow.py]"]
  node_retrieve["Multi-query retrieval<br/>[workflow.py]"]
  node_format_docs["Format documents<br/>[workflow.py]"]
  node_hybrid_answer["RAG sufficiency<br/>[workflow.py]"]
  node_doc_answer["Document answer<br/>[workflow.py]"]
  node_search_query["Search query<br/>[workflow.py]"]
  node_web_search["Tavily search<br/>[workflow.py]"]
  node_format_results["Format results<br/>[workflow.py]"]
  node_web_answer["Web answer<br/>[workflow.py]"]
  node_final_answer["Final synthesis<br/>[workflow.py]"]
end

subgraph group_services["Storage and services"]
  node_vector_store[("Chroma store")]
  node_chat_store[("Chat checkpoints<br/>[chats.db]")]
  node_groq{{"Groq models"}}
  node_tavily{{"Tavily service"}}
  node_langsmith{{"LangSmith tracing"}}
end

node_user(("Researcher"))

node_user -->|"uploads PDF"| node_upload
node_upload -->|"indexes file"| node_pdf_loader
node_pdf_loader -->|"splits pages"| node_chunker
node_chunker -->|"embeds chunks"| node_embedder
node_embedder -->|"persists vectors"| node_vector_store
node_user -->|"asks question"| node_chat
node_chat -->|"invokes workflow"| node_router
node_router -->|"routes retrieval"| node_retrieve
node_router -->|"routes web"| node_search_query
node_retrieve -->|"queries vectors"| node_vector_store
node_retrieve -->|"generates variants"| node_groq
node_retrieve -->|"returns chunks"| node_format_docs
node_format_docs -->|"supplies context"| node_hybrid_answer
node_format_docs -->|"supplies context"| node_doc_answer
node_hybrid_answer -->|"judges sufficiency"| node_groq
node_hybrid_answer -->|"answers if sufficient"| node_final_answer
node_hybrid_answer -->|"falls back if needed"| node_search_query
node_doc_answer -->|"supplies answer"| node_final_answer
node_search_query -->|"rewrites question"| node_groq
node_search_query -->|"dispatches query"| node_web_search
node_web_search -->|"searches web"| node_tavily
node_web_search -->|"returns results"| node_format_results
node_format_results -->|"supplies evidence"| node_web_answer
node_web_answer -->|"summarizes results"| node_groq
node_web_answer -->|"supplies answer"| node_final_answer
node_final_answer -->|"synthesizes responses"| node_groq
node_router -->|"checkpoints thread"| node_chat_store
node_router -.->|"traces workflow"| node_langsmith
node_final_answer -->|"returns final response"| node_chat

click node_upload "https://github.com/arunnegi112/deepdive/blob/main/main.py"
click node_chat "https://github.com/arunnegi112/deepdive/blob/main/main.py"
click node_pdf_loader "https://github.com/arunnegi112/deepdive/blob/main/indexing.py"
click node_chunker "https://github.com/arunnegi112/deepdive/blob/main/indexing.py"
click node_embedder "https://github.com/arunnegi112/deepdive/blob/main/indexing.py"
click node_vector_store "https://github.com/arunnegi112/deepdive/tree/main/vector_db_1"
click node_router "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_retrieve "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_format_docs "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_hybrid_answer "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_doc_answer "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_search_query "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_web_search "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_format_results "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_web_answer "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_final_answer "https://github.com/arunnegi112/deepdive/blob/main/workflow.py"
click node_chat_store "https://github.com/arunnegi112/deepdive/blob/main/chats.db"

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_upload,node_chat toneBlue
class node_pdf_loader,node_chunker,node_embedder toneAmber
class node_router,node_retrieve,node_format_docs,node_hybrid_answer,node_doc_answer,node_search_query,node_web_search,node_format_results,node_web_answer,node_final_answer toneMint
class node_vector_store,node_chat_store,node_groq,node_tavily,node_langsmith toneRose
class node_user toneIndigo
```

## Components

### API

- [PDF upload](https://github.com/arunnegi112/deepdive/blob/main/main.py): `main.py`
- [Chat endpoint](https://github.com/arunnegi112/deepdive/blob/main/main.py): `main.py`

### PDF ingestion

- [Page loader](https://github.com/arunnegi112/deepdive/blob/main/indexing.py): `indexing.py`
- [Text chunker](https://github.com/arunnegi112/deepdive/blob/main/indexing.py): `indexing.py`
- [Local embeddings](https://github.com/arunnegi112/deepdive/blob/main/indexing.py): `indexing.py`

### Answer workflow

- [Strategy router](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Multi-query retrieval](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Format documents](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [RAG sufficiency](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Document answer](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Search query](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Tavily search](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Format results](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Web answer](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`
- [Final synthesis](https://github.com/arunnegi112/deepdive/blob/main/workflow.py): `workflow.py`

### Storage and services

- [Chroma store](https://github.com/arunnegi112/deepdive/tree/main/vector_db_1): `vector_db_1`
- [Chat checkpoints](https://github.com/arunnegi112/deepdive/blob/main/chats.db): `chats.db`
- **Groq models**
- **Tavily service**
- **LangSmith tracing**

### Other components

- **Researcher**

## Connections

- Researcher → PDF upload: uploads PDF (evidence: `README.md`)
- PDF upload → Page loader: indexes file (evidence: `main.py`)
- Page loader → Text chunker: splits pages (evidence: `README.md`)
- Text chunker → Local embeddings: embeds chunks (evidence: `README.md`)
- Local embeddings → Chroma store: persists vectors (evidence: `indexing.py`)
- Researcher → Chat endpoint: asks question (evidence: `README.md`)
- Chat endpoint → Strategy router: invokes workflow (evidence: `main.py`)
- Strategy router → Multi-query retrieval: routes retrieval (evidence: `README.md`)
- Strategy router → Search query: routes web (evidence: `README.md`)
- Multi-query retrieval → Chroma store: queries vectors (evidence: `README.md`)
- Multi-query retrieval → Groq models: generates variants (evidence: `README.md`)
- Multi-query retrieval → Format documents: returns chunks (evidence: `README.md`)
- Format documents → RAG sufficiency: supplies context (evidence: `README.md`)
- Format documents → Document answer: supplies context (evidence: `README.md`)
- RAG sufficiency → Groq models: judges sufficiency (evidence: `README.md`)
- RAG sufficiency → Final synthesis: answers if sufficient (evidence: `README.md`)
- RAG sufficiency → Search query: falls back if needed (evidence: `README.md`)
- Document answer → Final synthesis: supplies answer (evidence: `README.md`)
- Search query → Groq models: rewrites question (evidence: `README.md`)
- Search query → Tavily search: dispatches query (evidence: `README.md`)
- Tavily search → Tavily service: searches web (evidence: `README.md`)
- Tavily search → Format results: returns results (evidence: `README.md`)
- Format results → Web answer: supplies evidence (evidence: `README.md`)
- Web answer → Groq models: summarizes results (evidence: `README.md`)
- Web answer → Final synthesis: supplies answer (evidence: `README.md`)
- Final synthesis → Groq models: synthesizes responses (evidence: `README.md`)
- Strategy router → Chat checkpoints: checkpoints thread (evidence: `README.md`)
- Strategy router → LangSmith tracing: traces workflow (evidence: `README.md`)
- Final synthesis → Chat endpoint: returns final response (evidence: `main.py`)
