# kvkrpm/chatty-llama-ai-document-intelligence-system architecture

> Architecture diagram of the GitHub repository kvkrpm/chatty-llama-ai-document-intelligence-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kvkrpm/chatty-llama-ai-document-intelligence-system
- Repository: https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system

## Overview

This is an offline, multimodal PDF question-answering application. The main workflow is: a user uploads a report, the Streamlit app extracts text, tables, and image OCR, chunks the resulting documents, builds a searchable index, then retrieves context for a local LLM answer. The app also provides raw-page inspection, retrieved-chunk debugging, supporting images, and sample-query evaluation. A CLI offers a text-only indexing and retrieval path. Edges reflect calls shown in excerpts or explicit README claims; unsampled details are not inferred.

Main entry points: [`app/streamlit_app.py`](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/app/streamlit_app.py) (Streamlit App), [`retriever/rag_retriever.py`](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/retriever/rag_retriever.py) (RAG Retriever), [`main.py`](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/main.py) (CLI Pipeline), [`llm/ollama_llm.py`](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/llm/ollama_llm.py) (Local LLM Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interfaces"]
  node_streamlit["Streamlit App<br/>[streamlit_app.py]"]
  node_cli["CLI Pipeline<br/>[main.py]"]
end

subgraph group_ingestion["PDF Ingestion"]
  node_text_parser["Text Extraction<br/>[text_parser.py]"]
  node_table_parser["Table Extraction<br/>[table_parser.py]"]
  node_image_ocr["Image OCR<br/>[image_ocr.py]"]
  node_chunker["Document Chunking<br/>[chunker.py]"]
end

subgraph group_retrieval["Search and Indexing"]
  node_retriever["RAG Retriever<br/>[rag_retriever.py]"]
  node_embedder["Text Embedder"]
  node_faiss[("FAISS Index<br/>[faiss_store.py]")]
end

subgraph group_generation["Answer Generation"]
  node_local_llm["Local LLM Client<br/>[ollama_llm.py]"]
  node_ollama["Ollama Runtime"]
end

node_user(("User"))

node_user -->|"uploads report, asks"| node_streamlit
node_user -->|"enters query"| node_cli
node_streamlit -->|"extracts text"| node_text_parser
node_streamlit -->|"extracts tables"| node_table_parser
node_streamlit -->|"extracts OCR"| node_image_ocr
node_streamlit -->|"chunks documents"| node_chunker
node_streamlit -->|"builds, queries"| node_retriever
node_streamlit -->|"requests answers"| node_local_llm
node_cli -->|"extracts text"| node_text_parser
node_cli -->|"builds, queries"| node_retriever
node_retriever -->|"embeds text"| node_embedder
node_retriever -->|"indexes, searches"| node_faiss
node_local_llm -->|"sends chat prompt"| node_ollama

click node_streamlit "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/app/streamlit_app.py"
click node_cli "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/main.py"
click node_text_parser "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/text_parser.py"
click node_table_parser "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/table_parser.py"
click node_image_ocr "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/image_ocr.py"
click node_chunker "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/utils/chunker.py"
click node_retriever "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/retriever/rag_retriever.py"
click node_embedder "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/embeddings/multi_modal_embedder.py"
click node_faiss "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/vectorstore/faiss_store.py"
click node_local_llm "https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/llm/ollama_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_streamlit,node_cli,node_user toneBlue
class node_text_parser,node_table_parser,node_image_ocr,node_chunker toneAmber
class node_retriever,node_embedder,node_faiss toneMint
class node_local_llm,node_ollama toneRose
```

## Components

### User Interfaces

- [Streamlit App](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [CLI Pipeline](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/main.py): `main.py`

### PDF Ingestion

- [Text Extraction](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/text_parser.py): `ingestion/text_parser.py`
- [Table Extraction](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/table_parser.py): `ingestion/table_parser.py`
- [Image OCR](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/ingestion/image_ocr.py): `ingestion/image_ocr.py`
- [Document Chunking](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/utils/chunker.py): `utils/chunker.py`

### Search and Indexing

- [RAG Retriever](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/retriever/rag_retriever.py): `retriever/rag_retriever.py`
- [Text Embedder](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/embeddings/multi_modal_embedder.py): `embeddings/multi_modal_embedder.py`
- [FAISS Index](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/vectorstore/faiss_store.py): `vectorstore/faiss_store.py`

### Answer Generation

- [Local LLM Client](https://github.com/kvkrpm/chatty-llama-ai-document-intelligence-system/blob/main/llm/ollama_llm.py): `llm/ollama_llm.py`
- **Ollama Runtime**

### Other components

- **User**

## Connections

- User → Streamlit App: uploads report, asks (evidence: `README.md`)
- User → CLI Pipeline: enters query (evidence: `main.py`)
- Streamlit App → Text Extraction: extracts text (evidence: `app/streamlit_app.py`)
- Streamlit App → Table Extraction: extracts tables (evidence: `app/streamlit_app.py`)
- Streamlit App → Image OCR: extracts OCR (evidence: `app/streamlit_app.py`)
- Streamlit App → Document Chunking: chunks documents (evidence: `app/streamlit_app.py`)
- Streamlit App → RAG Retriever: builds, queries (evidence: `app/streamlit_app.py`)
- Streamlit App → Local LLM Client: requests answers (evidence: `app/streamlit_app.py`)
- CLI Pipeline → Text Extraction: extracts text (evidence: `main.py`)
- CLI Pipeline → RAG Retriever: builds, queries (evidence: `main.py`)
- RAG Retriever → Text Embedder: embeds text (evidence: `retriever/rag_retriever.py`)
- RAG Retriever → FAISS Index: indexes, searches (evidence: `retriever/rag_retriever.py`)
- Local LLM Client → Ollama Runtime: sends chat prompt (evidence: `llm/ollama_llm.py`)
