# muralikrishna1729/codesage architecture

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

- Interactive diagram: https://gitdiagram.com/muralikrishna1729/codesage
- Repository: https://github.com/muralikrishna1729/codesage

## Overview

This is a repository-question-answering RAG assistant: users submit a repository for ingestion, then ask questions and receive answers with source citations or an explicit fallback. Ingestion clones the repository, extracts code chunks, embeds them, and stores them; chat routes questions through retrieval, evidence grading, and answer generation, using web search when appropriate. The README also describes repository-map context and sandboxed code execution, but the supplied tree has no code-execution or frontend modules, and the excerpts do not show repository-map wiring. Arrows reflect shown calls or documented relationships.

Main entry points: [`app/api/routes.py`](https://github.com/muralikrishna1729/codesage/blob/main/app/api/routes.py) (HTTP API), [`app/ingestion/embed_store.py`](https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/embed_store.py) (Embedding and retrieval), [`app/agent/graph.py`](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/graph.py) (Workflow orchestration), [`app/agent/nodes.py`](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/nodes.py) (Routing and answer nodes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and entry"]
  node_api_routes["HTTP API<br/>[routes.py]"]
end

subgraph group_ingestion["Repository ingestion"]
  node_clone["Repository clone<br/>[clone.py]"]
  node_chunker["Code chunking<br/>[chunker.py]"]
  node_repo_map["Repository map<br/>[repo_map.py]"]
  node_embed_store["Embedding and retrieval<br/>[embed_store.py]"]
end

subgraph group_agent["Agent workflow"]
  node_graph["Workflow orchestration<br/>[graph.py]"]
  node_state["Agent state<br/>[state.py]"]
  node_agent_nodes["Routing and answer nodes<br/>[nodes.py]"]
end

subgraph group_services["Models and search"]
  node_qdrant[("Qdrant vector store")]
  node_embed_model["Sentence Transformers"]
  node_llm_client["LLM provider client<br/>[llm_client.py]"]
  node_config["Runtime settings<br/>[config.py]"]
  node_web_search["Web search tool<br/>[web_search.py]"]
end

node_user(("User"))
node_llm_providers["Groq, OpenRouter, Gemini"]
node_web_providers["Tavily and DuckDuckGo"]
node_answer["Answer and source"]

node_user -->|"submits request"| node_api_routes
node_api_routes -->|"clones repository"| node_clone
node_api_routes -->|"chunks repository"| node_chunker
node_api_routes -->|"stores chunks"| node_embed_store
node_embed_store -->|"encodes chunks"| node_embed_model
node_embed_store -->|"writes and searches"| node_qdrant
node_api_routes -->|"invokes chat workflow"| node_graph
node_graph -->|"types workflow state"| node_state
node_graph -->|"dispatches workflow steps"| node_agent_nodes
node_agent_nodes -->|"retrieves code context"| node_embed_store
node_agent_nodes -->|"routes and generates"| node_llm_client
node_agent_nodes -->|"searches web evidence"| node_web_search
node_llm_client -->|"reads provider settings"| node_config
node_llm_client -->|"calls providers"| node_llm_providers
node_web_search -->|"reads search settings"| node_config
node_web_search -->|"searches with fallback"| node_web_providers
node_graph -->|"returns final result"| node_answer
node_user -->|"receives response"| node_answer
node_repo_map -.->|"adds structural retrieval context"| node_embed_store

click node_api_routes "https://github.com/muralikrishna1729/codesage/blob/main/app/api/routes.py"
click node_clone "https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/clone.py"
click node_chunker "https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/chunker.py"
click node_repo_map "https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/repo_map.py"
click node_embed_store "https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/embed_store.py"
click node_graph "https://github.com/muralikrishna1729/codesage/blob/main/app/agent/graph.py"
click node_state "https://github.com/muralikrishna1729/codesage/blob/main/app/agent/state.py"
click node_agent_nodes "https://github.com/muralikrishna1729/codesage/blob/main/app/agent/nodes.py"
click node_llm_client "https://github.com/muralikrishna1729/codesage/blob/main/app/agent/llm_client.py"
click node_config "https://github.com/muralikrishna1729/codesage/blob/main/app/config.py"
click node_web_search "https://github.com/muralikrishna1729/codesage/blob/main/app/tools/web_search.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_api_routes,node_user toneBlue
class node_clone,node_chunker,node_repo_map,node_embed_store toneAmber
class node_graph,node_state,node_agent_nodes,node_llm_providers toneMint
class node_qdrant,node_embed_model,node_llm_client,node_config,node_web_search toneRose
class node_web_providers,node_answer toneIndigo
```

## Components

### API and entry

- [HTTP API](https://github.com/muralikrishna1729/codesage/blob/main/app/api/routes.py): `app/api/routes.py`

### Repository ingestion

- [Repository clone](https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/clone.py): `app/ingestion/clone.py`
- [Code chunking](https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/chunker.py): `app/ingestion/chunker.py`
- [Repository map](https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/repo_map.py): `app/ingestion/repo_map.py`
- [Embedding and retrieval](https://github.com/muralikrishna1729/codesage/blob/main/app/ingestion/embed_store.py): `app/ingestion/embed_store.py`

### Agent workflow

- [Workflow orchestration](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/graph.py): `app/agent/graph.py`
- [Agent state](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/state.py): `app/agent/state.py`
- [Routing and answer nodes](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/nodes.py): `app/agent/nodes.py`

### Models and search

- **Qdrant vector store**
- **Sentence Transformers**
- [LLM provider client](https://github.com/muralikrishna1729/codesage/blob/main/app/agent/llm_client.py): `app/agent/llm_client.py`
- [Runtime settings](https://github.com/muralikrishna1729/codesage/blob/main/app/config.py): `app/config.py`
- [Web search tool](https://github.com/muralikrishna1729/codesage/blob/main/app/tools/web_search.py): `app/tools/web_search.py`

### Other components

- **User**
- **Groq, OpenRouter, Gemini**
- **Tavily and DuckDuckGo**
- **Answer and source**

## Connections

- User → HTTP API: submits request (evidence: `app/api/routes.py`)
- HTTP API → Repository clone: clones repository (evidence: `app/api/routes.py`)
- HTTP API → Code chunking: chunks repository (evidence: `app/api/routes.py`)
- HTTP API → Embedding and retrieval: stores chunks (evidence: `app/api/routes.py`)
- Embedding and retrieval → Sentence Transformers: encodes chunks (evidence: `app/ingestion/embed_store.py`)
- Embedding and retrieval → Qdrant vector store: writes and searches (evidence: `app/ingestion/embed_store.py`)
- HTTP API → Workflow orchestration: invokes chat workflow (evidence: `app/api/routes.py`)
- Workflow orchestration → Agent state: types workflow state (evidence: `app/agent/graph.py`)
- Workflow orchestration → Routing and answer nodes: dispatches workflow steps (evidence: `app/agent/graph.py`)
- Routing and answer nodes → Embedding and retrieval: retrieves code context (evidence: `app/agent/nodes.py`)
- Routing and answer nodes → LLM provider client: routes and generates (evidence: `app/agent/nodes.py`)
- Routing and answer nodes → Web search tool: searches web evidence (evidence: `app/agent/nodes.py`)
- LLM provider client → Runtime settings: reads provider settings (evidence: `app/agent/llm_client.py`)
- LLM provider client → Groq, OpenRouter, Gemini: calls providers (evidence: `app/agent/llm_client.py`)
- Web search tool → Runtime settings: reads search settings (evidence: `app/tools/web_search.py`)
- Web search tool → Tavily and DuckDuckGo: searches with fallback (evidence: `app/tools/web_search.py`)
- Workflow orchestration → Answer and source: returns final result
- User → Answer and source: receives response
- Repository map → Embedding and retrieval: adds structural retrieval context (evidence: `README.md`)
