# harshithada/cloud_monitoredrag architecture

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

- Interactive diagram: https://gitdiagram.com/harshithada/cloud_monitoredrag
- Repository: https://github.com/harshithada/cloud_monitoredrag

## Overview

Cloud Monitored RAG ingests authorized PDFs into Weaviate, then lets users ask grounded questions through Streamlit or a Flask API. The query path applies shared prompt-injection checks, retrieves hybrid-ranked chunks, generates a cited Gemini answer, and records telemetry for Phoenix. The README documents additional product capabilities; source excerpts confirm the main calls and ingestion operations, while some detailed implementation relationships are supported only by README descriptions.

Main entry points: [`RAG_Agent_VertexAI_GoogleADK.py`](https://github.com/harshithada/cloud_monitoredrag/blob/main/RAG_Agent_VertexAI_GoogleADK.py) (RAG agent), [`ingestion_weaviate.py`](https://github.com/harshithada/cloud_monitoredrag/blob/main/ingestion_weaviate.py) (PDF ingestion), [`rag_pipeline.py`](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py) (Hybrid retrieval), [`streamlit_app.py`](https://github.com/harshithada/cloud_monitoredrag/blob/main/streamlit_app.py) (Streamlit console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Streamlit console<br/>[streamlit_app.py]"]
  node_flask_api["Flask query API<br/>[api.py]"]
end

subgraph group_query["Guarded RAG"]
  node_agent["RAG agent"]
  node_guardrail["Query guardrail<br/>[rag_pipeline.py]"]
  node_retrieval["Hybrid retrieval<br/>[rag_pipeline.py]"]
  node_query_embedding["Query embedding<br/>[rag_pipeline.py]"]
  node_weaviate[("Weaviate collection<br/>[rag_pipeline.py]")]
  node_generation["Grounded generation<br/>[rag_pipeline.py]"]
  node_coverage["Source coverage<br/>[rag_pipeline.py]"]
  node_answer["Cited answer"]
end

subgraph group_ingestion["PDF ingestion"]
  node_ingest_api["Ingestion endpoint"]
  node_ingestion["PDF ingestion"]
  node_extraction["PDF extraction<br/>[rag_pipeline.py]"]
  node_chunking["Text chunking<br/>[rag_pipeline.py]"]
  node_document_embedding["Document embeddings<br/>[rag_pipeline.py]"]
end

subgraph group_observability["Observability"]
  node_telemetry["OpenTelemetry spans"]
  node_phoenix["Phoenix dashboard<br/>[Server_Phoenix.py]"]
end

node_user(("User"))
node_vertex{{"Vertex Gemini"}}
node_pdfs["Authorized PDFs"]
node_otlp{{"OTLP collector"}}

node_user -->|"asks via"| node_streamlit
node_user -->|"queries via"| node_flask_api
node_streamlit -->|"submits chat"| node_agent
node_streamlit -->|"inspects results"| node_retrieval
node_streamlit -->|"tests query"| node_guardrail
node_flask_api -->|"dispatches query"| node_agent
node_agent -->|"checks input"| node_guardrail
node_agent -->|"searches accepted query"| node_retrieval
node_agent -->|"requests answer"| node_generation
node_retrieval -->|"encodes query"| node_query_embedding
node_retrieval -->|"runs hybrid search"| node_weaviate
node_weaviate -->|"returns ranked chunks"| node_retrieval
node_generation -->|"generates with"| node_vertex
node_generation -->|"checks answer"| node_coverage
node_coverage -->|"returns cited result"| node_answer
node_ingest_api -->|"invokes directory ingest"| node_ingestion
node_pdfs -->|"supplies documents"| node_ingestion
node_ingestion -->|"extracts text"| node_extraction
node_ingestion -->|"splits text"| node_chunking
node_ingestion -->|"embeds chunks"| node_document_embedding
node_ingestion -->|"upserts chunks"| node_weaviate
node_agent -->|"creates run spans"| node_telemetry
node_retrieval -->|"records retrieval"| node_telemetry
node_generation -->|"records generation"| node_telemetry
node_telemetry -->|"exports spans"| node_otlp
node_otlp -->|"feeds dashboard"| node_phoenix

click node_streamlit "https://github.com/harshithada/cloud_monitoredrag/blob/main/streamlit_app.py"
click node_flask_api "https://github.com/harshithada/cloud_monitoredrag/blob/main/api.py"
click node_agent "https://github.com/harshithada/cloud_monitoredrag/blob/main/RAG_Agent_VertexAI_GoogleADK.py"
click node_guardrail "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_retrieval "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_query_embedding "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_weaviate "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_generation "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_coverage "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_ingest_api "https://github.com/harshithada/cloud_monitoredrag/blob/main/ingestion_service.py"
click node_ingestion "https://github.com/harshithada/cloud_monitoredrag/blob/main/ingestion_weaviate.py"
click node_extraction "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_chunking "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_document_embedding "https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py"
click node_telemetry "https://github.com/harshithada/cloud_monitoredrag/blob/main/Observability_Traces_Phoenix.py"
click node_phoenix "https://github.com/harshithada/cloud_monitoredrag/blob/main/Server_Phoenix.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_flask_api,node_user toneBlue
class node_agent,node_guardrail,node_retrieval,node_query_embedding,node_weaviate,node_generation,node_coverage,node_answer toneAmber
class node_ingest_api,node_ingestion,node_extraction,node_chunking,node_document_embedding toneMint
class node_telemetry,node_phoenix toneRose
class node_vertex,node_pdfs,node_otlp toneIndigo
```

## Components

### User interfaces

- [Streamlit console](https://github.com/harshithada/cloud_monitoredrag/blob/main/streamlit_app.py): `streamlit_app.py`
- [Flask query API](https://github.com/harshithada/cloud_monitoredrag/blob/main/api.py): `api.py`

### Guarded RAG

- [RAG agent](https://github.com/harshithada/cloud_monitoredrag/blob/main/RAG_Agent_VertexAI_GoogleADK.py): `RAG_Agent_VertexAI_GoogleADK.py`
- [Query guardrail](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Hybrid retrieval](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Query embedding](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Weaviate collection](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Grounded generation](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Source coverage](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- **Cited answer**

### PDF ingestion

- [Ingestion endpoint](https://github.com/harshithada/cloud_monitoredrag/blob/main/ingestion_service.py): `ingestion_service.py`
- [PDF ingestion](https://github.com/harshithada/cloud_monitoredrag/blob/main/ingestion_weaviate.py): `ingestion_weaviate.py`
- [PDF extraction](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Text chunking](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Document embeddings](https://github.com/harshithada/cloud_monitoredrag/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Observability

- [OpenTelemetry spans](https://github.com/harshithada/cloud_monitoredrag/blob/main/Observability_Traces_Phoenix.py): `Observability_Traces_Phoenix.py`
- [Phoenix dashboard](https://github.com/harshithada/cloud_monitoredrag/blob/main/Server_Phoenix.py): `Server_Phoenix.py`

### Other components

- **User**
- **Vertex Gemini**
- **Authorized PDFs**
- **OTLP collector**

## Connections

- User → Streamlit console: asks via (evidence: `README.md`)
- User → Flask query API: queries via (evidence: `README.md`)
- Streamlit console → RAG agent: submits chat (evidence: `streamlit_app.py`)
- Streamlit console → Hybrid retrieval: inspects results (evidence: `streamlit_app.py`)
- Streamlit console → Query guardrail: tests query (evidence: `streamlit_app.py`)
- Flask query API → RAG agent: dispatches query (evidence: `api.py`)
- RAG agent → Query guardrail: checks input (evidence: `RAG_Agent_VertexAI_GoogleADK.py`)
- RAG agent → Hybrid retrieval: searches accepted query (evidence: `RAG_Agent_VertexAI_GoogleADK.py`)
- RAG agent → Grounded generation: requests answer (evidence: `RAG_Agent_VertexAI_GoogleADK.py`)
- Hybrid retrieval → Query embedding: encodes query (evidence: `README.md`)
- Hybrid retrieval → Weaviate collection: runs hybrid search (evidence: `rag_pipeline.py`)
- Weaviate collection → Hybrid retrieval: returns ranked chunks (evidence: `README.md`)
- Grounded generation → Vertex Gemini: generates with (evidence: `rag_pipeline.py`)
- Grounded generation → Source coverage: checks answer (evidence: `rag_pipeline.py`)
- Source coverage → Cited answer: returns cited result (evidence: `README.md`)
- Ingestion endpoint → PDF ingestion: invokes directory ingest (evidence: `ingestion_service.py`)
- Authorized PDFs → PDF ingestion: supplies documents (evidence: `README.md`)
- PDF ingestion → PDF extraction: extracts text (evidence: `ingestion_weaviate.py`)
- PDF ingestion → Text chunking: splits text (evidence: `ingestion_weaviate.py`)
- PDF ingestion → Document embeddings: embeds chunks (evidence: `ingestion_weaviate.py`)
- PDF ingestion → Weaviate collection: upserts chunks (evidence: `ingestion_weaviate.py`)
- RAG agent → OpenTelemetry spans: creates run spans (evidence: `RAG_Agent_VertexAI_GoogleADK.py`)
- Hybrid retrieval → OpenTelemetry spans: records retrieval (evidence: `rag_pipeline.py`)
- Grounded generation → OpenTelemetry spans: records generation (evidence: `README.md`)
- OpenTelemetry spans → OTLP collector: exports spans (evidence: `Observability_Traces_Phoenix.py`)
- OTLP collector → Phoenix dashboard: feeds dashboard (evidence: `README.md`)
