# gopu-005/multimodal-retrieval-augmented-generation-main architecture

> Architecture diagram of the GitHub repository gopu-005/multimodal-retrieval-augmented-generation-main, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gopu-005/multimodal-retrieval-augmented-generation-main
- Repository: https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main

## Overview

VisionRAG is a multimodal document question-answering application. Users sign in, upload PDFs or images for page rendering and OCR, then ask questions; the backend retrieves relevant text blocks, sends context and page imagery to a multimodal LLM, and returns answers with citations that the UI can use to highlight document locations. The README also describes token analytics, shared conversation snapshots, and Firebase-backed storage fallback. Several backend routes and frontend features are only partially sampled, so those links rely on README documentation where noted.

Main entry points: [`backend/app/main.py`](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py) (REST API), [`frontend/src/App.jsx`](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/App.jsx) (Workspace UI), [`backend/app/services/document.py`](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/document.py) (Document processing), [`frontend/src/components/ChatPane.jsx`](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/ChatPane.jsx) (Chat pane)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_workspace["Workspace UI<br/>[App.jsx]"]
  node_auth_ui["Sign-in UI<br/>[Auth.jsx]"]
  node_chat_ui["Chat pane<br/>[ChatPane.jsx]"]
  node_viewer["Document viewer<br/>[DocumentViewer.jsx]"]
  node_api_config["Backend address<br/>[config.js]"]
end

