# jogindernrajput/langchain-agent architecture

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

- Interactive diagram: https://gitdiagram.com/jogindernrajput/langchain-agent
- Repository: https://github.com/jogindernrajput/langchain-agent

## Overview

Agentic Research Agent is a provider-agnostic research assistant with CLI and HTTP entry points, a ReAct tool-using mode, and a supervisor-driven multi-agent RAG mode. The principal workflow accepts a question, selects a configured service, runs an agent graph, and returns an answer; knowledge-base ingestion and retrieval support the RAG branches. The graph distinguishes retrieval, synthesis, and critique in multi-agent mode. Some API startup and graph wiring excerpts are incomplete, so only documented or sampled connections are shown.

Main entry points: [`src/agentic_research_agent/multiagent/service.py`](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/service.py) (MultiAgentRAG), [`src/agentic_research_agent/agents/service.py`](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/service.py) (ResearchAgent), [`src/agentic_research_agent/rag/retriever.py`](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/retriever.py) (Hybrid retriever), [`src/agentic_research_agent/agents/graph.py`](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/graph.py) (ReAct graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[cli.py]"]
  node_api["HTTP API<br/>[app.py]"]
end

subgraph group_orchestration["Agent orchestration"]
  node_service_factory["Mode selector<br/>[service_factory.py]"]
  node_single_service["ResearchAgent<br/>[service.py]"]
  node_single_graph["ReAct graph<br/>[graph.py]"]
  node_multi_service["MultiAgentRAG<br/>[service.py]"]
  node_multi_graph["Supervisor graph<br/>[graph.py]"]
  node_retrieval_stage["Retrieval stage<br/>[graph.py]"]
  node_synthesis_stage["Synthesis stage<br/>[graph.py]"]
  node_critic_stage["Grounding critic<br/>[graph.py]"]
end

subgraph group_rag["Retrieval and knowledge"]
  node_knowledge_base[("Knowledge base<br/>[knowledge_base.py]")]
  node_hybrid_retriever["Hybrid retriever<br/>[retriever.py]"]
  node_query_transformer["Query expansion<br/>[query_transform.py]"]
  node_reranker["Cross-encoder reranker<br/>[reranker.py]"]
  node_corpus["Source documents"]
end

subgraph group_capabilities["Tools and models"]
  node_web_search["Web search<br/>[web_search.py]"]
  node_calculator["Calculator<br/>[calculator.py]"]
  node_llm_factory["Chat model factory<br/>[llm.py]"]
end

subgraph group_state["Configuration and memory"]
  node_settings["Settings<br/>[settings.py]"]
  node_checkpointer[("Conversation checkpointer<br/>[checkpointer.py]")]
end

node_user(("Question asker"))
node_llm_provider{{"LLM provider"}}
node_answer(("Answer consumer"))
node_web{{"DuckDuckGo"}}

node_user -->|"asks via"| node_cli
node_user -->|"submits to"| node_api
node_cli -->|"builds service"| node_service_factory
node_api -->|"builds service"| node_service_factory
node_service_factory -->|"selects single"| node_single_service
node_service_factory -->|"selects multiagent"| node_multi_service
node_single_service -->|"builds and invokes"| node_single_graph
node_multi_service -->|"builds and invokes"| node_multi_graph
node_single_service -->|"builds model"| node_llm_factory
node_multi_service -->|"builds model"| node_llm_factory
node_single_service -->|"builds index"| node_knowledge_base
node_single_service -->|"builds memory"| node_checkpointer
node_multi_service -->|"builds index"| node_knowledge_base
node_multi_service -->|"builds retriever"| node_hybrid_retriever
node_multi_service -->|"builds expander"| node_query_transformer
node_multi_service -->|"builds memory"| node_checkpointer
node_single_graph -->|"dispatches tool"| node_web_search
node_single_graph -->|"dispatches tool"| node_knowledge_base
node_single_graph -->|"dispatches tool"| node_calculator
node_multi_graph -->|"routes to"| node_retrieval_stage
node_multi_graph -->|"routes to"| node_synthesis_stage
node_multi_graph -->|"routes to"| node_critic_stage
node_retrieval_stage -->|"expands query"| node_query_transformer
node_retrieval_stage -->|"retrieves chunks"| node_hybrid_retriever
node_hybrid_retriever -->|"dense-searches"| node_knowledge_base
node_hybrid_retriever -->|"ranks lexically"| node_corpus
node_hybrid_retriever -.->|"optionally reranks"| node_reranker
node_query_transformer -->|"invokes model"| node_llm_factory
node_llm_factory -->|"constructs provider"| node_llm_provider
node_single_service -->|"reads configuration"| node_settings
node_multi_service -->|"reads configuration"| node_settings
node_web_search -->|"searches web"| node_web
node_single_service -->|"returns answer"| node_answer
node_multi_service -->|"returns answer"| node_answer

click node_cli "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/cli.py"
click node_api "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/api/app.py"
click node_service_factory "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/service_factory.py"
click node_single_service "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/service.py"
click node_single_graph "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/graph.py"
click node_multi_service "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/service.py"
click node_multi_graph "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py"
click node_retrieval_stage "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py"
click node_synthesis_stage "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py"
click node_critic_stage "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py"
click node_knowledge_base "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/knowledge_base.py"
click node_hybrid_retriever "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/retriever.py"
click node_query_transformer "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/query_transform.py"
click node_reranker "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/reranker.py"
click node_corpus "https://github.com/jogindernrajput/langchain-agent/tree/main/data/knowledge_base"
click node_web_search "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/web_search.py"
click node_calculator "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/calculator.py"
click node_llm_factory "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/core/llm.py"
click node_settings "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/config/settings.py"
click node_checkpointer "https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/checkpointer.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_api toneBlue
class node_service_factory,node_single_service,node_single_graph,node_multi_service,node_multi_graph,node_retrieval_stage,node_synthesis_stage,node_critic_stage toneAmber
class node_knowledge_base,node_hybrid_retriever,node_query_transformer,node_reranker,node_corpus toneMint
class node_web_search,node_calculator,node_llm_factory toneRose
class node_settings,node_checkpointer,node_user,node_llm_provider,node_answer,node_web toneIndigo
```

## Components

### Entry points

- [CLI](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/cli.py): `src/agentic_research_agent/cli.py`
- [HTTP API](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/api/app.py): `src/agentic_research_agent/api/app.py`

### Agent orchestration

- [Mode selector](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/service_factory.py): `src/agentic_research_agent/service_factory.py`
- [ResearchAgent](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/service.py): `src/agentic_research_agent/agents/service.py`
- [ReAct graph](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/graph.py): `src/agentic_research_agent/agents/graph.py`
- [MultiAgentRAG](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/service.py): `src/agentic_research_agent/multiagent/service.py`
- [Supervisor graph](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py): `src/agentic_research_agent/multiagent/graph.py`
- [Retrieval stage](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py): `src/agentic_research_agent/multiagent/graph.py`
- [Synthesis stage](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py): `src/agentic_research_agent/multiagent/graph.py`
- [Grounding critic](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/multiagent/graph.py): `src/agentic_research_agent/multiagent/graph.py`

### Retrieval and knowledge

- [Knowledge base](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/knowledge_base.py): `src/agentic_research_agent/tools/knowledge_base.py`
- [Hybrid retriever](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/retriever.py): `src/agentic_research_agent/rag/retriever.py`
- [Query expansion](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/query_transform.py): `src/agentic_research_agent/rag/query_transform.py`
- [Cross-encoder reranker](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/rag/reranker.py): `src/agentic_research_agent/rag/reranker.py`
- [Source documents](https://github.com/jogindernrajput/langchain-agent/tree/main/data/knowledge_base): `data/knowledge_base`

### Tools and models

- [Web search](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/web_search.py): `src/agentic_research_agent/tools/web_search.py`
- [Calculator](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/tools/calculator.py): `src/agentic_research_agent/tools/calculator.py`
- [Chat model factory](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/core/llm.py): `src/agentic_research_agent/core/llm.py`

### Configuration and memory

- [Settings](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/config/settings.py): `src/agentic_research_agent/config/settings.py`
- [Conversation checkpointer](https://github.com/jogindernrajput/langchain-agent/blob/main/src/agentic_research_agent/agents/checkpointer.py): `src/agentic_research_agent/agents/checkpointer.py`

### Other components

- **Question asker**
- **LLM provider**
- **Answer consumer**
- **DuckDuckGo**

## Connections

- Question asker → CLI: asks via
- Question asker → HTTP API: submits to
- CLI → Mode selector: builds service
- HTTP API → Mode selector: builds service
- Mode selector → ResearchAgent: selects single
- Mode selector → MultiAgentRAG: selects multiagent
- ResearchAgent → ReAct graph: builds and invokes
- MultiAgentRAG → Supervisor graph: builds and invokes
- ResearchAgent → Chat model factory: builds model
- MultiAgentRAG → Chat model factory: builds model
- ResearchAgent → Knowledge base: builds index
- ResearchAgent → Conversation checkpointer: builds memory
- MultiAgentRAG → Knowledge base: builds index
- MultiAgentRAG → Hybrid retriever: builds retriever
- MultiAgentRAG → Query expansion: builds expander
- MultiAgentRAG → Conversation checkpointer: builds memory
- ReAct graph → Web search: dispatches tool
- ReAct graph → Knowledge base: dispatches tool
- ReAct graph → Calculator: dispatches tool
- Supervisor graph → Retrieval stage: routes to
- Supervisor graph → Synthesis stage: routes to
- Supervisor graph → Grounding critic: routes to
- Retrieval stage → Query expansion: expands query
- Retrieval stage → Hybrid retriever: retrieves chunks
- Hybrid retriever → Knowledge base: dense-searches
- Hybrid retriever → Source documents: ranks lexically
- Hybrid retriever → Cross-encoder reranker: optionally reranks
- Query expansion → Chat model factory: invokes model
- Chat model factory → LLM provider: constructs provider
- ResearchAgent → Settings: reads configuration
- MultiAgentRAG → Settings: reads configuration
- Web search → DuckDuckGo: searches web
- ResearchAgent → Answer consumer: returns answer
- MultiAgentRAG → Answer consumer: returns answer
