Skip to content

Latest commit

ย 

History

78 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

๐Ÿš€ LegendStack Agentic FastAPI Template

Ship production-ready AI agents in hours, not months.

LegendStack Agentic Template

Tests Python License Docs DeepWiki Discord

๐Ÿ“š Documentation ยท ๐ŸŽ“ Tutorials ยท ๐Ÿ”ง Guides ยท ๐Ÿ’ฌ Discord


โšก Time to First Agent

git clone https://github.com/LegendStack/agentic-fastapi-template
cd agentic-fastapi-template && docker compose up

That's it. Your agent is running at http://localhost:8000/docs with:

  • ๐Ÿค– Demo Agent showcasing all features (no API keys needed)
  • ๐Ÿ“š RAG pipeline with vector search
  • ๐Ÿ›ก๏ธ Safety guardrails (PII masking, moderation)
  • ๐Ÿ’ฌ Real-time streaming (SSE/WebSocket)

Tip

New to LegendStack? Start with the Interactive Tutorial โ€” it walks you through every feature in 90 minutes.


๐ŸŽฏ Why LegendStack?

Building AI Agents From Scratch With LegendStack
Set up FastAPI, auth, database, caching... โœ… Batteries included
Build RAG pipeline from scratch โœ… Production-ready RAG with reranking
Figure out LangGraph patterns โœ… 11 modular node examples
Add safety guardrails โœ… PII masking, moderation built-in
Implement caching, rate limiting โœ… Semantic cache, tiered limits
Debug memory, threading issues โœ… Entity-aware cross-thread memory
Build monitoring, cost tracking โœ… OpenTelemetry + cost tracking
Weeks/Months Hours

๐Ÿ—๏ธ What's Included

๐Ÿ”ง Core Platform

  • โšก FastAPI + SQLAlchemy 2.0 (fully async)
  • ๐Ÿ” JWT Auth + Microsoft Entra ID (Azure AD)
  • ๐Ÿ‘ฎ Tiered Rate Limiting (Free/Standard/Premium)
  • ๐ŸงŠ Redis Caching + Background Jobs (ARQ)
  • ๐Ÿณ Docker Compose (dev/staging/production)

๐Ÿค– Agentic AI Framework

  • ๐Ÿง  LangGraph Orchestration with state management
  • ๐Ÿ“š RAG with Redis, Azure AI Search, or pgvector
  • ๐Ÿ”— Graph-RAG with Neo4j knowledge graphs
  • ๐Ÿ›ก๏ธ Safety Guardrails (PII, moderation)
  • โšก Semantic Caching (reduce LLM costs 70%+)

๐Ÿ”Œ Enterprise Integrations

  • ๐Ÿ“ Jira, Confluence, SharePoint, OneDrive
  • ๐Ÿ” Azure OpenAI, Cohere, Cross-Encoders
  • ๐Ÿ“Š OpenTelemetry (Datadog, Honeycomb)
  • ๐Ÿ” Azure Key Vault, Managed Identity
  • ๐Ÿ›ก๏ธ HashiCorp Vault (AppRole Auth)

๐ŸŽ“ Developer Experience

  • ๐Ÿ–ฅ๏ธ LegendStack Studio (Streamlit dashboard)
  • ๐Ÿ› ๏ธ CLI for scaffolding agents/connectors
  • ๐Ÿ““ Jupyter Tutorial (8 chapters)
  • ๐Ÿ“‹ Production Checklist (28 items)

๐Ÿ“š Learning Resources

Resource Format Time Best For
Quick Start Docs 5 min Get running fast
Jupyter Tutorial Notebook 90 min Hands-on learning
Streamlit Walkthrough Web App 30 min Visual learners
Integration Guide Docs 15 min Connect real services
Customization Cookbook Docs โ€” Add your logic
Production Checklist Checklist โ€” Pre-deploy review

๐Ÿš€ Quick Start Examples

๐Ÿค– Chat with the Demo Agent
from app.agents.demo import LegendDemoAgent

