How dev-arctik/langgraph_learning works
Project type and purpose
• This is an open-source learning repository (“LangGraph Learning”) composed of standalone Python scripts demonstrating incremental LangChain graph patterns and techniques (simple graphs, tool graphs, agent graphs, memory patterns, checkpointing, parallelism, etc.).
• Each numbered file (1-SimpleGraph.py through 13-MemoryBetweenThreads.py) is a self-contained example; there’s a utility module for image generation, a config directory for API keys, and GraphImages for outputs.
File structure
• Top-level example scripts: 1-*.py … 13-*.py
• config/secret_keys.py holds API key placeholders loaded at runtime via a .env file
• utils/graph_img_generation.py encapsulates common logic to render or save graph visuals
• GraphImages/ stores generated graph images
• requirements.txt lists dependencies (LangChain, OpenAI, pymongo or motor, etc.)
Main architectural components
a. Example-Graph Runner Layer (“Scripts”)
• Each numbered file imports config, utils, LangChain constructs, and external services
b. Configuration Layer
• secret_keys.py (reads .env via python-dotenv)
c. Graph Utilities Layer
• graph_img_generation.py
d. External Services
• OpenAI API (via LangChain LLM wrappers)
• LangSmith tracing endpoint
• Tavily API
• MongoDB (synchronous or async) for checkpointing
e. Output/Storage
• GraphImages directory for PNG/SVG outputs
• MongoDB collections for state persistence
Relationships and interactions
• Each Script → loads API keys from Config
• Script → initializes a LangChain Graph or Agent
• Script ↔ External LLM services (OpenAI, optional Tavily)
• Script → (optional) LangSmith tracing endpoint for experiment telemetry
• Some scripts → MongoDBCheckpointer (sync or async) for saving graph runs
• Script → utils.graph_img_generation to render graph structure → writes to GraphImages/
Architectural patterns and principles
• Modular example approach: each file is an independent use case
• Separation of concerns: config isolated from code; rendering utility factored out
• Optional persistence layer via checkpointers abstracts database interaction
• Concurrency patterns demonstrated (thread-based memory, async checkpointing)
• Extensibility: new graph examples can be added by following the numbered naming convention
Technologies, frameworks, and libraries
• Python 3
• LangChain and its Graph API
• OpenAI Python SDK / Tavily
• python-dotenv for configuration
• pymongo / motor for MongoDB
• graphviz or networkx in graph_img_generation (depending on implementation)
• Clear, human-readable labels for each component (“1-SimpleGraph.py,” “config/secret_keys.py,” “MongoDB”)