How harshil17704/langchain-learnings works
1. Repository role
- This is not a single application; it is a structured course repository of standalone Python examples.
- Each file demonstrates one LangChain/LangGraph concept, with the repo organized as a learning progression from primitives to full application patterns.
2. Core architectural boundary
- The repository centers on the boundary between:
- LLM-facing logic: prompts, models, chains, tools, agents, graphs
- application data: documents, chat history, vector stores, checkpoints, evaluation data
- Most examples are “read-and-run” patterns rather than a shared runtime service.
3. Foundation layer: setup and prompt design
- 00_setup establishes environment and conceptual grounding.
- 01_prompts covers prompt templates, chat prompts, few-shot prompting, output parsers, and structured outputs with Pydantic.
- This layer defines how input is shaped before any model call, and how model output is constrained after generation.
4. Model and embedding layer
- 02_models_embeddings introduces chat models, embeddings, model alternatives, streaming, and usage tracking.
- This is the main inference boundary: prompts go in, model text or embeddings come out.
- Streaming and usage tracking are treated as operational concerns tied to model invocation.
5. Document ingestion pipeline
- 03_document_processing handles loaders, text splitters, metadata enrichment, and web/PDF ingestion.
- The data flow here is: raw content → normalized documents → chunked segments → metadata-enriched units.
- This pipeline feeds retrieval systems and RAG workflows later in the repo.
6. Composable workflow layer
- 04_chains demonstrates LCEL-based composition: sequential, router, parallel, and branching chains.
- This is the “workflow orchestration without agents” layer, where multiple model calls or transformations are connected explicitly.
- It forms the structural bridge between simple prompt calls and more dynamic agent/graph systems.
7. Conversation state and memory
- 05_memory covers chat history, summary memory, and persistent memory.
- Memory is treated as application state that augments model context over time.
- This boundary matters because memory can be in-process, summarized, or persisted externally depending on the pattern.
8. Retrieval-Augmented Generation subsystem
- 06_retrieval_rag is a full RAG stack: vector stores, retrievers, retrieval pipelines, hybrid search, conversational RAG, query rewriting, multi-query retrieval, reranking, and context compression.
- Data flow: ingested documents → embeddings/vector index → retriever → context assembly → LLM answer generation.
- This is the main information-retrieval architecture in the repo and the clearest place to draw a “knowledge store + retrieval + generation” diagram.
9. Tool-use and agent subsystem
- 07_tools defines custom tools, tool calling, and tool error handling.
- 08_agents builds on that with agent executors, ReAct patterns, memory integration, and planning/reflection.
- The architectural shift here is from fixed workflows to model-directed control flow, where the LLM decides when to call tools and how to iterate.
10. LangGraph orchestration layer
- 09_langgraph introduces state graphs, conditional edges, human-in-the-loop approval, multi-agent supervision, checkpoints, interrupts, and resume.
- This is the strongest orchestration boundary in the repo: state becomes explicit, transitions are controlled, and execution can pause/restart.
- It extends the agent idea into a durable workflow engine with branching and persistence.
11. Production hardening layer
- 10_production_patterns covers callbacks/observability, guardrails/validation, retries/caching, evaluation, and prompt versioning.
- These examples show the operational controls around LLM systems: tracing, safety checks, reliability, quality measurement, and prompt lifecycle management.
- This layer sits orthogonally across prompts, chains, RAG, agents, and graphs.
12. Integrated solutions and reference architectures
- 11_projects contains an end-to-end support bot example that likely combines retrieval, tools, memory, and orchestration patterns.
- 14_capstone provides a full-stack RAG-agent blueprint, which acts as the repo’s highest-level system design reference.
- These sections are where the course’s building blocks converge into realistic application architecture.
13. Ecosystem and deployment
- 13_ecosystem adds LangSmith tracing and LangServe deployment.
- LangSmith is the observability/evaluation boundary for tracing runs and inspecting behavior.
- LangServe represents the deployment boundary where a chain or app can be exposed as a service.
14. Overall architectural shape
- The repo progresses from single-call LLM interactions to stateful workflows, then to retrieval systems, tool-using agents, and finally graph-orchestrated, production-aware applications.
- For a diagram, the most important flows are:
- prompt → model → parser
- documents → split/chunk → embed → retrieve → generate
- user input → memory/context/tool calls → agent decisions
- state graph → conditional transitions → checkpoints/human approval → resume
- application runs → tracing/evaluation/guardrails/retries/versioning
Main entry points: 03_rag_pipeline.py RAG Pipeline · 01_agent_executor_basics.py Agents · 01_stategraph_basics.py State Graph · 01_full_stack_rag_agent_blueprint.py Capstone
Components 23
Foundations
Prompting, model calls, and document prep basics.
- Setup · Environment setup and conceptual grounding for the repo.
00_setup/01_environment_and_concepts.py - Prompts · Prompt templates, chat prompts, few-shot examples, and structured output design.
01_prompts/01_prompt_templates.py - Parsers · Output parsers and structured output constraints for model responses.
01_prompts/03_output_parsers.py - Models · Chat models, embeddings, alternatives, streaming, and usage tracking.
02_models_embeddings/01_chat_models.py - Embeddings · Embedding generation used to support retrieval and similarity search.
02_models_embeddings/02_embeddings.py
Workflow
LCEL composition, memory, and classic chain patterns.
- LCEL · Core LCEL composition patterns for chaining transformations and model calls.
04_chains/01_lcel_basics.py - Chain Patterns · Sequential, router, parallel, and branching chain patterns.
04_chains/02_sequential_chain_lcel.py - Memory · Chat history, summary memory, and persistent memory patterns.
05_memory/01_chat_history_basics.py
Retrieval
Vector search and RAG pipelines over processed documents.
- Ingestion · Loaders, splitters, metadata enrichment, and web/PDF ingestion.
03_document_processing/01_document_loaders.py - Vector Store · Vector store basics as the storage layer for embedded documents.
06_retrieval_rag/01_vectorstores_basics.py - Retriever · Retriever abstractions that query the vector index for relevant context.
06_retrieval_rag/02_retrievers.py - RAG Pipeline · End-to-end retrieval-augmented generation flow from query to answer.
06_retrieval_rag/03_rag_pipeline.py - RAG Tuning · Hybrid search, conversational RAG, query rewriting, reranking, and context compression.
06_retrieval_rag/04_rag_improvements.py
Agents
Tool use and model-directed control flow.
Graph Orchestration
Stateful LangGraph execution, branching, and persistence.
- State Graph · LangGraph state graph basics and conditional transitions.
09_langgraph/01_stategraph_basics.py - Human Loop · Human-in-the-loop approval, interrupts, and resume behavior.
09_langgraph/03_human_in_the_loop.py - Persistence · Checkpoints, persistence, interrupts, and restartable execution.
09_langgraph/05_checkpoints_and_persistence.py
Ops
Production controls, tracing, deployment, and evaluation.
- Production · Callbacks, guardrails, retries, caching, evaluation, and prompt versioning.
10_production_patterns/01_callbacks_observability.py - Ecosystem · LangSmith tracing and LangServe deployment integration.
13_ecosystem/01_langsmith_tracing.py
Applications
Integrated examples and reference blueprints.
- Support Bot · End-to-end support bot that combines retrieval, memory, and orchestration.
11_projects/01_end_to_end_support_bot.py - Capstone · Full-stack RAG-agent blueprint tying together the repo's major patterns.
14_capstone/01_full_stack_rag_agent_blueprint.py
Connections 31
- Setup → Prompts: introduces · Conceptual setup leads into prompt shaping and output control.
- Prompts → Parsers: constrains output · Prompts are paired with parsers and structured output rules.
- Prompts → Models: calls · Prompted input is sent to chat models for inference.
- Models → Embeddings: produces · The model layer includes embeddings as the representation boundary.
- Ingestion → Embeddings: chunks for · Loaded and split documents become embedding-ready units.
- Embeddings → Vector Store: indexes · Embeddings are stored in a vector index for retrieval.
- Vector Store → Retriever: serves · The vector store is queried through retriever abstractions.
- Retriever → RAG Pipeline: feeds context · Retriever output becomes context for answer generation.
- Ingestion → RAG Pipeline: supplies docs · Ingested documents flow into the RAG pipeline.
- RAG Pipeline → RAG Tuning: extends to · The basic RAG pipeline is refined with better retrieval strategies.
- LCEL → Chain Patterns: composes · LCEL basics expand into explicit chain patterns.
- Chain Patterns → Memory: augments with · Workflow examples are combined with conversational state.
- Models → LCEL: drives · Model calls are the core execution unit inside LCEL flows.
- Tools → Agents: enables · Tools are orchestrated by agent execution loops.
- Agents → Planning: iterates · Agents are extended with planning, reflection, and memory.
- Agents → Memory: uses state · Agents can carry chat history and persistent context.
- Planning → State Graph: maps to · Planning and reflection can be expressed as graph state transitions.
- State Graph → Human Loop: branches to · Graph execution can pause for human approval.
- State Graph → Persistence: persists · State graphs support checkpoints and resumable execution.
- RAG Pipeline → Agents: toolifies · Retrieval workflows can be embedded in agentic control flow.
- RAG Pipeline → State Graph: orchestrated by · RAG can be wrapped in explicit graph state and routing.
- Production → Models: observes · Operational controls wrap model invocations.
- Production → RAG Pipeline: hardens · Guardrails and retries apply across RAG workflows.
- Ecosystem → Production: supports · Tracing and deployment sit alongside production patterns.
- Support Bot → RAG Pipeline: integrates · The support bot likely uses retrieval as a core capability.
- Support Bot → Agents: integrates · The support bot also incorporates tool-using behavior.
- Support Bot → Memory: retains context · Conversation state supports the application example.
- Capstone → RAG Tuning: combines · The capstone blueprint incorporates advanced retrieval patterns.
- Capstone → State Graph: orchestrates · The capstone reference architecture uses graph-based control flow.
- Capstone → Production: hardened by · The blueprint is framed with production concerns.
- Ecosystem → Capstone: deploys and traces · Platform integrations support the top-level reference architecture.