# shre167/rag-model architecture

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

- Interactive diagram: https://gitdiagram.com/shre167/rag-model
- Repository: https://github.com/shre167/rag-model

## Overview

This repository implements a Streamlit-facing, astronomy-themed retrieval-augmented knowledge assistant. Its main workflow is document ingestion and indexing, followed by question answering: prepare a query, retrieve and rank evidence, select context, generate a grounded answer, and return sources. The pipeline also includes fallback, citation, evaluation, and observability capabilities. The README is empty and app.py was not sampled, so the application-entry connections are shown as unverified; internal links rely on the pipeline’s indexed references and the excerpts provided.

Main entry points: [`src/rag_pipeline/pipeline.py`](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/pipeline.py) (RAG Pipeline), [`src/ui/pages.py`](https://github.com/shre167/rag-model/blob/main/src/ui/pages.py) (UI Pages), [`ingest.py`](https://github.com/shre167/rag-model/blob/main/ingest.py) (Ingestion Command), [`app.py`](https://github.com/shre167/rag-model/blob/main/app.py) (Streamlit App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_app["Streamlit App<br/>[app.py]"]
  node_ui_pages["UI Pages<br/>[pages.py]"]
  node_ui_theme["Astronomy Theme<br/>[astronomy_theme.py]"]
end

subgraph group_knowledge["Knowledge Indexing"]
  node_ingest["Ingestion Command<br/>[ingest.py]"]
  node_document_loader["Document Loading<br/>[document_loader.py]"]
  node_image_analyzer["Image Analysis<br/>[image_analyzer.py]"]
  node_embeddings["Embeddings<br/>[embeddings.py]"]
  node_vector_store[("Vector Store<br/>[vector_store.py]")]
  node_bm25[("BM25 Index<br/>[bm25_retriever.py]")]
end

subgraph group_answering["Answer Pipeline"]
  node_pipeline["RAG Pipeline<br/>[pipeline.py]"]
  node_query_prep["Query Preparation<br/>[query.py]"]
  node_query_normalizer["Alias Normalization"]
  node_retrieval["Hybrid Retrieval<br/>[retrieval.py]"]
  node_context["Context Selection<br/>[context.py]"]
  node_evidence["Evidence Gate<br/>[evidence.py]"]
  node_generation["Answer Generation<br/>[generation.py]"]
  node_fallback["Fallback Answers<br/>[fallback.py]"]
  node_citations["Claim Citations<br/>[citations.py]"]
end

subgraph group_quality["Quality and Observability"]
  node_evaluation["RAG Evaluation<br/>[evaluation.py]"]
  node_ragas["RAGAS Evaluation"]
  node_observability["Observability<br/>[observability.py]"]
  node_observation_store[("Observation Store")]
  node_observatory["Observatory<br/>[observatory.py]"]
end

node_user(("User"))

node_user -.->|"asks questions"| node_app
node_app -.->|"renders"| node_ui_pages
node_ui_pages -.->|"submits queries"| node_pipeline
node_ui_pages -->|"uses theme"| node_ui_theme
node_ui_pages -->|"reads observations"| node_observation_store
node_ingest -->|"lists files"| node_document_loader
node_ingest -->|"starts ingestion"| node_pipeline
node_pipeline -->|"loads documents"| node_document_loader
node_pipeline -->|"creates embeddings"| node_embeddings
node_pipeline -->|"updates index"| node_vector_store
node_pipeline -->|"updates index"| node_bm25
node_pipeline -->|"prepares query"| node_query_prep
node_pipeline -->|"normalizes query"| node_query_normalizer
node_pipeline -->|"retrieves candidates"| node_retrieval
node_pipeline -->|"selects context"| node_context
node_pipeline -->|"evaluates evidence"| node_evidence
node_pipeline -->|"generates answer"| node_generation
node_pipeline -->|"tries fallback"| node_fallback
node_pipeline -->|"adds citations"| node_citations
node_pipeline -->|"uses evaluation"| node_evaluation
node_pipeline -->|"records telemetry"| node_observability
node_pipeline -->|"stores observations"| node_observation_store
node_pipeline -.->|"analyzes images"| node_image_analyzer
node_evaluation -.->|"may evaluate with"| node_ragas
node_ui_pages -.->|"opens diagnostics"| node_observatory

click node_app "https://github.com/shre167/rag-model/blob/main/app.py"
click node_ui_pages "https://github.com/shre167/rag-model/blob/main/src/ui/pages.py"
click node_ui_theme "https://github.com/shre167/rag-model/blob/main/src/ui/astronomy_theme.py"
click node_ingest "https://github.com/shre167/rag-model/blob/main/ingest.py"
click node_document_loader "https://github.com/shre167/rag-model/blob/main/src/document_loader.py"
click node_image_analyzer "https://github.com/shre167/rag-model/blob/main/src/image_analyzer.py"
click node_embeddings "https://github.com/shre167/rag-model/blob/main/src/embeddings.py"
click node_vector_store "https://github.com/shre167/rag-model/blob/main/src/vector_store.py"
click node_bm25 "https://github.com/shre167/rag-model/blob/main/src/bm25_retriever.py"
click node_pipeline "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/pipeline.py"
click node_query_prep "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/query.py"
click node_query_normalizer "https://github.com/shre167/rag-model/blob/main/src/query_normalizer.py"
click node_retrieval "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/retrieval.py"
click node_context "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/context.py"
click node_evidence "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/evidence.py"
click node_generation "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/generation.py"
click node_fallback "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/fallback.py"
click node_citations "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/citations.py"
click node_evaluation "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/evaluation.py"
click node_ragas "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/ragas_evaluation.py"
click node_observability "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observability.py"
click node_observation_store "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observation_store.py"
click node_observatory "https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observatory.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_app,node_ui_pages,node_ui_theme,node_user toneBlue
class node_ingest,node_document_loader,node_image_analyzer,node_embeddings,node_vector_store,node_bm25 toneAmber
class node_pipeline,node_query_prep,node_query_normalizer,node_retrieval,node_context,node_evidence,node_generation,node_fallback,node_citations toneMint
class node_evaluation,node_ragas,node_observability,node_observation_store,node_observatory toneRose
```

## Components

### User Interface

- [Streamlit App](https://github.com/shre167/rag-model/blob/main/app.py): `app.py`
- [UI Pages](https://github.com/shre167/rag-model/blob/main/src/ui/pages.py): `src/ui/pages.py`
- [Astronomy Theme](https://github.com/shre167/rag-model/blob/main/src/ui/astronomy_theme.py): `src/ui/astronomy_theme.py`

### Knowledge Indexing

- [Ingestion Command](https://github.com/shre167/rag-model/blob/main/ingest.py): `ingest.py`
- [Document Loading](https://github.com/shre167/rag-model/blob/main/src/document_loader.py): `src/document_loader.py`
- [Image Analysis](https://github.com/shre167/rag-model/blob/main/src/image_analyzer.py): `src/image_analyzer.py`
- [Embeddings](https://github.com/shre167/rag-model/blob/main/src/embeddings.py): `src/embeddings.py`
- [Vector Store](https://github.com/shre167/rag-model/blob/main/src/vector_store.py): `src/vector_store.py`
- [BM25 Index](https://github.com/shre167/rag-model/blob/main/src/bm25_retriever.py): `src/bm25_retriever.py`

### Answer Pipeline

- [RAG Pipeline](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/pipeline.py): `src/rag_pipeline/pipeline.py`
- [Query Preparation](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/query.py): `src/rag_pipeline/query.py`
- [Alias Normalization](https://github.com/shre167/rag-model/blob/main/src/query_normalizer.py): `src/query_normalizer.py`
- [Hybrid Retrieval](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/retrieval.py): `src/rag_pipeline/retrieval.py`
- [Context Selection](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/context.py): `src/rag_pipeline/context.py`
- [Evidence Gate](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/evidence.py): `src/rag_pipeline/evidence.py`
- [Answer Generation](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/generation.py): `src/rag_pipeline/generation.py`
- [Fallback Answers](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/fallback.py): `src/rag_pipeline/fallback.py`
- [Claim Citations](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/citations.py): `src/rag_pipeline/citations.py`

### Quality and Observability

- [RAG Evaluation](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/evaluation.py): `src/rag_pipeline/evaluation.py`
- [RAGAS Evaluation](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/ragas_evaluation.py): `src/rag_pipeline/ragas_evaluation.py`
- [Observability](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observability.py): `src/rag_pipeline/observability.py`
- [Observation Store](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observation_store.py): `src/rag_pipeline/observation_store.py`
- [Observatory](https://github.com/shre167/rag-model/blob/main/src/rag_pipeline/observatory.py): `src/rag_pipeline/observatory.py`

### Other components

- **User**

## Connections

- User → Streamlit App: asks questions
- Streamlit App → UI Pages: renders
- UI Pages → RAG Pipeline: submits queries
- UI Pages → Astronomy Theme: uses theme (evidence: `src/ui/pages.py`)
- UI Pages → Observation Store: reads observations (evidence: `src/ui/pages.py`)
- Ingestion Command → Document Loading: lists files (evidence: `ingest.py`)
- Ingestion Command → RAG Pipeline: starts ingestion (evidence: `ingest.py`)
- RAG Pipeline → Document Loading: loads documents (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Embeddings: creates embeddings (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Vector Store: updates index (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → BM25 Index: updates index (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Query Preparation: prepares query (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Alias Normalization: normalizes query (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Hybrid Retrieval: retrieves candidates (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Context Selection: selects context (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Evidence Gate: evaluates evidence (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Answer Generation: generates answer (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Fallback Answers: tries fallback (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Claim Citations: adds citations (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → RAG Evaluation: uses evaluation (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Observability: records telemetry (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Observation Store: stores observations (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Pipeline → Image Analysis: analyzes images (evidence: `src/rag_pipeline/pipeline.py`)
- RAG Evaluation → RAGAS Evaluation: may evaluate with
- UI Pages → Observatory: opens diagnostics
