Component architecture
LangChain's power comes from how its components work together to create sophisticated AI applications. This page provides diagrams showcasing the relationships between different components.
Core component ecosystem
The diagram below shows how LangChain's major components connect to form complete AI applications:
graph TD
%% Input processing
subgraph "📥 Input processing"
A[Text input] --> B[Document loaders]
B --> C[Text splitters]
C --> D[Documents]
end
%% Embedding & storage
subgraph "🔢 Embedding & storage"
D --> E[Embedding models]
E --> F[Vectors]
F --> G[(Vector stores)]
end
%% Retrieval
subgraph "🔍 Retrieval"
H[User Query] --> I[Embedding models]
I --> J[Query vector]
J --> K[Retrievers]
K --> G
G --> L[Relevant context]
end
%% Generation
subgraph "🤖 Generation"
M[Chat models] --> N[Tools]
N --> O[Tool results]
O --> M
L --> M
M --> P[AI response]
end
%% Orchestration
subgraph "🎯 Orchestration"
Q[Agents] --> M
Q --> N
Q --> K
Q --> R[Memory]
end
classDef trigger fill:#F6FFDB,stroke:#6E8900,stroke-width:2px,color:#2E3900
classDef process fill:#E5F4FF,stroke:#006DDD,stroke-width:2px,color:#030710
classDef output fill:#EBD0F0,stroke:#885270,stroke-width:2px,color:#441E33
classDef neutral fill:#F2FAFF,stroke:#40668D,stroke-width:2px,color:#2F4B68
class A,H trigger
class B,C,E,I,K,M,N,Q process
class D,F,J,L,O,P,R neutral
class G outputHow components connect
Each component layer builds on the previous ones:
- Input processing – Transform raw data into structured documents
- Embedding & storage – Convert text into searchable vector representations
- Retrieval – Find relevant information based on user queries
- Generation – Use AI models to create responses, optionally with tools
- Orchestration – Coordinate everything through agents and memory systems
Component categories
LangChain organizes components into these main categories:
| Category | Purpose | Key Components | Use Cases |
|---|---|---|---|
| Models (opens in a new tab) | AI reasoning and generation | Chat models, LLMs, Embedding models | Text generation, reasoning, semantic understanding |
| Tools (opens in a new tab) | External capabilities | APIs, databases, etc. | Web search, data access, computations |
| Agents (opens in a new tab) | Orchestration and reasoning | ReAct agents, tool calling agents | Nondeterministic workflows, decision making |
| Memory (opens in a new tab) | Context preservation | Message history, custom state | Conversations, stateful interactions |
| Retrievers (opens in a new tab) | Information access | Vector retrievers, web retrievers | RAG, knowledge base search |
| Document processing (opens in a new tab) | Data ingestion | Loaders, splitters, transformers | PDF processing, web scraping |
| Vector Stores (opens in a new tab) | Semantic search | Chroma, Pinecone, FAISS | Similarity search, embeddings storage |
Common patterns
RAG (Retrieval-Augmented generation)
graph LR
A[User question] --> B[Retriever]
B --> C[Relevant docs]
C --> D[Chat model]
A --> D
D --> E[Informed response]
classDef trigger fill:#F6FFDB,stroke:#6E8900,stroke-width:2px,color:#2E3900
classDef process fill:#E5F4FF,stroke:#006DDD,stroke-width:2px,color:#030710
classDef neutral fill:#F2FAFF,stroke:#40668D,stroke-width:2px,color:#2F4B68
class A trigger
class B,D process
class C,E neutralAgent with tools
graph LR
A[User request] --> B[Agent]
B --> C{Need tool?}
C -->|Yes| D[Call tool]
D --> E[Tool result]
E --> B
C -->|No| F[Final answer]
classDef trigger fill:#F6FFDB,stroke:#6E8900,stroke-width:2px,color:#2E3900
classDef process fill:#E5F4FF,stroke:#006DDD,stroke-width:2px,color:#030710
classDef decision fill:#FDF3FF,stroke:#7E65AE,stroke-width:2px,color:#504B5F
classDef neutral fill:#F2FAFF,stroke:#40668D,stroke-width:2px,color:#2F4B68
class A trigger
class B,D process
class C decision
class E,F neutralMulti-agent system
graph LR
A[Complex Task] --> B[Supervisor agent]
B --> C[Specialist agent 1]
B --> D[Specialist agent 2]
C --> E[Results]
D --> E
E --> B
B --> F[Coordinated response]
classDef trigger fill:#F6FFDB,stroke:#6E8900,stroke-width:2px,color:#2E3900
classDef process fill:#E5F4FF,stroke:#006DDD,stroke-width:2px,color:#030710
classDef neutral fill:#F2FAFF,stroke:#40668D,stroke-width:2px,color:#2F4B68
class A trigger
class B,C,D process
class E,F neutral