# chandanc5525/rag_using_langchain_langgraph_langsmith architecture

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

- Interactive diagram: https://gitdiagram.com/chandanc5525/rag_using_langchain_langgraph_langsmith
- Repository: https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith

## Overview

This repository is a book-code companion with two runtime products: a command-line RAG workbench and the AskMyDocs application. The main user workflow is to upload documents, ingest and index them, then ask questions and receive grounded answers with sources. The workbench also demonstrates advanced retrieval, LangGraph workflows, and evaluation. Relationships below are limited to source excerpts, SOURCE INDEX references, and README statements; unsampled subsystems are represented without speculative internal call chains.

Main entry points: [`askmydocs/app/services/rag_service.py`](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/services/rag_service.py) (RAG Service), [`workbench/rag/chains.py`](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/chains.py) (RAG Chains), [`workbench/main.py`](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/main.py) (CLI Assistant), [`workbench/rag/vectorstore.py`](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/vectorstore.py) (Vector Store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workbench["RAG Workbench"]
  node_cli["CLI Assistant<br/>[main.py]"]
  node_ingestion["Document Ingestion<br/>[ingestion.py]"]
  node_cleaning["Cleaning<br/>[cleaning.py]"]
  node_chunking["Chunking<br/>[chunking.py]"]
  node_embeddings["Embedding Models<br/>[models.py]"]
  node_vectorstore[("Vector Store<br/>[vectorstore.py]")]
  node_retrieval["Retrieval<br/>[retrieval.py]"]
  node_context["Context Building<br/>[context.py]"]
  node_prompts["RAG Prompts<br/>[prompts.py]"]
  node_llm["Chat Model<br/>[llm.py]"]
  node_chains["RAG Chains<br/>[chains.py]"]
end

subgraph group_advanced["Advanced RAG"]
  node_advanced_retrieval["Advanced Retrieval<br/>[advanced.py]"]
  node_graphs["LangGraph Workflows<br/>[graphs.py]"]
end

subgraph group_askmydocs["AskMyDocs Core"]
  node_service["RAG Service<br/>[rag_service.py]"]
  node_loaders["File Loaders<br/>[loaders.py]"]
  node_app_chunking["Chunking<br/>[chunking.py]"]
  node_app_embeddings["Embedding Factory<br/>[embeddings.py]"]
  node_app_index[("Document Index<br/>[vectorstore.py]")]
  node_app_context["Context Builder<br/>[context.py]"]
  node_app_prompts["Answer Prompts<br/>[prompts.py]"]
  node_app_llm["Chat Model<br/>[llm.py]"]
  node_settings["Configuration<br/>[config.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_streamlit["Streamlit Chat<br/>[streamlit_app.py]"]
  node_api["REST API<br/>[main.py]"]
  node_schemas["API Schemas<br/>[schemas.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluation["RAG Evaluation<br/>[evaluation.py]"]
end

node_cli_user(("CLI User"))
node_ask_user(("Document User"))
node_ollama["Ollama Model Service"]

node_cli_user -->|"asks"| node_cli
node_cli -->|"gets index"| node_vectorstore
node_cli -->|"gets retriever"| node_retrieval
node_cli -->|"builds chain"| node_chains
node_chains -->|"retrieves"| node_retrieval
node_chains -->|"builds context"| node_context
node_chains -->|"uses prompt"| node_prompts
node_chains -->|"calls model"| node_llm
node_vectorstore -->|"loads documents"| node_ingestion
node_vectorstore -->|"chunks documents"| node_chunking
node_vectorstore -->|"uses embeddings"| node_embeddings
node_ingestion -->|"enriches text"| node_cleaning
node_advanced_retrieval -.->|"extends retrieval"| node_retrieval
node_graphs -.->|"coordinates retrieval"| node_retrieval
node_evaluation -.->|"evaluates pipelines"| node_advanced_retrieval
node_ask_user -->|"chats"| node_streamlit
node_streamlit -.->|"uses API"| node_api
node_api -->|"validates requests"| node_schemas
node_api -->|"delegates"| node_service
node_service -->|"loads files"| node_loaders
node_service -->|"splits documents"| node_app_chunking
node_service -->|"creates embeddings"| node_app_embeddings
node_service -->|"searches and updates"| node_app_index
node_service -->|"builds context"| node_app_context
node_service -->|"creates chains"| node_app_prompts
node_service -->|"creates chains"| node_app_llm
node_service -->|"reads settings"| node_settings
node_service -->|"checks model"| node_ollama
node_app_llm -->|"connects to"| node_ollama

click node_cli "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/main.py"
click node_ingestion "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/ingestion.py"
click node_cleaning "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/cleaning.py"
click node_chunking "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/chunking.py"
click node_embeddings "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/models.py"
click node_vectorstore "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/vectorstore.py"
click node_retrieval "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/retrieval.py"
click node_context "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/context.py"
click node_prompts "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/prompts.py"
click node_llm "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/llm.py"
click node_chains "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/chains.py"
click node_advanced_retrieval "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/advanced.py"
click node_graphs "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/graphs.py"
click node_evaluation "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/evaluation.py"
click node_streamlit "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/frontend/streamlit_app.py"
click node_api "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/backend/main.py"
click node_schemas "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/backend/schemas.py"
click node_service "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/services/rag_service.py"
click node_loaders "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/loaders.py"
click node_app_chunking "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/chunking.py"
click node_app_embeddings "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/embeddings.py"
click node_app_index "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/vectorstore.py"
click node_app_context "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/context.py"
click node_app_prompts "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/prompts.py"
click node_app_llm "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/llm.py"
click node_settings "https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/config.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_cli,node_ingestion,node_cleaning,node_chunking,node_embeddings,node_vectorstore,node_retrieval,node_context,node_prompts,node_llm,node_chains,node_cli_user,node_ask_user toneBlue
class node_advanced_retrieval,node_graphs toneAmber
class node_service,node_loaders,node_app_chunking,node_app_embeddings,node_app_index,node_app_context,node_app_prompts,node_app_llm,node_settings toneMint
class node_streamlit,node_api,node_schemas toneRose
class node_evaluation,node_ollama toneIndigo
```

## Components

### RAG Workbench

- [CLI Assistant](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/main.py): `workbench/main.py`
- [Document Ingestion](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/ingestion.py): `workbench/rag/ingestion.py`
- [Cleaning](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/cleaning.py): `workbench/rag/cleaning.py`
- [Chunking](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/chunking.py): `workbench/rag/chunking.py`
- [Embedding Models](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/models.py): `workbench/rag/models.py`
- [Vector Store](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/vectorstore.py): `workbench/rag/vectorstore.py`
- [Retrieval](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/retrieval.py): `workbench/rag/retrieval.py`
- [Context Building](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/context.py): `workbench/rag/context.py`
- [RAG Prompts](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/prompts.py): `workbench/rag/prompts.py`
- [Chat Model](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/llm.py): `workbench/rag/llm.py`
- [RAG Chains](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/chains.py): `workbench/rag/chains.py`

### Advanced RAG

- [Advanced Retrieval](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/advanced.py): `workbench/rag/advanced.py`
- [LangGraph Workflows](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/graphs.py): `workbench/rag/graphs.py`

### AskMyDocs Core

- [RAG Service](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/services/rag_service.py): `askmydocs/app/services/rag_service.py`
- [File Loaders](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/loaders.py): `askmydocs/app/core/loaders.py`
- [Chunking](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/chunking.py): `askmydocs/app/core/chunking.py`
- [Embedding Factory](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/embeddings.py): `askmydocs/app/core/embeddings.py`
- [Document Index](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/vectorstore.py): `askmydocs/app/core/vectorstore.py`
- [Context Builder](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/context.py): `askmydocs/app/core/context.py`
- [Answer Prompts](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/prompts.py): `askmydocs/app/core/prompts.py`
- [Chat Model](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/core/llm.py): `askmydocs/app/core/llm.py`
- [Configuration](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/app/config.py): `askmydocs/app/config.py`

### User Interfaces

- [Streamlit Chat](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/frontend/streamlit_app.py): `askmydocs/frontend/streamlit_app.py`
- [REST API](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/backend/main.py): `askmydocs/backend/main.py`
- [API Schemas](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/askmydocs/backend/schemas.py): `askmydocs/backend/schemas.py`

### Evaluation

- [RAG Evaluation](https://github.com/chandanc5525/rag_using_langchain_langgraph_langsmith/blob/main/workbench/rag/evaluation.py): `workbench/rag/evaluation.py`

### Other components

- **CLI User**
- **Document User**
- **Ollama Model Service**

## Connections

- CLI User → CLI Assistant: asks (evidence: `workbench/main.py`)
- CLI Assistant → Vector Store: gets index (evidence: `workbench/main.py`)
- CLI Assistant → Retrieval: gets retriever (evidence: `workbench/main.py`)
- CLI Assistant → RAG Chains: builds chain (evidence: `workbench/main.py`)
- RAG Chains → Retrieval: retrieves
- RAG Chains → Context Building: builds context (evidence: `workbench/rag/chains.py`)
- RAG Chains → RAG Prompts: uses prompt (evidence: `workbench/rag/chains.py`)
- RAG Chains → Chat Model: calls model (evidence: `workbench/rag/chains.py`)
- Vector Store → Document Ingestion: loads documents (evidence: `workbench/rag/vectorstore.py`)
- Vector Store → Chunking: chunks documents (evidence: `workbench/rag/vectorstore.py`)
- Vector Store → Embedding Models: uses embeddings (evidence: `workbench/rag/vectorstore.py`)
- Document Ingestion → Cleaning: enriches text (evidence: `workbench/rag/ingestion.py`)
- Advanced Retrieval → Retrieval: extends retrieval
- LangGraph Workflows → Retrieval: coordinates retrieval
- RAG Evaluation → Advanced Retrieval: evaluates pipelines
- Document User → Streamlit Chat: chats (evidence: `README.md`)
- Streamlit Chat → REST API: uses API (evidence: `README.md`)
- REST API → API Schemas: validates requests (evidence: `askmydocs/backend/main.py`)
- REST API → RAG Service: delegates (evidence: `askmydocs/backend/main.py`)
- RAG Service → File Loaders: loads files (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Chunking: splits documents (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Embedding Factory: creates embeddings (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Document Index: searches and updates (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Context Builder: builds context (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Answer Prompts: creates chains (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Chat Model: creates chains (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Configuration: reads settings (evidence: `askmydocs/app/services/rag_service.py`)
- RAG Service → Ollama Model Service: checks model (evidence: `askmydocs/app/services/rag_service.py`)
- Chat Model → Ollama Model Service: connects to (evidence: `README.md`)
