# keerthanasankar2006/cricket-rag-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/keerthanasankar2006/cricket-rag-assistant
- Repository: https://github.com/keerthanasankar2006/cricket-rag-assistant

## Overview

Cricket RAG Assistant takes a question from the Streamlit interface, sends it to FastAPI, retrieves and reranks match evidence, then prompts a Groq-hosted LLM to produce a cited answer. The README also describes document preparation and indexing into ChromaDB with local Ollama embeddings; the notebook is present in the tree but was not inspected, so those ingestion stages are documented rather than source-verified. Runtime relationships are supported by the sampled app/backend excerpts and README.

Main entry points: [`backend.py`](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py) (Match Retrieval), [`app.py`](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/app.py) (Question Interface), [`cricket_analysis/cricket_rag.ipynb`](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/cricket_analysis/cricket_rag.ipynb) (Split Into Chunks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Document Indexing"]
  node_prep["Prepare Match Text<br/>[cricket_rag.ipynb]"]
  node_chunk["Split Into Chunks<br/>[cricket_rag.ipynb]"]
  node_embed["Ollama Embeddings"]
end

subgraph group_interface["User Interface"]
  node_streamlit["Question Interface<br/>[app.py]"]
  node_api["FastAPI Ask Endpoint<br/>[backend.py]"]
end

subgraph group_retrieval["Evidence Retrieval"]
  node_chroma[("ChromaDB Collection<br/>[backend.py]")]
  node_retrieve["Match Retrieval<br/>[backend.py]"]
  node_rerank["Evidence Reranking<br/>[backend.py]"]
end

subgraph group_answering["Answer Generation"]
  node_context["Context Preparation<br/>[backend.py]"]
  node_prompt["Answer Prompt<br/>[backend.py]"]
  node_groq["Groq LLM"]
  node_answer["Cited Answer<br/>[backend.py]"]
end

node_user(("Questioner"))

node_user -->|"asks"| node_streamlit
node_streamlit -->|"posts question"| node_api
node_api -->|"handles request"| node_retrieve
node_retrieve -->|"searches chunks"| node_chroma
node_retrieve -->|"passes results"| node_rerank
node_rerank -->|"provides evidence"| node_context
node_context -->|"fills context"| node_prompt
node_prompt -->|"invokes model"| node_groq
node_groq -->|"generates"| node_answer
node_answer -->|"returns answer"| node_streamlit
node_prep -->|"converts to chunks"| node_chunk
node_chunk -->|"embeds locally"| node_embed
node_embed -->|"stores vectors"| node_chroma
node_chroma -->|"supplies matches"| node_retrieve

click node_prep "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/cricket_analysis/cricket_rag.ipynb"
click node_chunk "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/cricket_analysis/cricket_rag.ipynb"
click node_chroma "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_streamlit "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/app.py"
click node_api "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_retrieve "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_rerank "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_context "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_prompt "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py"
click node_answer "https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.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_prep,node_chunk,node_embed toneBlue
class node_streamlit,node_api toneAmber
class node_chroma,node_retrieve,node_rerank toneMint
class node_context,node_prompt,node_groq,node_answer toneRose
class node_user toneIndigo
```

## Components

### Document Indexing

- [Prepare Match Text](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/cricket_analysis/cricket_rag.ipynb): `cricket_analysis/cricket_rag.ipynb`
- [Split Into Chunks](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/cricket_analysis/cricket_rag.ipynb): `cricket_analysis/cricket_rag.ipynb`
- **Ollama Embeddings**

### User Interface

- [Question Interface](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/app.py): `app.py`
- [FastAPI Ask Endpoint](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`

### Evidence Retrieval

- [ChromaDB Collection](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`
- [Match Retrieval](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`
- [Evidence Reranking](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`

### Answer Generation

- [Context Preparation](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`
- [Answer Prompt](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`
- **Groq LLM**
- [Cited Answer](https://github.com/keerthanasankar2006/cricket-rag-assistant/blob/main/backend.py): `backend.py`

### Other components

- **Questioner**

## Connections

- Questioner → Question Interface: asks (evidence: `README.md`)
- Question Interface → FastAPI Ask Endpoint: posts question (evidence: `app.py`)
- FastAPI Ask Endpoint → Match Retrieval: handles request (evidence: `backend.py`)
- Match Retrieval → ChromaDB Collection: searches chunks (evidence: `backend.py`)
- Match Retrieval → Evidence Reranking: passes results (evidence: `backend.py`)
- Evidence Reranking → Context Preparation: provides evidence (evidence: `backend.py`)
- Context Preparation → Answer Prompt: fills context (evidence: `backend.py`)
- Answer Prompt → Groq LLM: invokes model (evidence: `backend.py`)
- Groq LLM → Cited Answer: generates (evidence: `backend.py`)
- Cited Answer → Question Interface: returns answer (evidence: `app.py`)
- Prepare Match Text → Split Into Chunks: converts to chunks (evidence: `README.md`)
- Split Into Chunks → Ollama Embeddings: embeds locally (evidence: `README.md`)
- Ollama Embeddings → ChromaDB Collection: stores vectors (evidence: `README.md`)
- ChromaDB Collection → Match Retrieval: supplies matches (evidence: `README.md`)
