Skip to content

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LearnAgenticAI

CI Python TypeScript Next.js LangChain LangGraph LangSmith License: MIT

A production-grade monorepo portfolio of 10 progressive Agentic AI projects built on the LangChain / LangGraph / LangSmith / MCP stack. Designed as an industry-standard reference architecture covering single-agent ReAct loops, production RAG, cross-session memory, multi-agent supervisor hierarchies, human-in-the-loop (HITL) safety, Model Context Protocol (MCP) integrations, deep autonomous subagents, typed structured outputs, and automated evaluation harnesses.


πŸ—οΈ System Architecture

The monorepo is architected around modular FastAPI agent services, a reusable Next.js 15 chat shell, and a shared Python infrastructure package (common) for model routing, streaming telemetry, and evaluation gates.

                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚                 apps/chat-ui (Next.js 15)              β”‚
                      β”‚  β€’ Token-by-token SSE streaming                        β”‚
                      β”‚  β€’ Collapsible Tool Call Inspection Trees              β”‚
                      β”‚  β€’ Direct Deep Links to LangSmith Traces               β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                  β”‚ HTTP POST (SSE stream)
                                                  β–Ό
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚              FastAPI Agent Service (/agents/*)         β”‚
                      β”‚  β€’ /v1/chat/completions (OpenAI-compatible)            β”‚
                      β”‚  β€’ StateGraph Execution & Checkpointing                β”‚
                      β”‚  β€’ Interrupt Handling & Resumption Endpoints           β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚                           β”‚
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
                   β–Ό                                β–Ό           β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚    common.llm               β”‚   β”‚    common.ui_bridge       β”‚   β”‚    common.tracing             β”‚
    β”‚  β€’ Multi-provider routing   β”‚   β”‚  β€’ Typed SSE event codec  β”‚   β”‚  β€’ LangSmith telemetry setup  β”‚
    β”‚  β€’ OpenRouter / Ollama      β”‚   β”‚  β€’ token / tool / trace   β”‚   β”‚  β€’ Scoped project contexts    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚                                                                  β”‚
                   β–Ό                                                                  β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ LLMs (Claude, GPT-4o, Llama)β”‚                                   β”‚ LangSmith Observability Platformβ”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ The 10-Project Portfolio Matrix

Project Pattern Core Technologies Eval & Observability Status
P0: Foundation & Smoke Shared Infra Validation FastAPI, SSE Bridge, Next.js 15, LangSmith Unit + integration smoke tests βœ… Completed
P1: ReAct Research Agent Single-Agent Reasoning create_react_agent, Tavily Search, OpenRouter 30 multi-hop Q&A benchmark (94.7% recall) βœ… Completed
P2: Production RAG Retrieval & Reranking Semantic Chunking, Qdrant, Cohere Rerank Faithfulness & Context-Precision evals ⏳ Planned
P3: Conversational Memory Multi-Tier State Store LangGraph MemorySaver + PostgreSQL Store 20 multi-turn recall benchmarks ⏳ Planned
P4: Multi-Agent Supervisor Hierarchical Orchestration LangGraph Subgraphs, Command handoffs 15 collaborative research tasks ⏳ Planned
P5: HITL Approval Workflow Human-in-the-Loop Safety LangGraph interrupt(), Resumable Checkpoints 10 destructive mutation scenarios ⏳ Planned
P6: MCP Tool Server Protocol-Driven Tooling Python mcp SDK, langchain-mcp-adapters 12 cross-tool workflow evaluations ⏳ Planned
P7: Deep Research Agent Long-Horizon Autonomy Parallel Send API, Context Offloading LLM-as-a-Judge report rubrics ⏳ Planned
P8: Structured-Output Agent Typed Schema Extraction Pydantic v2, Retry Prompt Injection 30 malformed input edge cases ⏳ Planned
P9: Eval & Observability CI/CD Quality Gates LangSmith evaluate(), Trajectory Matching Meta-evals against human labels ⏳ Planned
P10: Production Capstone Full-Stack Deployment Docker, FastAPI, Rate Limiting, Sentry Locust load tests + online evals ⏳ Planned

πŸ“‚ Repository Structure

LearnAgenticAI/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml                 # Python (uv, ruff, mypy, pytest) + TypeScript (vitest, typecheck, lint)
β”‚       └── openwiki-update.yml    # Automated documentation synchronization
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ P0-smoke/                  # Smoke validation agent (FastAPI + LangChain)
β”‚   β”‚   β”œβ”€β”€ src/P0_smoke/          # Server and agent graph implementation
β”‚   β”‚   β”œβ”€β”€ tests/                 # Unit and integration test suites
β”‚   β”‚   └── pyproject.toml         # Agent package definition
β”‚   β”œβ”€β”€ P1-react-agent/            # Autonomous ReAct research agent (Tavily + web reading)
β”‚   β”‚   β”œβ”€β”€ src/P1_react_agent/    # ReAct graph, prompts, and SSE bridge
β”‚   β”‚   β”œβ”€β”€ data/                  # 30-question multi-hop eval dataset
β”‚   β”‚   β”œβ”€β”€ tests/                 # Unit, integration, and eval test suites
β”‚   β”‚   β”œβ”€β”€ eval.py                # Offline evaluation CLI benchmark
β”‚   β”‚   └── pyproject.toml         # Agent package definition
β”‚   └── ...                        # P2 through P10 agent packages
β”œβ”€β”€ apps/
β”‚   └── chat-ui/                   # Next.js 15 chat shell with Tailwind CSS & Lucide icons
β”‚       β”œβ”€β”€ app/                   # App Router pages and health routes
β”‚       β”œβ”€β”€ components/            # ChatWindow, ToolCallTree, TraceLink, MessageBubble
β”‚       β”œβ”€β”€ lib/                   # API streaming client and TypeScript types
β”‚       └── tests/                 # Vitest test suite
β”œβ”€β”€ common/                        # Shared Python workspace package
β”‚   β”œβ”€β”€ src/common/
β”‚   β”‚   β”œβ”€β”€ config.py              # Pydantic BaseSettings environment configuration
β”‚   β”‚   β”œβ”€β”€ llm.py                 # Multi-model factory (OpenRouter, Ollama, OpenAI)
β”‚   β”‚   β”œβ”€β”€ tracing.py             # LangSmith context manager and telemetry setup
β”‚   β”‚   β”œβ”€β”€ ui_bridge.py           # Typed SSE event formatters (token, tool, trace)
β”‚   β”‚   └── tools/                 # Shared search, filesystem, and data tools
β”‚   └── tests/                     # Unit tests for shared infrastructure
β”œβ”€β”€ docker/
β”‚   β”œβ”€β”€ docker-compose.yml         # Local Postgres (pgvector) and Qdrant services
β”‚   └── .env.example               # Docker environment templates
β”œβ”€β”€ docs/                          # Architecture specifications and implementation plans
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ test.sh                    # Monorepo test runner (Python + TypeScript)
β”‚   β”œβ”€β”€ dev-up.sh                  # Bootstrap local Docker infrastructure
β”‚   └── dev-down.sh                # Tear down local Docker services
└── pyproject.toml                 # uv monorepo workspace configuration

πŸ› οΈ Shared Infrastructure Core Modules

1. Unified Multi-Model Routing (common.llm)

Route dynamically across LLM providers based on project load and reasoning requirements:

from common.llm import get_model

# High-reasoning agent model
model = get_model(project="P1-react-agent", task="reasoning")

# Cost-optimized evaluator model
eval_model = get_model(project="P2-rag", task="eval")

2. Scoped LangSmith Telemetry (common.tracing)

Isolate project traces cleanly in LangSmith with automatic environment scoping:

from common.tracing import setup

# Automatically configures LANGSMITH_PROJECT="LearnAgenticAI/P1-react-agent"
with setup("P1-react-agent"):
    response = agent.invoke({"messages": [...]})

3. Typed SSE Streaming Protocol (common.ui_bridge)

Format events predictably for consumer frontends:

from common.ui_bridge import to_sse

# Stream individual tokens
yield to_sse("token", {"delta": "Hello"})

# Stream tool start and completion telemetry
yield to_sse("tool_start", {"id": "call_1", "tool": "tavily_search", "args": {"query": "LangGraph"}})
yield to_sse("tool_end", {"id": "call_1", "result": "..."})

# Attach LangSmith trace URL
yield to_sse("trace_meta", {"run_id": "8f2a...", "project": "LearnAgenticAI/P1-react-agent"})

⚑ Quickstart & Local Setup

Prerequisites

1. Environment Setup

# Clone the repository
git clone git@github.com:atandra2000/LearnAgenticAI.git
cd LearnAgenticAI

# Copy environment configuration files
cp .env.example .env
cp docker/.env.example docker/.env
cp apps/chat-ui/.env.example apps/chat-ui/.env.local

# Edit .env and supply your API keys:
# OPENROUTER_API_KEY=...
# LANGSMITH_API_KEY=...

2. Install Dependencies & Start Services

# Sync Python workspace packages
uv sync --all-packages --all-extras

# Install frontend dependencies
pnpm --dir apps/chat-ui install

# Start local backing services (PostgreSQL + Qdrant)
bash scripts/dev-up.sh

3. Run the Agent & Frontend

In terminal 1 (Backend Agent):

cd agents/P0-smoke
uv run uvicorn P0_smoke.server:app --reload --port 8000

In terminal 2 (Next.js Chat UI):

pnpm --dir apps/chat-ui dev

Open http://localhost:3000 to interact with the agent.


πŸ§ͺ Testing & Verification

The repository enforces strict typing, linting, and automated testing across both Python and TypeScript workspaces.

# Run the complete test suite (Python pytest + TypeScript vitest)
bash scripts/test.sh

# Python Linting & Formatting
uv run ruff check .
uv run ruff format --check .

# Python Static Type Analysis
uv run mypy common/src agents/P0-smoke/src

# TypeScript Typecheck & Linting
pnpm --dir apps/chat-ui typecheck
pnpm --dir apps/chat-ui lint

πŸ“„ License

Distributed under the MIT License. See LICENSE for more details.

About

Production-grade portfolio of 10 progressive Agentic AI projects built with LangChain, LangGraph, LangSmith, and MCP.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages