RunPrompt Pro
cursor Backend Architecture
β˜… 4.98 (5.420 uses)

FastAPI, PostgreSQL & Supabase Production (.cursorrules)

Eliminates common Python AI code generation traps: synchronous database calls in async routes, outdated Pydantic v1 syntax, and missing transaction rollbacks.

⏱️ 2 min breakdown (226 words) β€’ βœ“ 2026 Engine Calibrated
𝕏 Share in Post

Parametric Customizer & Compiler Live Tool

Adjust the variables below. The prompt code and API payload update dynamically in real time.

5420 uses
Fast Presets:

Specifies how asynchronous worker queues should be constructed.

Tells Cursor which authentication middlewares to scaffold.

Ready-to-Run Compiled Prompt
0 words β€’ 0 tokens β€’ Est: <$0.0001 β€’ β€’ β€’
# CURSOR RULES FOR FASTAPI & SUPABASE BACKEND

You are a Principal Python Architect specializing in FastAPI, Pydantic v2, async SQLAlchemy 2.0, and Supabase PostgreSQL.

### TECH STACK REQUIREMENTS:
- Python: 3.12+ with strict type hints throughout
- Web Framework: FastAPI (modern APIRouter modular architecture)
- Schema Validation: Pydantic v2 (use model_config = ConfigDict(...), never v1 class Config)
- Database: PostgreSQL on Supabase managed via asyncpg & SQLAlchemy 2.0 async engine
- Background Jobs: FastAPI native BackgroundTasks (for lightweight webhooks & emails)
- Authentication: Supabase Auth JWT verification with FastAPI dependency injection

### ARCHITECTURAL CONSTRAINTS:
1. **Pure Asynchronous Execution**:
   - ALL database queries must use `await session.execute(...)` and async session context managers.
   - Never introduce synchronous blocking operations (`time.sleep()`, synchronous `requests.get()`) into route handlers.

2. **Security & Row-Level Security (RLS)**:
   - All Supabase tables MUST enforce Row-Level Security.
   - Route dependencies must validate JWT claims before touching ORM models.

3. **API Design Standards**:
   - Return strict Pydantic response models using `response_model=...`
   - Handle errors with explicit `HTTPException(status_code=..., detail=...)` and custom domain exception handlers.
   - Paginate all list endpoints using cursor-based or limit-offset structures.
Download Cursor AI (Free Trial)

Code with full codebase indexing and instant multi-file generation.

⚑
Featured AI Partner Verified

Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.

πŸ“Έ Real Sample Outputs & Verified Results

Visual evidence and benchmark responses generated using this exact prompt formula.

### Example Generated Route with Async SQLAlchemy 2.0 & Pydantic v2: ```python from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy import select from app.db import get_async_session from app.models import Project from app.schemas import ProjectResponse router = APIRouter(prefix="/projects", tags=["projects"]) @router.get("/{project_id}", response_model=ProjectResponse) async def get_project( project_id: str, session: AsyncSession = Depends(get_async_session) ): query = select(Project).where(Project.id == project_id) result = await session.execute(query) project = result.scalar_one_or_none() if not project: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=f"Project '{project_id}' not found" ) return project ```
Pydantic v2 and Async SQLAlchemy route avoiding synchronous blocking calls.

πŸ”¬ Prompt Engineering Anatomy

Why this prompt consistently delivers high-tier results: technical parameter breakdown.

1 Pydantic v2 Migration Constraint

Cursor often mixes Pydantic v1 (`.dict()`, `class Config`) and v2 (`.model_dump()`, `model_config`). Explicitly pinning v2 removes dozens of deprecation warnings.

PRO TIP: Specify 'Never import from pydantic.v1' in your `.cursorrules` to keep dependencies clean.
2 Async SQLAlchemy 2.0 scalar_one_or_none() syntax

Legacy SQLAlchemy 1.4 syntax like `query.first()` breaks under modern async sessions. Pinning 2.0 standardizes execution queries.