subgraph group_processing["Document processing"]
  node_api["REST API<br/>[main.py]"]
  node_document["Document processing<br/>[document.py]"]
  node_ocr["Cloud OCR<br/>[ocr.py]"]
  node_ocr_models["OCR schemas<br/>[ocr.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

subgraph group_qa["Question answering"]
  node_ranker["BM25 retrieval<br/>[vector_db.py]"]
  node_llm["Multimodal LLM<br/>[llm.py]"]
  node_analytics["Token analytics<br/>[main.py]"]
  node_sharing["Conversation sharing<br/>[main.py]"]
end

subgraph group_cloud["Firebase services"]
  node_firebase_config["Firebase backend config<br/>[firebase_config.py]"]
  node_firebase_auth["Firebase Authentication"]
  node_firestore[("Firestore")]
  node_storage[("Cloud Storage")]
end

node_user(("Document user"))
node_llm_provider["Gemini via OpenRouter"]

node_user -->|"signs in"| node_auth_ui
node_auth_ui -->|"authenticates"| node_firebase_auth
node_workspace -->|"renders"| node_auth_ui
node_workspace -->|"renders"| node_chat_ui
node_workspace -->|"renders"| node_viewer
node_chat_ui -->|"gets API address"| node_api_config
node_chat_ui -->|"submits questions"| node_api
node_user -->|"uploads documents"| node_workspace
node_workspace -->|"uploads documents"| node_api
node_api -->|"processes uploads"| node_document
node_document -->|"extracts text"| node_ocr
node_document -->|"creates index"| node_ranker
node_document -->|"uploads pages"| node_storage
node_document -->|"builds results"| node_ocr_models
node_ocr -->|"reads credentials"| node_settings
node_ocr -->|"requests OCR"| node_llm_provider
node_ocr -->|"returns blocks"| node_ocr_models
node_api -->|"retrieves blocks"| node_ranker
node_api -->|"requests answers"| node_llm
node_llm -->|"sends multimodal query"| node_llm_provider
node_llm -->|"reads model config"| node_settings
node_api -->|"verifies tokens"| node_firebase_auth
node_api -->|"reads and writes"| node_firestore
node_api -->|"loads page assets"| node_storage
node_api -->|"serves analytics"| node_analytics
node_api -->|"supports snapshots"| node_sharing
node_workspace -->|"shows token metrics"| node_analytics
node_chat_ui -->|"opens cited pages"| node_viewer
node_viewer -->|"loads document pages"| node_api
node_firebase_config -.->|"configures access"| node_firestore
node_firebase_config -.->|"configures access"| node_storage

click node_workspace "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/Auth.jsx"
click node_chat_ui "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/ChatPane.jsx"
click node_viewer "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/DocumentViewer.jsx"
click node_api_config "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/config.js"
click node_api "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py"
click node_document "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/document.py"
click node_ocr "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/ocr.py"
click node_ocr_models "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/schemas/ocr.py"
click node_settings "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/config.py"
click node_ranker "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/vector_db.py"
click node_llm "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/llm.py"
click node_analytics "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py"
click node_sharing "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py"
click node_firebase_config "https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/firebase_config.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_auth_ui,node_chat_ui,node_viewer,node_api_config,node_user toneBlue
class node_api,node_document,node_ocr,node_ocr_models,node_settings toneAmber
class node_ranker,node_llm,node_analytics,node_sharing,node_llm_provider toneMint
class node_firebase_config,node_firebase_auth,node_firestore,node_storage toneRose
```

## Components

### Web application

- [Workspace UI](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in UI](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/Auth.jsx): `frontend/src/components/Auth.jsx`
- [Chat pane](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/ChatPane.jsx): `frontend/src/components/ChatPane.jsx`
- [Document viewer](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/components/DocumentViewer.jsx): `frontend/src/components/DocumentViewer.jsx`
- [Backend address](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/frontend/src/config.js): `frontend/src/config.js`

### Document processing

- [REST API](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py): `backend/app/main.py`
- [Document processing](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/document.py): `backend/app/services/document.py`
- [Cloud OCR](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/ocr.py): `backend/app/services/ocr.py`
- [OCR schemas](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/schemas/ocr.py): `backend/app/schemas/ocr.py`
- [Runtime settings](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/config.py): `backend/app/config.py`

### Question answering

- [BM25 retrieval](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/vector_db.py): `backend/app/services/vector_db.py`
- [Multimodal LLM](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/llm.py): `backend/app/services/llm.py`
- [Token analytics](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py): `backend/app/main.py`
- [Conversation sharing](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/main.py): `backend/app/main.py`

### Firebase services

- [Firebase backend config](https://github.com/gopu-005/multimodal-retrieval-augmented-generation-main/blob/main/backend/app/services/firebase_config.py): `backend/app/services/firebase_config.py`
- **Firebase Authentication**
- **Firestore**
- **Cloud Storage**

### Other components

- **Document user**
- **Gemini via OpenRouter**

## Connections

- Document user → Sign-in UI: signs in (evidence: `README.md`)
- Sign-in UI → Firebase Authentication: authenticates (evidence: `frontend/src/components/Auth.jsx`)
- Workspace UI → Sign-in UI: renders (evidence: `frontend/src/App.jsx`)
- Workspace UI → Chat pane: renders (evidence: `frontend/src/App.jsx`)
- Workspace UI → Document viewer: renders (evidence: `frontend/src/App.jsx`)
- Chat pane → Backend address: gets API address (evidence: `frontend/src/components/ChatPane.jsx`)
- Chat pane → REST API: submits questions (evidence: `frontend/src/components/ChatPane.jsx`)
- Document user → Workspace UI: uploads documents (evidence: `README.md`)
- Workspace UI → REST API: uploads documents (evidence: `README.md`)
- REST API → Document processing: processes uploads (evidence: `backend/app/main.py`)
- Document processing → Cloud OCR: extracts text (evidence: `backend/app/services/document.py`)
- Document processing → BM25 retrieval: creates index (evidence: `backend/app/services/document.py`)
- Document processing → Cloud Storage: uploads pages (evidence: `backend/app/services/document.py`)
- Document processing → OCR schemas: builds results (evidence: `backend/app/services/document.py`)
- Cloud OCR → Runtime settings: reads credentials (evidence: `backend/app/services/ocr.py`)
- Cloud OCR → Gemini via OpenRouter: requests OCR (evidence: `backend/app/services/ocr.py`)
- Cloud OCR → OCR schemas: returns blocks (evidence: `backend/app/services/ocr.py`)
- REST API → BM25 retrieval: retrieves blocks (evidence: `backend/app/main.py`)
- REST API → Multimodal LLM: requests answers (evidence: `backend/app/main.py`)
- Multimodal LLM → Gemini via OpenRouter: sends multimodal query (evidence: `backend/app/services/llm.py`)
- Multimodal LLM → Runtime settings: reads model config (evidence: `backend/app/services/llm.py`)
- REST API → Firebase Authentication: verifies tokens (evidence: `README.md`)
- REST API → Firestore: reads and writes (evidence: `backend/app/main.py`)
- REST API → Cloud Storage: loads page assets (evidence: `backend/app/main.py`)
- REST API → Token analytics: serves analytics (evidence: `README.md`)
- REST API → Conversation sharing: supports snapshots (evidence: `README.md`)
- Workspace UI → Token analytics: shows token metrics (evidence: `README.md`)
- Chat pane → Document viewer: opens cited pages (evidence: `frontend/src/components/ChatPane.jsx`)
- Document viewer → REST API: loads document pages (evidence: `README.md`)
- Firebase backend config → Firestore: configures access
- Firebase backend config → Cloud Storage: configures access
