# nithyasrimiriyala/ragimage architecture

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

- Interactive diagram: https://gitdiagram.com/nithyasrimiriyala/ragimage
- Repository: https://github.com/nithyasrimiriyala/ragimage

## Overview

This is a Streamlit image-text extraction workspace with a terminal-based RAG question-answering workflow. Users upload an image, tune preprocessing, extract and inspect OCR text, then can ask questions from the terminal; answers are grounded in retrieved image text. The guide page demonstrates preprocessing options. The main pipeline is excerpted; its documented stages are represented separately even when implemented in one file. External OCR, embedding, vector-store, and LLM dependencies are shown only where the source or README supports the relationship.

Main entry points: [`app.py`](https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py) (Image workspace), [`rag_pipeline.py`](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py) (Text cleanup and chunks), [`pages/1_OpenCV_Guide.py`](https://github.com/nithyasrimiriyala/ragimage/blob/main/pages/1_OpenCV_Guide.py) (OpenCV guide)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_workspace["Image workspace<br/>[app.py]"]
  node_guide["OpenCV guide<br/>[1_OpenCV_Guide.py]"]
  node_cli["Terminal interface<br/>[rag_pipeline.py]"]
  node_text_output["OCR results<br/>[app.py]"]
end

subgraph group_image_ingestion["Image ingestion"]
  node_preview["Live preview<br/>[app.py]"]
  node_preprocess["Image preprocessing<br/>[rag_pipeline.py]"]
  node_ocr["Text recognition<br/>[rag_pipeline.py]"]
  node_clean_chunk["Text cleanup and chunks<br/>[rag_pipeline.py]"]
end

subgraph group_rag["Question answering"]
  node_embedding["Text embeddings<br/>[rag_pipeline.py]"]
  node_vector_store[("Image vector store<br/>[rag_pipeline.py]")]
  node_retrieval["Relevant chunk retrieval<br/>[rag_pipeline.py]"]
  node_prompt["Grounded answer prompt<br/>[rag_pipeline.py]"]
  node_answer["Answer generation<br/>[rag_pipeline.py]"]
end

subgraph group_integrations["External integrations"]
  node_tesseract["Tesseract OCR"]
  node_embedding_model["Hugging Face model"]
  node_chroma[("ChromaDB")]
  node_groq["Groq LLM"]
end

node_user(("User"))

node_user -->|"uploads image"| node_workspace
node_workspace -->|"requests preview"| node_preview
node_preview -->|"calls"| node_preprocess
node_user -->|"sets options"| node_workspace
node_workspace -->|"calls on extract"| node_preprocess
node_preprocess -->|"passes processed image"| node_ocr
node_ocr -->|"recognizes text"| node_tesseract
node_ocr -->|"returns OCR text"| node_clean_chunk
node_clean_chunk -->|"creates chunk documents"| node_embedding
node_embedding -->|"embeds chunks"| node_embedding_model
node_clean_chunk -->|"adds documents"| node_vector_store
node_vector_store -->|"persists vectors"| node_chroma
node_workspace -->|"shows extracted text"| node_text_output
node_clean_chunk -->|"provides text and count"| node_text_output
node_user -->|"opens guide"| node_guide
node_guide -->|"demonstrates settings"| node_preprocess
node_user -->|"starts image query"| node_cli
node_cli -->|"ingests image"| node_clean_chunk
node_cli -->|"submits question"| node_retrieval
node_retrieval -->|"searches top chunks"| node_vector_store
node_retrieval -->|"supplies context"| node_prompt
node_prompt -->|"formats question and context"| node_answer
node_answer -->|"generates answer"| node_groq
node_answer -->|"returns answer"| node_cli

click node_workspace "https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py"
click node_guide "https://github.com/nithyasrimiriyala/ragimage/blob/main/pages/1_OpenCV_Guide.py"
click node_cli "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_preview "https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py"
click node_preprocess "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_ocr "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_clean_chunk "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_text_output "https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py"
click node_embedding "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_vector_store "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_retrieval "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_prompt "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py"
click node_answer "https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.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_workspace,node_guide,node_cli,node_text_output,node_user toneBlue
class node_preview,node_preprocess,node_ocr,node_clean_chunk toneAmber
class node_embedding,node_vector_store,node_retrieval,node_prompt,node_answer toneMint
class node_tesseract,node_embedding_model,node_chroma,node_groq toneRose
```

## Components

### User interfaces

- [Image workspace](https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py): `app.py`
- [OpenCV guide](https://github.com/nithyasrimiriyala/ragimage/blob/main/pages/1_OpenCV_Guide.py): `pages/1_OpenCV_Guide.py`
- [Terminal interface](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [OCR results](https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py): `app.py`

### Image ingestion

- [Live preview](https://github.com/nithyasrimiriyala/ragimage/blob/main/app.py): `app.py`
- [Image preprocessing](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Text recognition](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Text cleanup and chunks](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Question answering

- [Text embeddings](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Image vector store](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Relevant chunk retrieval](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Grounded answer prompt](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Answer generation](https://github.com/nithyasrimiriyala/ragimage/blob/main/rag_pipeline.py): `rag_pipeline.py`

### External integrations

- **Tesseract OCR**
- **Hugging Face model**
- **ChromaDB**
- **Groq LLM**

### Other components

- **User**

## Connections

- User → Image workspace: uploads image (evidence: `app.py`)
- Image workspace → Live preview: requests preview (evidence: `app.py`)
- Live preview → Image preprocessing: calls (evidence: `app.py`)
- User → Image workspace: sets options (evidence: `app.py`)
- Image workspace → Image preprocessing: calls on extract (evidence: `rag_pipeline.py`)
- Image preprocessing → Text recognition: passes processed image (evidence: `rag_pipeline.py`)
- Text recognition → Tesseract OCR: recognizes text (evidence: `rag_pipeline.py`)
- Text recognition → Text cleanup and chunks: returns OCR text (evidence: `rag_pipeline.py`)
- Text cleanup and chunks → Text embeddings: creates chunk documents (evidence: `rag_pipeline.py`)
- Text embeddings → Hugging Face model: embeds chunks (evidence: `rag_pipeline.py`)
- Text cleanup and chunks → Image vector store: adds documents (evidence: `rag_pipeline.py`)
- Image vector store → ChromaDB: persists vectors (evidence: `rag_pipeline.py`)
- Image workspace → OCR results: shows extracted text (evidence: `app.py`)
- Text cleanup and chunks → OCR results: provides text and count (evidence: `app.py`)
- User → OpenCV guide: opens guide (evidence: `pages/1_OpenCV_Guide.py`)
- OpenCV guide → Image preprocessing: demonstrates settings (evidence: `pages/1_OpenCV_Guide.py`)
- User → Terminal interface: starts image query (evidence: `rag_pipeline.py`)
- Terminal interface → Text cleanup and chunks: ingests image (evidence: `rag_pipeline.py`)
- Terminal interface → Relevant chunk retrieval: submits question (evidence: `rag_pipeline.py`)
- Relevant chunk retrieval → Image vector store: searches top chunks (evidence: `rag_pipeline.py`)
- Relevant chunk retrieval → Grounded answer prompt: supplies context (evidence: `rag_pipeline.py`)
- Grounded answer prompt → Answer generation: formats question and context (evidence: `rag_pipeline.py`)
- Answer generation → Groq LLM: generates answer (evidence: `rag_pipeline.py`)
- Answer generation → Terminal interface: returns answer (evidence: `rag_pipeline.py`)