PRO TIP: Always wrap mutations in `async with session.begin():` for automatic rollback on exceptions.

πŸ’¬ Frequently Asked Questions

Troubleshooting common edge cases, model incompatibilities, and best practices.

Where should I save this file in my FastAPI repository?

Save it as `.cursorrules` in the root folder of your project, right next to your `pyproject.toml` or `requirements.txt`.

Does this work with Windsurf or GitHub Copilot?

Yes! Windsurf automatically reads `.windsurfrules` (you can create a symlink or rename it).

Sponsored / Featured Partner
Ad Transparency
⚑

Cursor AI & Claude 3.5 Sonnet Pro Bundle

Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.

Claim Free Trial

Explore Related AI Coding & Rulesets Prompts View all β†’

πŸš€ Community Showcase

Submit Your Proven AI Prompt

Share your best prompt formula. Approved prompts get featured on RunPrompt with a backlink to your profile or website!

Prompts & Generative Tools
chatgpt B2B SaaS Customer Case Study & Social Proof Storytelling Engine
AI Marketing & Copywriting
chatgpt B2B SaaS Churn Prevention & Inactive Account Win-Back Email Sequence
Marketing & Copywriting
chatgpt B2B SaaS 3-Tier Pricing Page & High-Conversion Copy Teardown
AI Marketing & Copywriting
chatgpt B2B LinkedIn Viral Carousel & High-CTR Hook Generator
AI Marketing & Copywriting
claude Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
AI Coding & Architecture
claude Hyper-Personalized B2B Cold Email Sequence with 40%+ Open Rates
B2B Sales & Cold Outreach
claude Claude 3.5 Executive Ghostwriter & Thought Leadership Essay Studio
Business & Career
midjourney Amazon A+ Content & Shopify Lifestyle Product Mockup Generator
E-Commerce & Amazon A+
flux Cyberpunk Tokyo Streetwear Character Portrait Generator
Character & Fashion Concepts
cursor Cursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
AI Coding & Rulesets
deepseek DeepSeek-R1 Autonomous Deep Research & Synthesis Engine
AI Coding & Architecture
deepseek DeepSeek-R1 Quantitative Algorithmic Trading & Alpha Strategy Backtester
AI Coding & Architecture
deepseek DeepSeek R1 Architecture & Security Vulnerability Code Auditor
AI Coding & Rulesets
deepseek DeepSeek-V3 671B MoE High-Throughput System Rules & Benchmark
AI Coding & Architecture
cursor FastAPI + Pydantic v2 + Supabase Production .cursorrules
AI Coding & Architecture
claude ATS-Proof Executive Resume & Metric-Driven CV Rewrite Prompt
Career & Executive Growth
cursor FastAPI, PostgreSQL & Supabase Production (.cursorrules)
AI Coding & Rulesets
flux Invisible Ghost Mannequin Apparel & Fashion Mockup Generator
Fashion & Ghost Mannequin
flux FLUX.1 Studio Commercial Beverage & Food High-Speed Splash Photography
Image & Art Generation
flux FLUX.1 Extreme Macro Human Eye Iris & Corneal Reflection Photography
Image & Art Generation
flux Flux 1.1 Pro Luxury Cosmetic Bottle & Product Packaging Mockup
AI Image & Icons
flux Flux 1.1 Pro Ultra-Photorealistic 85mm Studio Portrait
AI Image & Icons
claude Gemini 2.0 Flash Multimodal Video & Audio Real-Time Analyzer
AI Coding & Architecture
flux Flux 1.1 Pro Vintage 1970s Kodachrome 35mm Analog Film
AI Image & Icons
flux Cinematic AI Video Camera Movement & Motion Generator
AI Video & Camera Motion
cursor Go 1.24 Distributed Worker Pool & Lock-Free Channel Architecture
AI Coding & Architecture
kling Kling 1.5 & Runway Gen-3 1000fps High-Speed Bullet-Time Video Director
AI Video Generation
midjourney Luxury Perfume Studio Product Photography Prompt Generator
E-Commerce & Product Mockups
midjourney Midjourney v6.1 Architectural Digest Minimalist Concrete & Travertine Villa
AI Image & Icons
midjourney Malibu Oceanfront Brutalist Luxury Villa Architectural Digest Render
Architecture & Interior Design
flux Surreal Seamless Morphing & Physics Transformation Video Prompt
AI Video & Camera Motion
midjourney Midjourney v6.1 Isometric Cyberpunk Game Asset Tileset
AI Image & Icons
midjourney Midjourney v6.1 Vogue Editorial High-Fashion Haute Couture
AI Image & Icons
midjourney Midjourney Cinematic Sci-Fi Spaceship & Orbital Station Interiors
Image & Art Generation
midjourney Midjourney Isometric 3D Voxel Diorama & Miniature World Studio
Image & Art Generation
cursor Next.js 15 App Router + React 19 Server Actions .cursorrules
AI Coding & Architecture
midjourney Minimalist 3D Claymorphic iOS App Icon & Logo Generator
Logos & App Icons
cursor React 19 + Tailwind v4 + Shadcn UI Financial Dashboard .cursorrules
AI Coding & Architecture
cursor Rust 2024 Zero-Cost Async Actor System & Lock-Free MPSC Architecture
AI Coding & Architecture
cursor React Native & Expo Router Mobile App Production (.cursorrules)
AI Coding & Rulesets
chatgpt High-Converting B2B SaaS Landing Page Copy Mega-Prompt
Direct Response Copywriting
deepseek Solidity Smart Contract Reentrancy & Flash Loan Attack Auditor
Blockchain & Smart Contracts
claude 2026 Google AI Overviews & Semantic Entity Cluster Architecture Mega-Prompt
Search Strategy & Semantic SEO
chatgpt Suno v3.5 & Udio Viral Cyberpunk Synthwave Hit Formula
AI Music & Audio Prompts
claude Viral Twitter / X Long-Form Educational Thread Architect
Social Media & Viral Growth
chatgpt B2B Enterprise Churn Post-Mortem & Account Recovery Playbook Studio
Marketing & Copywriting
deepseek DeepSeek-R1 Mathematical Formal Proofs & Lean 4 Theorem Derivation
AI Coding & Architecture
flux FLUX.1 3D Frosted Glassmorphism UI & Floating Mobile Dashboard Studio
Image & Art Generation
kling Kling 1.5 Sci-Fi Hyperspace Jump & Faster-Than-Light Tunnel Director
AI Video Generation
midjourney Midjourney 35mm Candid Editorial Street Photography (Leica M11 & Cartier-Bresson Style)
Image & Art Generation
cursor Solana Anchor (Rust) Smart Contract Security Audit & Exploit Guard
AI Coding & Architecture
cursor TypeScript 5.8 Strict Domain-Driven Design (DDD) & Branded Types Architecture
AI Coding & Architecture
chatgpt B2B Enterprise Competitor Battlecard & Kill Sheet
Marketing & Copywriting
claude Claude 3.5 Sonnet Model Context Protocol (MCP) Server Architect
Coding & Architecture
cursor Cursor Rules: FastAPI Clean Architecture & TDD Repository Pattern
Coding & Architecture
claude Claude 3.5 Anthropic XML Tag System Prompt Engineering Framework
Coding & Architecture
deepseek DeepSeek-R1 SEC 10-K & Financial Forensics Auditor
Career & Business
flux FLUX.1 Dark Fantasy Eldritch Tarot Card Illustration
AI Art & Image
kling Kling 1.5 FPV Urban Parkour & Rooftop Motion Hyperlapse
AI Video & 3D
midjourney Midjourney Architectural Photography: Brutalist Concrete & Biophilic Glass
AI Art & Image
↑ ↓ Navigate ↡ Select
RunPrompt Spotlight
πŸ•’

Recent Generations

Your customized prompts generated in this session. Saved privately in your browser.

No recent prompts yet. Customize and copy any prompt to see your history here!
0 items stored