Python FastAPI Guide .cursorrules prompt file
About .cursorrules prompt file
What you can build
Serverless API Gateway Manager: Create a tool that integrates with various API Gateway solutions like AWS API Gateway and Kong, allowing users to configure and manage their FastAPI services. It could offer features like setting rate limits, implementing security measures, and transforming requests for optimal serverless architecture usage.
Microservices Resilience Kit: Develop a utility to handle inter-service communication with retries, circuit breakers, and fallback mechanisms using FastAPI and message brokers like RabbitMQ. This would ensure resilient communication between microservices.
FastAPI Serverless Optimizer: Create a service that analyzes FastAPI applications and offers recommendations or automatic optimizations for deployment in serverless environments, focusing on reducing cold start times and efficient packaging.
Managed Services Integrator: Provide an integration tool that connects FastAPI applications with managed database services like AWS DynamoDB or Azure Cosmos DB, simplifying scalability and reducing operational overhead for developers.
Asynchronous Worker Manager: Build a platform that integrates with Celery or RQ to efficiently handle and monitor background tasks for FastAPI applications, offering a user-friendly interface for task status tracking and log management.
Custom Middleware Generator: Develop a framework or library for building custom middleware in FastAPI applications, focused on logging, tracing, and implementing security headers like CORS and CSP, enhancing observability and security.
Distributed Tracing Enabler: Implement a service that automatically sets up and configures OpenTelemetry for FastAPI microservices, providing detailed insights into distributed tracing without requiring extensive manual setup.
API Security Suite: Create a security-focused application that integrates with FastAPI to implement OAuth2, rate limiting, and DDoS protection, safeguarding APIs from common security threats with minimal configuration.
High-Performance Caching Layer: Offer a caching solution optimized for FastAPI, utilizing Redis or Memcached to reduce database load and improve response times, along with tools to simulate and test performance improvements.
Centralized Monitoring Dashboard: Develop a dashboard that integrates Prometheus, Grafana, and centralized logging systems to provide a comprehensive monitoring and alerting suite for FastAPI applications, tailored for microservices.
Performance and Scalability Analyzer: Create a diagnostic tool to analyze FastAPI backend services, providing insights into throughput, latency, and scalability bottlenecks, with actionable optimization suggestions for developers.
Benefits
- Implement stateless services utilizing external storage/caches, ensuring resiliency with circuit breakers and retries.
- Integrate FastAPI with API Gateways for security, request transformation, and efficient microservices communication.
- Optimize FastAPI applications for serverless deployments, employing lightweight containers and managing automatic scaling.
Synopsis
This prompt is ideal for backend developers building scalable, cloud-native microservice architectures with FastAPI, serverless technologies, and advanced optimization and security techniques.
Overview of .cursorrules prompt
The .cursorrules file outlines advanced principles and best practices for building scalable, secure, and performant applications using Python and FastAPI within a microservices and serverless architecture. It emphasizes stateless service design, use of external storage, integration with API gateways, and resilient service communication. The file also describes optimizing FastAPI for serverless environments, employing asynchronous workers, and using managed services for scaling. Additional focus areas include implementing advanced middleware for security and performance, leveraging caching, and employing monitoring tools like Prometheus and Grafana for application observability. Key conventions encourage adherence to microservices principles, and optimization for cloud-native deployments, with references to relevant documentation.