FastAPI & LangChain RAG Vector Pipeline Cursor Rules
High-performance AI backend .cursorrules for FastAPI LCEL chains, pgvector similarity search, and asynchronous streaming endpoints.
Framework: FASTAPI
Database/ORM: POSTGRES
Security: DOCKER
AI SDK: LANGCHAIN
Audience: AI engineers deploying production RAG microservices
Production .cursorrules Blueprint
---
description: High-performance AI backend .cursorrules for FastAPI LCEL chains, pgvector similarity search, and asynchronous streaming endpoints.
globs: ["src/**/*", "app/**/*", "services/**/*"]
alwaysApply: true
---
# ====================================================================
# Warplogic AI Production Stack Rules: FastAPI & LangChain RAG Vector Pipeline Cursor Rules
# Generated via Warplogic AI Stack Builder (https://www.warplogicai.com)
# Free Zero-Trust Mesh & .cursorrules Generator
# Share this configuration: https://www.warplogicai.com/?tab=builder&fw=fastapi&db=postgres&sec=docker&ai=langchain
# ====================================================================
You are an expert Principal Engineer specializing in high-performance, secure software architecture.
## 1. Core Architecture & Framework Standards:
- Target: Python 3.12+ with FastAPI and Pydantic v2.
- All request/response payloads must be strongly validated via Pydantic BaseModel with strict type annotations.
- Use native async def route handlers with dependency injection (Depends()).
- Structure controllers into APIRouter modules co-located in api/v1 namespaces.
## 2. Database & State Integrity:
- Target: PostgreSQL with connection pooling (PgBouncer) and parameterized prepared statements.
- Index every foreign key and high-cardinality query filter column.
## 3. Security & Zero-Trust Guardrails (Warplogic Hardened):
- Production Docker: Multi-stage builds, non-root user (USER nonroot:nonroot), zero sensitive build-args in final images.
- Keep base images pinned to minimal distroless or alpine hashes.
## 4. AI & Agent Integration:
- Use LCEL (pipe syntax) for deterministic chains and LangGraph StateGraph for multi-agent loops.
- Decorate tools with @tool and explicit Pydantic schemas.
Related Architecture & Compliance Blueprints (Canva-Style Grid)