Skip to content

SURYAS1306/Agentic-AI-Workflow-Engine-using-LangGraph

Repository files navigation

Agentic AI Workflow Engine

A production-ready multi-agent AI system that automates complex workflows using a Planner–Executor architecture. Built with LangGraph, LangChain, FastAPI, FAISS, PostgreSQL, Redis, Docker, and AWS.

Architecture

User
 ↓
FastAPI
 ↓
LangGraph Workflow Engine
 ↓
Planner Agent
 ↓
Executor Agents (Research → Analysis → Writer)
 ↓
Tools / APIs / Knowledge Base (FAISS RAG)
 ↓
Response

Features

  • Multi-Agent Orchestration — Planner, Research, Analysis, Writer, Tool, and Memory agents
  • LangGraph Workflow — Dynamic routing, conditional branching, retry, failure recovery
  • RAG Pipeline — PDF, TXT, DOCX ingestion with FAISS vector search
  • Contextual Memory — Short-term (Redis) and long-term (PostgreSQL) memory
  • Tool Framework — Web search, calculator, weather, news, database, email, REST API
  • Security — JWT auth, RBAC (ADMIN/USER), rate limiting, input validation
  • Observability — LangSmith tracing, token/cost tracking, execution history
  • Human-in-the-Loop — Workflow approval gates
  • Streaming — SSE-based workflow streaming
  • Workflow Templates — Pre-built templates for common tasks
  • Scheduled Workflows — Cron-based job scheduling
  • MCP Integration — Model Context Protocol server bridge
  • Docker & AWS — Containerized deployment on EC2 + Lambda background jobs
  • CI/CD — GitHub Actions pipeline with lint, test, build, deploy

Quick Start

Prerequisites

  • Python 3.12+
  • Docker & Docker Compose
  • OpenAI API key (or Azure OpenAI)

Local Development

# Clone and setup
cd agentic-ai-workflow-engine
cp .env.example .env
# Edit .env with your OPENAI_API_KEY

# Install dependencies
pip install -r requirements.txt

# Start with Docker Compose (recommended)
docker compose up -d --build

# Or run locally (requires PostgreSQL + Redis)
make dev

API available at: http://localhost:8000
Swagger docs: http://localhost:8000/docs

Example API Usage

# Health check
curl http://localhost:8000/api/v1/health

# Register user
curl -X POST http://localhost:8000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"name": "John", "email": "john@example.com", "password": "securepass123"}'

# Login
curl -X POST http://localhost:8000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "john@example.com", "password": "securepass123"}'

# Execute query
curl -X POST http://localhost:8000/api/v1/query \
  -H "Content-Type: application/json" \
  -d '{"query": "Compare AWS and Azure pricing and generate a report"}'

# Upload document for RAG
curl -X POST http://localhost:8000/api/v1/documents/upload \
  -H "Authorization: Bearer <token>" \
  -F "file=@document.pdf"

# Get workflow status
curl http://localhost:8000/api/v1/workflow/<workflow_id>

Project Structure

agentic-ai-workflow-engine/
├── app/
│   ├── agents/           # Planner & Executor agents
│   ├── api/              # FastAPI routes
│   ├── db/               # SQLAlchemy models & database
│   ├── memory/           # Redis + PostgreSQL memory
│   ├── mcp/              # MCP integration
│   ├── observability/    # Tracing & cost tracking
│   ├── rag/              # Document processing & FAISS
│   ├── schemas/          # Pydantic models
│   ├── security/         # Auth, RBAC, rate limiting
│   ├── services/         # Workflow, LLM, scheduler
│   ├── tools/            # Agent tools framework
│   ├── workflow/         # LangGraph engine
│   ├── config.py
│   └── main.py
├── aws/
│   ├── ec2/              # EC2 deployment scripts
│   └── lambda/           # Background job handler
├── tests/                # 30+ pytest test cases
├── .github/workflows/    # CI/CD pipeline
├── docker-compose.yml
├── Dockerfile
└── requirements.txt

API Endpoints

Method Endpoint Description
GET /api/v1/health Health check
POST /api/v1/auth/register Register user
POST /api/v1/auth/login Login (JWT)
POST /api/v1/query Execute query workflow
POST /api/v1/workflow Create workflow
GET /api/v1/workflow/{id} Get workflow status
POST /api/v1/workflow/{id}/execute Execute workflow
POST /api/v1/workflow/{id}/approve Human approval
POST /api/v1/workflow/stream Stream workflow (SSE)
POST /api/v1/documents/upload Upload document
POST /api/v1/documents/search Semantic search
GET /api/v1/templates List workflow templates

Workflow State

{
  "user_query": "",
  "plan": [],
  "research_data": "",
  "analysis": "",
  "final_response": "",
  "memory": []
}

Testing

# Run all tests (30+ cases)
make test

# Run with coverage
pytest tests/ -v --cov=app --cov-report=html

# Lint
make lint

AWS Deployment

EC2

# On EC2 instance
bash aws/ec2/deploy.sh

Lambda (Background Jobs)

aws cloudformation deploy \
  --template-file aws/lambda/template.yaml \
  --stack-name agentic-workflow-lambda \
  --parameter-overrides OpenAIApiKey=$OPENAI_API_KEY

Environment Variables

See .env.example for all configuration options including:

  • OPENAI_API_KEY — OpenAI API key
  • DATABASE_URL — PostgreSQL connection string
  • REDIS_URL — Redis connection string
  • LANGCHAIN_API_KEY — LangSmith tracing
  • JWT_SECRET_KEY — JWT signing key

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages