# urveebettadapur/contextiq architecture

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

- Interactive diagram: https://gitdiagram.com/urveebettadapur/contextiq
- Repository: https://github.com/urveebettadapur/contextiq

## Overview

ContextIQ is a small, single-script RAG question-answering application. Its workflow loads and chunks a local knowledge file, embeds and indexes the chunks in Chroma, retrieves relevant chunks for a user question, builds a grounded prompt, and generates an answer with Ollama-hosted Llama 2. The README also documents local embedding and vector storage. The source confirms the basic pipeline; it does not show separate ingestion modes, APIs, or interfaces.

Main entry points: [`rag.py`](https://github.com/urveebettadapur/contextiq/blob/main/rag.py) (Chroma Store), [`knowledge.txt`](https://github.com/urveebettadapur/contextiq/blob/main/knowledge.txt) (Knowledge Base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Knowledge Ingestion"]
  node_knowledge["Knowledge Base<br/>[knowledge.txt]"]
  node_chunking["Text Chunking<br/>[rag.py]"]
  node_documents["Chunk Documents<br/>[rag.py]"]
  node_embedding["Text Embeddings<br/>[rag.py]"]
  node_embed_model{{"nomic-embed-text"}}
end

subgraph group_retrieval["Semantic Retrieval"]
  node_chroma[("Chroma Store<br/>[rag.py]")]
  node_search["Similarity Search<br/>[rag.py]"]
end

subgraph group_generation["Grounded Generation"]
  node_context["Retrieved Context<br/>[rag.py]"]
  node_prompt["Grounded Prompt<br/>[rag.py]"]
  node_llama{{"Llama 2"}}
  node_answer["Grounded Answer<br/>[rag.py]"]
end

node_user(("Questioner"))

node_knowledge -->|"read by"| node_chunking
node_chunking -->|"split into"| node_documents
node_documents -->|"indexed by"| node_chroma
node_embedding -->|"calls"| node_embed_model
node_chroma -->|"uses for indexing"| node_embedding
node_user -->|"submits question"| node_search
node_search -->|"searches"| node_chroma
node_chroma -->|"returns matches"| node_search
node_search -->|"provides matches"| node_context
node_context -->|"added to"| node_prompt
node_user -->|"question added to"| node_prompt
node_prompt -->|"sent to"| node_llama
node_llama -->|"generates"| node_answer

click node_knowledge "https://github.com/urveebettadapur/contextiq/blob/main/knowledge.txt"
click node_chunking "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_documents "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_embedding "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_chroma "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_search "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_context "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_prompt "https://github.com/urveebettadapur/contextiq/blob/main/rag.py"
click node_answer "https://github.com/urveebettadapur/contextiq/blob/main/rag.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_knowledge,node_chunking,node_documents,node_embedding,node_embed_model toneBlue
class node_chroma,node_search toneAmber
class node_context,node_prompt,node_llama,node_answer toneMint
class node_user toneIndigo
```

## Components

### Knowledge Ingestion

- [Knowledge Base](https://github.com/urveebettadapur/contextiq/blob/main/knowledge.txt): `knowledge.txt`
- [Text Chunking](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- [Chunk Documents](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- [Text Embeddings](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- **nomic-embed-text**

### Semantic Retrieval

- [Chroma Store](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- [Similarity Search](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`

### Grounded Generation

- [Retrieved Context](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- [Grounded Prompt](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`
- **Llama 2**
- [Grounded Answer](https://github.com/urveebettadapur/contextiq/blob/main/rag.py): `rag.py`

### Other components

- **Questioner**

## Connections

- Knowledge Base → Text Chunking: read by
- Text Chunking → Chunk Documents: split into
- Chunk Documents → Chroma Store: indexed by
- Text Embeddings → nomic-embed-text: calls
- Chroma Store → Text Embeddings: uses for indexing
- Questioner → Similarity Search: submits question
- Similarity Search → Chroma Store: searches
- Chroma Store → Similarity Search: returns matches
- Similarity Search → Retrieved Context: provides matches
- Retrieved Context → Grounded Prompt: added to
- Questioner → Grounded Prompt: question added to
- Grounded Prompt → Llama 2: sent to
- Llama 2 → Grounded Answer: generates
