Skip to content

πŸ”§ Production-ready LangGraph + RAG Agentic AI System End-to-end boilerplate for deploying a secure, modular, and scalable RAG-based AI agent. Features LangGraph orchestration, Redis state, local vector search, FastAPI backend, Streamlit UI, Prometheus monitoring, Docker & Kubernetes deployment.

Notifications You must be signed in to change notification settings

pradeepgithubrepo/lang_with_k8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Enterprise RAG Agent – LangGraph + FastAPI + Redis + Kubernetes

🧠 A production-grade, agentic AI backend that combines LangGraph, Retrieval-Augmented Generation (RAG), persistent memory via Redis, and secure FastAPI endpoints. Designed for full-scale deployment on Docker and Kubernetes with monitoring and API key security.


🎯 Objective

This project provides a modular boilerplate to build and deploy end-to-end agentic AI applications using LangGraph and RAG. It is production-ready, scalable, and extensible, enabling multi-turn conversations, external document integration, persistent memory, and comprehensive monitoring.


🧱 Architecture Overview

+------------------+       +-------------------+       +------------------+
|   Streamlit UI   | <---> | FastAPI Backend    | <---> |  LangGraph Agent |
+------------------+       +-------------------+       +------------------+
                                      |
                             +--------+--------+
                             |   Redis Memory   |
                             +--------+--------+
                                      |
                              +-------+--------+
                              | Vector Store    |
                              | (Chroma)  |
                              +----------------+

πŸ“ Codebase Structure

/enterprise-rag-agent
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py                 # FastAPI entrypoint
β”‚   β”œβ”€β”€ config.py               # App-wide config (env vars, secrets)
β”‚   β”œβ”€β”€ tools.py                # Tool functions used in LangGraph
β”‚   β”œβ”€β”€ graph_manager.py        # LangGraph graph and flow logic
β”‚   β”œβ”€β”€ vector_store/
β”‚   β”‚   β”œβ”€β”€ loader.py           # Load PDFs, markdown, etc.
β”‚   β”‚   β”œβ”€β”€ embedder.py         # Embedding logic using OpenAI or others
β”‚   β”‚   └── vectordb.py         # Vector DB logic (FAISS/Chroma)
β”‚   β”œβ”€β”€ node_pool/
β”‚   β”‚   β”œβ”€β”€ retrieve_node.py
β”‚   β”‚   β”œβ”€β”€ generate_node.py
β”‚   β”‚   └── fallback_node.py
β”‚   β”œβ”€β”€ state_manager/
β”‚   β”‚   └── memory_state.py     # Redis chat history threading
β”‚   β”œβ”€β”€ integration/
β”‚   β”‚   └── confluence_api.py   # Placeholder for API integrations
β”‚   β”œβ”€β”€ security/
β”‚   β”‚   └── auth.py             # API key validation
β”‚   β”œβ”€β”€ monitoring/
β”‚   β”‚   └── metrics.py          # Prometheus-ready metrics
β”‚   β”œβ”€β”€ error_handler.py        # Global exception handling
β”‚
β”œβ”€β”€ streamlit_ui/
β”‚   └── ui.py                   # Multi-tab UI for user interaction
β”‚
β”œβ”€β”€ data/
β”‚   └── sample_docs/            # PDFs, Markdown, CSVs for ingestion
β”‚
β”œβ”€β”€ docker/
β”‚   └── Dockerfile              # Backend Docker setup
β”‚
β”œβ”€β”€ k8/
β”‚   β”œβ”€β”€ deployment.yaml         # Kubernetes deployment
β”‚   └── service.yaml            # Kubernetes service
β”‚
β”œβ”€β”€ .env                        # Secrets like API keys
β”œβ”€β”€ .gitignore                 # Ignored files
β”œβ”€β”€ requirements.txt           # Python dependencies
└── README.md                  # You’re reading it

βš™οΈ Setup Instructions

1. 🧬 Clone Repo

git clone https://github.com/your-org/enterprise-rag-agent.git
cd enterprise-rag-agent

2. πŸ” Create .env

AZURE_ENDPOINT = 
AZURE_API_KEY = 
OPENAI_API_TYPE = 
AZURE_DEPLOYMENT = 
AZURE_API_VERSION = 
AZURE_MODEL=
GEMINI_API_KEY=
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT=
LANGSMITH_API_KEY=
LANGSMITH_PROJECT=
SERPER_API_KEY=
RAG_API_KEY=

3. πŸ“¦ Install Dependencies

pip install -r requirements.txt

4. πŸš€ Start Redis

docker run -d -p 6379:6379 redis

5. 🧠 Run FastAPI Backend

uvicorn app.main:app --reload

6. πŸ–₯️ Run Streamlit UI

streamlit run streamlit_ui/ui.py

πŸ” Security

  • βœ… API key validation via X-API-Key
  • βœ… Secure loading from .env using python-dotenv
  • βœ… Centralized auth.py logic

🧠 Memory & Chat Threading

  • πŸ” Redis-based persistent state across sessions
  • 🧡 Threaded conversations
  • πŸ’Ύ State autosaved before/after LangGraph execution

πŸ€– LangGraph Agent

  • Nodes:
    • πŸ“₯ Retrieve Node – RAG doc search
    • ✍️ Generate Node – LLM reasoning
    • 🧯 Fallback Node – edge case handler
  • Built using LangGraph’s composable workflows

πŸ“‘ API Reference

POST /ask

Ask a question to the agent.

POST /ask
Headers:
  X-API-Key: your_api_key

Body:
{
  "question": "What is the sales trend for Q1?"
}

Response

{
  "final_answer": "The sales trend for Q1 was an upward growth of 18%."
}

πŸ“Š Monitoring

  • πŸ“ˆ /metrics endpoint exposes Prometheus counters
  • Tracks:
    • ⚑ Request duration
    • πŸ”’ Total requests
    • βœ… Response status codes
    • πŸ” RAG operation metrics

🐳 Docker Support

docker network create rag-net
 docker run -d   --name redis   --network rag-network   redis:latest
docker network connect rag-net redis

 docker run -d   --name rag-backend   --network rag-net   -p 8000:8000   rag-backend:latest

docker run -d   --name rag-frontend   --network rag-net   -p 8501:8501   rag-frontend:latest<img width="902" height="189" alt="image" src="https://github.com/user-attachments/assets/66ef1b9e-081d-4c5c-9b61-93f61d7576c5" />

☸️ Kubernetes Deployment

kubectl apply -f deployment/

βœ… Feature Highlights

  • πŸ” Secure API layer
  • πŸ“š Vector Search with FAISS/Chroma
  • πŸ”„ Persistent Redis memory
  • 🧠 LangGraph agent orchestration
  • πŸ§ͺ Monitoring with Prometheus
  • πŸ–₯️ Multi-tab Streamlit UI
  • 🐳 Docker-ready
  • ☸️ Kubernetes-ready

🚧 Coming Soon

  • πŸš€ CI/CD via GitHub Actions
  • ☁️ Azure Blob, SharePoint, Confluence integrations
  • πŸ’¬ Slack & Teams notifications
  • 🧾 Session transcripts and summaries

πŸ‘¨β€πŸ’» Maintainer

Pradeep P. – Software Professional | AI & Cloud Engineer

Feel free to fork, contribute, or raise issues!


About

πŸ”§ Production-ready LangGraph + RAG Agentic AI System End-to-end boilerplate for deploying a secure, modular, and scalable RAG-based AI agent. Features LangGraph orchestration, Redis state, local vector search, FastAPI backend, Streamlit UI, Prometheus monitoring, Docker & Kubernetes deployment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published