agent = LegendDemoAgent()  # Uses mocks (no API keys needed)
result = await agent.chat("What is LegendStack?")

print(result["response"])
print(result["features_used"])  # Shows which features were invoked
โ˜๏ธ Connect Azure OpenAI
from app.core.integration_config import configure_integrations, get_azure_openai_client

configure_integrations()  # Auto-configures from .env
client = get_azure_openai_client()
response = await client.chat([{"role": "user", "content": "Hello!"}], deployment="gpt-4o")
๐Ÿ” RAG with Reranking
from app.agents import RerankingService, CrossEncoderReranker

docs = await vector_store.search("How to deploy?", k=20)
reranker = RerankingService(CrossEncoderReranker())
top_docs = await reranker.rerank("How to deploy?", docs, top_k=5)
๐Ÿ›ก๏ธ Resilient LLM Calls
from app.agents import ResilientClient

client = ResilientClient(name="openai")  # Retry + circuit breaker
result = await client.execute(call_llm, prompt)  # Auto-retries on failure
๐Ÿ› ๏ธ CLI: Generate New Agent
uv run python src/app/cli/main.py create-agent CustomerSupport
uv run python src/app/cli/main.py create-connector Slack
๐Ÿ–ฅ๏ธ Launch Studio Dashboard
streamlit run studio/main.py

โฑ๏ธ Time to Production

Milestone Time
Clone & run with mocks 5 min
Connect real Azure OpenAI 30 min
Customize for your use case 2-4 hours
Production-ready 1-2 days

๐Ÿƒ Setup Options

Interactive setup:

./setup.py  # Choose: local / staging / production
Environment Config Best For
local Uvicorn + auto-reload Development
staging Gunicorn + workers Load testing
production NGINX + Gunicorn Deployment

Then:

docker compose up

๐Ÿ“– Full setup guide: Getting Started


๐Ÿ—บ๏ธ Project Structure

src/app/
โ”œโ”€โ”€ agents/           # ๐Ÿค– Agentic AI framework
โ”‚   โ”œโ”€โ”€ demo/         #    Demo agent with all features
โ”‚   โ”œโ”€โ”€ nodes/        #    Reusable LangGraph nodes
โ”‚   โ”œโ”€โ”€ connectors/   #    Enterprise integrations
โ”‚   โ””โ”€โ”€ guardrails/   #    Safety & moderation
โ”œโ”€โ”€ api/v1/           # ๐Ÿ”Œ REST endpoints
โ”œโ”€โ”€ core/             # โš™๏ธ Config, DB, auth
โ””โ”€โ”€ cli/              # ๐Ÿ› ๏ธ Developer tools

docs/
โ”œโ”€โ”€ getting-started/  # ๐Ÿ“š Quick start
โ”œโ”€โ”€ tutorials/        # ๐ŸŽ“ Interactive learning
โ”œโ”€โ”€ guides/           # ๐Ÿ”ง Integration & cookbook
โ””โ”€โ”€ user-guide/       # ๐Ÿ“– Detailed reference

notebooks/
โ””โ”€โ”€ tutorial.ipynb    # ๐Ÿ““ 8-chapter Jupyter tutorial

studio/
โ””โ”€โ”€ tutorial_app.py   # ๐Ÿ–ฅ๏ธ Streamlit walkthrough

๐Ÿงช Testing

# Run all tests (161 tests)
uv run pytest tests/ -v

# Run specific test file
uv run pytest tests/test_demo_agent.py -v

๐Ÿ” HashiCorp Vault Configuration

To enable Vault integration (AppRole Auth):

VAULT_ENABLED=true
VAULT_URL=http://localhost:8200
VAULT_ROLE_ID=<your-role-id>
VAULT_SECRET_ID=<your-secret-id>
VAULT_SECRET_PATH=secret/data/my-app

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.


๐Ÿ“œ License

MIT โ€” use it for anything.


Built with โค๏ธ by the LegendStack team

GitHub Stars

About

Enterprise-ready AI agent template. FastAPI + LangGraph + RAG. Ship production agents in hours.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages