https://github.com/webup/langgraph-up-monorepo
A batteries-included monorepo framework for building sophisticated LangGraph applications
https://github.com/webup/langgraph-up-monorepo
langchain langchain-python langgraph langgraph-python langgraph-supervisor-py langsmith
Last synced: 8 months ago
JSON representation
A batteries-included monorepo framework for building sophisticated LangGraph applications
- Host: GitHub
- URL: https://github.com/webup/langgraph-up-monorepo
- Owner: webup
- Created: 2025-09-18T09:29:17.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-08T05:14:45.000Z (8 months ago)
- Last Synced: 2025-10-08T05:39:46.552Z (8 months ago)
- Topics: langchain, langchain-python, langgraph, langgraph-python, langgraph-supervisor-py, langsmith
- Language: Python
- Homepage:
- Size: 367 KB
- Stars: 12
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ LangGraph-UP Monorepo
**LangGraph-UP Monorepo** showcases how to build production-ready LangGraph agents using the latest **LangChain & LangGraph** V1 ecosystem, organized in a clean monorepo structure with shared libraries and multiple agent applications.
[](https://github.com/webup/langgraph-up-monorepo/releases/tag/v0.2.0)
[](https://github.com/langchain-ai/langchain)
[](https://github.com/langchain-ai/langgraph)
[](https://opensource.org/licenses/MIT)
[](https://test.pypi.org/project/langgraph-up-devkits/)
[](https://twitter.com/zhanghaili0610)
## โจ Key Features
- ๐ **Universal Model Loading** - OpenRouter, Qwen, QwQ, SiliconFlow with automatic registration
- ๐ค **Multi-Agent Orchestration** - Supervisor & deep research patterns with specialized sub-agents
- ๐ **Custom Middleware** - Model switching, file masking, summarization, and state management
- ๐งช **Developer Experience** - Hot reload, comprehensive testing, strict linting, PyPI publishing
- ๐ **Deployment Ready** - LangGraph Cloud configurations included
- ๐ **Global Ready** - Region-based provider configuration (PRC/International)
## ๐ Quick Start
### Installation
```bash
# Install UV package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/webup/langgraph-up-monorepo.git
cd langgraph-up-monorepo
uv sync --dev
```
### 30-Second Demo
```python
from langgraph_up_devkits import load_chat_model
# Zero-setup model loading across providers
model = load_chat_model("openrouter:anthropic/claude-sonnet-4")
# model = load_chat_model("qwen:qwen-flash")
# model = load_chat_model("siliconflow:Qwen/Qwen3-8B")
# Start building your agent
from sample_agent import make_graph
app = make_graph()
result = await app.ainvoke({"messages": [{"role": "user", "content": "What's 25 * 4?"}]})
```
### Sample Agents
This monorepo includes two complete agent examples demonstrating different patterns:
#### ๐ค sample-agent: Supervisor Pattern
Multi-agent system with a coordinator that delegates to specialized sub-agents.
```bash
make dev sample-agent
```
**Features:**
- Supervisor-based coordination
- Math expert (add, multiply operations)
- Research expert (web search capabilities)
- Cross-agent handoffs
#### ๐ฌ sample-deep-agent: Deep Research Pattern
Advanced research workflow with virtual file system and structured planning.
```bash
make dev sample-deep-agent
```
**Features:**
- Deep web search with content extraction
- Virtual file system for document management
- Think tool for strategic TODO planning
- Research & critique sub-agents
- FileSystemMaskMiddleware to optimize token usage
## ๐ Architecture
### Monorepo Structure
```
langgraph-up-monorepo/
โโโ libs/
โ โโโ shared/ # Shared utilities
โ โโโ common/ # Common helper functions
โ โโโ langgraph-up-devkits/ # ๐ฏ Core framework (published to PyPI)
โ โโโ utils/providers.py # โ Multi-provider model loading
โ โโโ middleware/ # โ Custom middleware (model, file, summary)
โ โโโ tools/ # โ Web search, deep search, MCP integration
โ โโโ context/ # โ Context schemas & aware prompts
โโโ apps/
โ โโโ sample-agent/ # ๐ค Supervisor pattern (math + research agents)
โ โ โโโ src/sample_agent/
โ โ โ โโโ graph.py # โ Main supervisor graph
โ โ โ โโโ subagents/ # โ Math & research experts
โ โ โ โโโ tools/ # โ Agent-specific tools
โ โ โโโ langgraph.json # โ Deployment config
โ โโโ sample-deep-agent/ # ๐ฌ Deep research pattern (VFS + think tool)
โ โโโ src/sample_deep_agent/
โ โ โโโ graph.py # โ Deep agent with research workflow
โ โ โโโ subagents.py # โ Research & critique experts
โ โ โโโ prompts.py # โ Structured TODO planning prompts
โ โโโ langgraph.json # โ Deployment config
โโโ pyproject.toml # Root dependencies
โโโ Makefile # Development commands
โโโ PUBLISHING.md # PyPI publishing guide
โโโ .github/workflows/ # CI/CD pipeline
```
### Core Components
#### ๐ Universal Model Loading
Automatic provider registration with fallback support:
```python
from langgraph_up_devkits import load_chat_model
# Anthropic via OpenRouter (preferred)
model = load_chat_model("openrouter:anthropic/claude-sonnet-4")
# Qwen models (PRC/International regions)
model = load_chat_model("qwen:qwen-flash")
# SiliconFlow models
model = load_chat_model("siliconflow:Qwen/Qwen3-8B")
# With configuration
model = load_chat_model(
"openrouter:anthropic/claude-sonnet-4",
temperature=0.7,
max_tokens=1000
)
```
#### ๐ค Multi-Agent Patterns
```python
from sample_agent.subagents import math, research
from sample_agent.tools import create_handoff_tool
# Create specialized agents
math_agent = math.make_graph()
research_agent = research.make_graph()
# Enable handoffs between agents
math_to_research = create_handoff_tool("research_expert")
research_to_math = create_handoff_tool("math_expert")
```
#### ๐ง Custom Middleware (LangChain v1)
Built-in middleware for dynamic model switching, state management, and behavior modification:
```python
from langchain.agents import create_agent
from langgraph_up_devkits import (
ModelProviderMiddleware,
FileSystemMaskMiddleware,
load_chat_model
)
# Model provider middleware for automatic switching
model_middleware = ModelProviderMiddleware()
# File system middleware to mask large file content from LLM context
fs_middleware = FileSystemMaskMiddleware()
agent = create_agent(
model=load_chat_model("openrouter:gpt-4o"), # Fallback model
tools=[web_search, deep_web_search],
middleware=[model_middleware, fs_middleware]
)
# Context specifies different model - middleware switches automatically
context = {"model": "siliconflow:Qwen/Qwen3-8B"}
result = await agent.ainvoke(messages, context=context)
```
**Available Middleware:**
- `ModelProviderMiddleware` - Dynamic model switching based on context
- `FileSystemMaskMiddleware` - Masks virtual file systems from LLM to save tokens
- `SummarizationMiddleware` - Automatic message summarization for long conversations
For detailed documentation on additional features like middleware, tools, and utilities, see:
- **Framework Documentation**: [`libs/langgraph-up-devkits/README.md`](libs/langgraph-up-devkits/README.md)
- **Agent Examples**: [`apps/sample-agent/README.md`](apps/sample-agent/README.md)
## ๐ Development
### Commands
See the [Makefile](Makefile) for complete command reference.
```bash
# Testing
make test # Run all tests
make test_libs # Test libraries only
make test_apps # Test applications only
make unit sample-agent # Test specific app
# Code Quality
make lint # Run linters (ruff + mypy)
make format # Format code
# Development
make dev sample-agent # Start dev server with browser
make dev sample-agent -- --no-browser # Start without browser
make dev sample-agent -- --host 0.0.0.0 --port 3000 # Custom host/port
# Publishing (langgraph-up-devkits)
make build_devkits # Build distribution packages
make check_devkits # Validate package
make release_test_devkits # Build and publish to Test PyPI
make release_devkits # Build and publish to PyPI
```
See [PUBLISHING.md](PUBLISHING.md) for detailed publishing guide.
### Project Structure Guidelines
- **`libs/`** - Reusable packages shared across agents
- **`apps/`** - Individual agent implementations
- **Shared dependencies** - Managed in root `pyproject.toml`
- **Agent-specific deps** - In app-level `pyproject.toml`
### Creating New Agents
```bash
# Copy sample agent structure
cp -r apps/sample-agent apps/my-agent
# Update configuration
# Edit apps/my-agent/langgraph.json
# Edit apps/my-agent/pyproject.toml
# Implement apps/my-agent/src/my_agent/graph.py
```
## ๐งช Testing
```bash
# Run all tests (126+ tests in libs, 10+ in apps)
make test
# Run tests for specific components
make test_libs # Test libraries only
make test_apps # Test applications only
make unit sample-agent # Test specific app
```
## ๐ง Troubleshooting
Common issues and detailed troubleshooting guides are available in:
- **Setup Issues**: [`libs/langgraph-up-devkits/README.md#troubleshooting`](libs/langgraph-up-devkits/README.md#troubleshooting)
- **Agent Issues**: [`apps/sample-agent/README.md#troubleshooting`](apps/sample-agent/README.md#troubleshooting)
## ๐ค Contributing
### Development Setup
```bash
git clone https://github.com/your-org/langgraph-up-monorepo.git
cd langgraph-up-monorepo
uv sync
make lint # Ensure code quality
make test # Run test suite
```
### Code Standards
- **Type Safety** - Strict mypy checking enabled
- **Code Style** - Ruff formatting and linting
- **Testing** - High test coverage required
- **Documentation** - Comprehensive docstrings
### Submission Process
1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Ensure tests pass (`make test`)
4. Ensure linting passes (`make lint`)
5. Commit changes (`git commit -m 'Add amazing feature'`)
6. Push to branch (`git push origin feature/amazing-feature`)
7. Open Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
### Core Frameworks
- **[LangGraph](https://github.com/langchain-ai/langgraph)** - Agent orchestration framework
- **[LangChain](https://github.com/langchain-ai/langchain)** - Foundation for agent components
### Development Tools
- **[UV](https://github.com/astral-sh/uv)** - Fast Python package management
- **[langchain-dev-utils](https://github.com/TBice123123/langchain-dev-utils)** - Development utilities for LangChain
### Model Providers
- **[OpenRouter](https://openrouter.ai/)** - Multi-provider model access
---
**Built with โค๏ธ for the LangGraph community**
Ready to build production-grade agents? [Get started โ](#-quick-start)