# mehmoodosman/codebase-rag architecture

> Architecture diagram of the GitHub repository mehmoodosman/codebase-rag, 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/mehmoodosman/codebase-rag
- Repository: https://github.com/mehmoodosman/codebase-rag

## Overview

Codebase RAG is a Streamlit chat application for asking questions about indexed code repositories. The user selects a Pinecone namespace and submits a question; the app embeds the query, retrieves code matches, adds their metadata and text to the prompt, and requests an answer from Groq’s Llama model. Chat history is retained in Streamlit session state. The README also describes semantic search, multiple repositories, and context-aware chat. The tree contains only one runtime source file; subsystem boundaries below reflect its documented and visible responsibilities.

Main entry points: [`streamlit_app.py`](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py) (RAG query handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat interaction"]
  node_chat["Streamlit chat<br/>[streamlit_app.py]"]
  node_history["Session history<br/>[streamlit_app.py]"]
  node_namespace["Namespace selection<br/>[streamlit_app.py]"]
end

subgraph group_retrieval["Code retrieval"]
  node_rag["RAG query handler<br/>[streamlit_app.py]"]
  node_embed["Query embedding<br/>[streamlit_app.py]"]
end

subgraph group_generation["Answer generation"]
  node_context["Context augmentation<br/>[streamlit_app.py]"]
end

node_user(("User"))
node_embedding_model["Sentence Transformers"]
node_index[("Pinecone index")]
node_llm["Groq Llama API"]

node_user -->|"asks question"| node_chat
node_chat -->|"reads and writes"| node_history
node_chat -->|"selects namespace"| node_namespace
node_chat -->|"calls"| node_rag
node_rag -->|"embeds query"| node_embed
node_embed -->|"encodes text"| node_embedding_model
node_rag -->|"queries namespace"| node_index
node_index -->|"returns matches"| node_rag
node_rag -->|"formats matches"| node_context
node_context -->|"sends augmented prompt"| node_llm
node_llm -->|"returns answer"| node_context
node_context -->|"returns answer"| node_rag
node_rag -->|"returns answer"| node_chat

click node_chat "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py"
click node_history "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py"
click node_namespace "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py"
click node_rag "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py"
click node_embed "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py"
click node_context "https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.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_chat,node_history,node_namespace,node_user toneBlue
class node_rag,node_embed,node_index toneAmber
class node_context,node_llm toneMint
class node_embedding_model toneIndigo
```

## Components

### Chat interaction

- [Streamlit chat](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`
- [Session history](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`
- [Namespace selection](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`

### Code retrieval

- [RAG query handler](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`
- [Query embedding](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`

### Answer generation

- [Context augmentation](https://github.com/mehmoodosman/codebase-rag/blob/main/streamlit_app.py): `streamlit_app.py`

### Other components

- **User**
- **Sentence Transformers**
- **Pinecone index**
- **Groq Llama API**

## Connections

- User → Streamlit chat: asks question
- Streamlit chat → Session history: reads and writes
- Streamlit chat → Namespace selection: selects namespace
- Streamlit chat → RAG query handler: calls
- RAG query handler → Query embedding: embeds query
- Query embedding → Sentence Transformers: encodes text
- RAG query handler → Pinecone index: queries namespace
- Pinecone index → RAG query handler: returns matches
- RAG query handler → Context augmentation: formats matches
- Context augmentation → Groq Llama API: sends augmented prompt
- Groq Llama API → Context augmentation: returns answer
- Context augmentation → RAG query handler: returns answer
- RAG query handler → Streamlit chat: returns answer
