# debanjan06/geospatial-rag architecture

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

- Interactive diagram: https://gitdiagram.com/debanjan06/geospatial-rag
- Repository: https://github.com/debanjan06/geospatial-rag

## Overview

GeoSpatial-RAG lets users submit text queries, optionally with a remote-sensing image, through a CLI demo or Streamlit chat. The pipeline embeds inputs with CLIP, retrieves and ranks matching documents from SQLite, optionally captions the submitted image, and assembles a response from the retrieved context. README describes database preparation and broader LangChain generation capabilities, but the tree contains no ingestion scripts, and the sampled response code is a local formatter rather than a LangChain generation chain. The VLM implementation is referenced but absent from the tree, so its path is limited to the existing package directory.

Main entry points: [`src/geospatial_rag/pipeline.py`](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/pipeline.py) (RAG Pipeline), [`demo/interactive_demo.py`](https://github.com/debanjan06/geospatial-rag/blob/main/demo/interactive_demo.py) (CLI Demo), [`streamlit_app.py`](https://github.com/debanjan06/geospatial-rag/blob/main/streamlit_app.py) (Streamlit Chat), [`src/geospatial_rag/retriever.py`](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/retriever.py) (SQLite Retriever)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI Demo"]
  node_web["Streamlit Chat<br/>[streamlit_app.py]"]
end

subgraph group_pipeline["Query Pipeline"]
  node_rag["RAG Pipeline<br/>[pipeline.py]"]
  node_caption["VLM Captioning"]
  node_context["Context Response<br/>[pipeline.py]"]
end

subgraph group_retrieval["Embedding Retrieval"]
  node_embedder["CLIP Encoder<br/>[embeddings.py]"]
  node_retriever["SQLite Retriever<br/>[retriever.py]"]
end

subgraph group_storage["Vector Storage"]
  node_db_api["Database Operations<br/>[database.py]"]
  node_sqlite[("SQLite Vector DB")]
end

node_user(("Analyst"))
node_text_input(("Text Query"))
node_image_input(("Image Input"))
node_results["Search Results"]

node_user -->|"enters query"| node_cli
node_user -->|"submits query"| node_web
node_text_input -->|"query text"| node_rag
node_image_input -->|"optional image"| node_rag
node_cli -->|"calls query"| node_rag
node_web -->|"calls query"| node_rag
node_rag -->|"encodes inputs"| node_embedder
node_rag -->|"creates and queries"| node_retriever
node_retriever -->|"reads embeddings"| node_sqlite
node_db_api -->|"reads and writes"| node_sqlite
node_rag -->|"gets statistics"| node_db_api
node_rag -->|"requests caption"| node_caption
node_rag -->|"builds response"| node_context
node_rag -->|"returns documents and response"| node_results
node_web -->|"displays results"| node_results
node_cli -->|"prints results"| node_results

click node_cli "https://github.com/debanjan06/geospatial-rag/blob/main/demo/interactive_demo.py"
click node_web "https://github.com/debanjan06/geospatial-rag/blob/main/streamlit_app.py"
click node_rag "https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/pipeline.py"
click node_caption "https://github.com/debanjan06/geospatial-rag/tree/main/src/geospatial_rag"
click node_context "https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/pipeline.py"
click node_embedder "https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/embeddings.py"
click node_retriever "https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/retriever.py"
click node_db_api "https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/database.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_cli,node_web toneBlue
class node_rag,node_caption,node_context toneAmber
class node_embedder,node_retriever toneMint
class node_db_api,node_sqlite toneRose
class node_user,node_text_input,node_image_input,node_results toneIndigo
```

## Components

### User Interfaces

- [CLI Demo](https://github.com/debanjan06/geospatial-rag/blob/main/demo/interactive_demo.py): `demo/interactive_demo.py`
- [Streamlit Chat](https://github.com/debanjan06/geospatial-rag/blob/main/streamlit_app.py): `streamlit_app.py`

### Query Pipeline

- [RAG Pipeline](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/pipeline.py): `src/geospatial_rag/pipeline.py`
- [VLM Captioning](https://github.com/debanjan06/geospatial-rag/tree/main/src/geospatial_rag): `src/geospatial_rag`
- [Context Response](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/pipeline.py): `src/geospatial_rag/pipeline.py`

### Embedding Retrieval

- [CLIP Encoder](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/embeddings.py): `src/geospatial_rag/embeddings.py`
- [SQLite Retriever](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/retriever.py): `src/geospatial_rag/retriever.py`

### Vector Storage

- [Database Operations](https://github.com/debanjan06/geospatial-rag/blob/main/src/geospatial_rag/database.py): `src/geospatial_rag/database.py`
- **SQLite Vector DB**

### Other components

- **Analyst**
- **Text Query**
- **Image Input**
- **Search Results**

## Connections

- Analyst → CLI Demo: enters query
- Analyst → Streamlit Chat: submits query
- Text Query → RAG Pipeline: query text
- Image Input → RAG Pipeline: optional image
- CLI Demo → RAG Pipeline: calls query
- Streamlit Chat → RAG Pipeline: calls query
- RAG Pipeline → CLIP Encoder: encodes inputs
- RAG Pipeline → SQLite Retriever: creates and queries
- SQLite Retriever → SQLite Vector DB: reads embeddings
- Database Operations → SQLite Vector DB: reads and writes
- RAG Pipeline → Database Operations: gets statistics
- RAG Pipeline → VLM Captioning: requests caption
- RAG Pipeline → Context Response: builds response
- RAG Pipeline → Search Results: returns documents and response
- Streamlit Chat → Search Results: displays results
- CLI Demo → Search Results: prints results
