# sutirthachattopadhyay/doctalk architecture

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

- Interactive diagram: https://gitdiagram.com/sutirthachattopadhyay/doctalk
- Repository: https://github.com/sutirthachattopadhyay/doctalk

## Overview

DocTalk extracts text from PDFs, chunks it, builds a semantic vector index, and supports similarity search plus saving and loading the index. PDF extraction uses pdfplumber first, then Tesseract for scanned pages, with optional Gemini Vision for low-confidence OCR. The sampled code does not show how app.py exposes or orchestrates these capabilities, and the README is empty, so application-level wiring is omitted. The graph reflects the parser and embedding implementation shown; it does not assume unobserved links between them.

Main entry points: [`Embeddings.py`](https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py) (Embedding pipeline), [`pdf_parser.py`](https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py) (PDF parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["PDF ingestion"]
  node_parser["PDF parser<br/>[pdf_parser.py]"]
  node_pdf_text["PDF text extraction<br/>[pdf_parser.py]"]
  node_ocr["OCR fallbacks<br/>[pdf_parser.py]"]
  node_chunking["Text chunking<br/>[pdf_parser.py]"]
  node_pdfplumber["pdfplumber"]
  node_tesseract["Tesseract OCR"]
  node_gemini["Gemini Vision"]
end

subgraph group_retrieval["Semantic retrieval"]
  node_pipeline["Embedding pipeline<br/>[Embeddings.py]"]
  node_embedding_model["Sentence Transformer"]
  node_faiss[("FAISS index<br/>[Embeddings.py]")]
end

subgraph group_persistence["Index persistence"]
  node_metadata["Chunk metadata<br/>[Embeddings.py]"]
  node_index_files["Saved index files<br/>[Embeddings.py]"]
end

node_user(("User"))
node_app["Application<br/>[app.py]"]

node_user -->|"provides PDF"| node_parser
node_parser -->|"extracts pages"| node_pdf_text
node_pdf_text -->|"extracts text"| node_pdfplumber
node_pdf_text -->|"falls back"| node_ocr
node_ocr -->|"runs OCR"| node_tesseract
node_ocr -->|"tries vision OCR"| node_gemini
node_parser -->|"chunks pages"| node_chunking
node_pipeline -->|"encodes text"| node_embedding_model
node_pipeline -->|"adds vectors"| node_faiss
node_pipeline -->|"stores chunk data"| node_metadata
node_pipeline -->|"saves and loads"| node_index_files

click node_app "https://github.com/sutirthachattopadhyay/doctalk/blob/main/app.py"
click node_parser "https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py"
click node_pdf_text "https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py"
click node_ocr "https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py"
click node_chunking "https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py"
click node_pipeline "https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py"
click node_faiss "https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py"
click node_metadata "https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py"
click node_index_files "https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.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_parser,node_pdf_text,node_ocr,node_chunking,node_pdfplumber,node_tesseract,node_gemini,node_user toneBlue
class node_pipeline,node_embedding_model,node_faiss toneAmber
class node_metadata,node_index_files toneMint
class node_app toneTeal
```

## Components

### PDF ingestion

- [PDF parser](https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py): `pdf_parser.py`
- [PDF text extraction](https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py): `pdf_parser.py`
- [OCR fallbacks](https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py): `pdf_parser.py`
- [Text chunking](https://github.com/sutirthachattopadhyay/doctalk/blob/main/pdf_parser.py): `pdf_parser.py`
- **pdfplumber**
- **Tesseract OCR**
- **Gemini Vision**

### Semantic retrieval

- [Embedding pipeline](https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py): `Embeddings.py`
- **Sentence Transformer**
- [FAISS index](https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py): `Embeddings.py`

### Index persistence

- [Chunk metadata](https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py): `Embeddings.py`
- [Saved index files](https://github.com/sutirthachattopadhyay/doctalk/blob/main/Embeddings.py): `Embeddings.py`

### Other components

- **User**
- [Application](https://github.com/sutirthachattopadhyay/doctalk/blob/main/app.py): `app.py`

## Connections

- User → PDF parser: provides PDF (evidence: `pdf_parser.py`)
- PDF parser → PDF text extraction: extracts pages (evidence: `pdf_parser.py`)
- PDF text extraction → pdfplumber: extracts text (evidence: `pdf_parser.py`)
- PDF text extraction → OCR fallbacks: falls back (evidence: `pdf_parser.py`)
- OCR fallbacks → Tesseract OCR: runs OCR (evidence: `pdf_parser.py`)
- OCR fallbacks → Gemini Vision: tries vision OCR (evidence: `pdf_parser.py`)
- PDF parser → Text chunking: chunks pages (evidence: `pdf_parser.py`)
- Embedding pipeline → Sentence Transformer: encodes text (evidence: `Embeddings.py`)
- Embedding pipeline → FAISS index: adds vectors (evidence: `Embeddings.py`)
- Embedding pipeline → Chunk metadata: stores chunk data (evidence: `Embeddings.py`)
- Embedding pipeline → Saved index files: saves and loads (evidence: `Embeddings.py`)
