How bhancockio/langchain-crash-course works
Project type and purpose
• This is not a deployed product but a hands-on code-example repository for the “LangChain Crash Course.”
• Purpose: teach core LangChain concepts via runnable Python scripts covering Chat Models, Prompt Templates, Chains, RAG, and Agents & Tools.
File structure
• Top-level files
• .env.example / .gitignore / pyproject.toml – environment and dependency config
• README.md – project overview and usage
• Five main folders (modules) numbered 1–5:
1) 1_chat_models
2) 2_prompt_templates
3) 3_chains
4) 4_rag (incl. local books and utils)
5) 5_agents_and_tools (with deep-dive subfolders)
• Pattern: each folder contains sequential Python scripts illustrating incremental features
README for additional insights
• Outlines six course sections matching the five folders (+ setup)
• Mentions technologies: Python 3.10/3.11, Poetry, LangChain, Firestore, vector stores, web scraping
Main components
a. Configuration & Environment
• .env (API keys), Poetry virtualenv, dependency resolution (pyproject.toml)
b. Core LangChain Modules (as code packages)
1) Chat Models – interfaces to LLM providers (OpenAI, Claude, Gemini)
2) Prompt Templates – reusable prompt patterns
3) Chains – small workflows combining prompts and models
4) RAG – document ingestion, embedding, vector store retrieval, conversational interface
– Local “books” folder as document corpus
– embedding utility for cost calculation
5) Agents & Tools – agent orchestrator + custom tools (constructor, decorator, base)
c. External Services & Data Stores
• LLM Providers via API
• Vector store (e.g., FAISS, Pinecone)
• Firestore for message history
• Web-scraping service (e.g., Firecrawl)
d. User / Developer interaction
• CLI / script execution via Python
• Input: developer-provided prompt or code parameters
• Output: printed responses, saved records in Firestore
Relationships and interactions
• Configuration initializes environment → imports LangChain
• Chat Models & Prompt Templates feed into Chains
• Chains can call Chat Models, use Prompt Templates, and direct text to RAG or Agents
• RAG module: Documents → Text Splitting → Embeddings → Vector Store → Retriever → LLM via Chain
• Agents: orchestrate Chains + Tools for decision-making, dynamic tool invocation
• Tools can call external APIs or internal utilities (e.g., embedding cost calculator)
Architectural patterns and design principles
• Modular separation by concept (single responsibility per folder)
• Pipeline pattern (Chains) for data flow
• Adapter pattern for external LLM providers (Chat Models)
• Strategy pattern for different prompt templates and tool implementations
• Layered architecture: Config → Core Modules → External Services
Technology and framework call-outs
• Python + Poetry
• LangChain SDK
• Firestore integration
• Vector store of choice (FAISS/Pinecone)
• Web-scraping via Firecrawl
• Clear labels on every component (e.g., “3_chains” as “Chains Module”)
• Example data flow: “User prompt → Prompt Template → Chat Model → Chain → Output”
• Call out optional branches: “Agent invokes Tool A or Tool B based on condition”
Detail
• Don’t just lump everything into “Backend.” Break into the five course modules.
• Both high-level flow (e.g., User → Agent → LLM) and internal steps for complex parts (e.g., RAG ingestion).
• External dependencies and where API keys from .env are used.
• Deep-dive submodules under Agents & Tools to show extensibility points.