diff --git a/docs/prompt b/docs/prompt deleted file mode 100644 index 06b86ad..0000000 --- a/docs/prompt +++ /dev/null @@ -1,67 +0,0 @@ -I'll help you create 30 example prompts for building a web app with FastAPI. Let me put together a solid, practical set. - -## 30 Prompts for Building FastAPI Web Apps - -**Getting Started & Project Setup** -1. "Build a FastAPI web app with a clean project structure — `app/main.py`, `routers/`, `models/`, `schemas/`, and `database.py`." -2. "Create a FastAPI project scaffold with `requirements.txt`, `.env` config, and a `README` with run instructions." -3. "Set up a FastAPI app with CORS enabled for a React frontend running on a different port." -4. "Add environment-based configuration to a FastAPI app — dev, staging, and prod settings via pydantic-settings." - -**Database & Models** -5. "Build a FastAPI app with SQLAlchemy models and a PostgreSQL database, including a migration setup." -6. "Create a FastAPI CRUD API for a 'products' table — GET, POST, PUT, DELETE endpoints with proper Pydantic schemas." -7. "Add async SQLAlchemy support to a FastAPI app using asyncpg for PostgreSQL." -8. "Set up SQLite for local development and PostgreSQL for production in the same FastAPI app." - -**Authentication & Security** -9. "Add JWT authentication to a FastAPI app — login endpoint, token refresh, and protected routes." -10. "Implement OAuth2 password flow with hashed passwords (bcrypt) for user signup and login in FastAPI." -11. "Add role-based access control (admin/user) to FastAPI routes with dependency injection." -12. "Secure a FastAPI API with API-key authentication for third-party clients." - -**Validation & Schemas** -13. "Build Pydantic schemas with validation for a user registration form — email format, password strength, and field constraints." -14. "Add request/response models with nested serialization for a blog app — posts with author and comments." -15. "Create a FastAPI endpoint that accepts file uploads with size and type validation." - -**Advanced Features** -16. "Add pagination, sorting, and filtering to a FastAPI list endpoint for a large dataset." -17. "Build a background task system in FastAPI — run a job in the background and poll its status." -18. "Add WebSocket support to a FastAPI app for real-time chat or live notifications." -19. "Implement rate limiting on a FastAPI API to prevent abuse." -20. "Add full-text search to a FastAPI app using PostgreSQL's built-in search features." - -**Testing & Quality** -21. "Write unit tests for FastAPI endpoints using pytest and TestClient." -22. "Set up automated tests with a test database fixture that runs against a clean schema." -23. "Add request logging and structured error handling to a FastAPI app." - -**Docs & Production** -24. "Customize FastAPI's auto-generated Swagger docs — add descriptions, tags, and examples to all endpoints." -25. "Containerize a FastAPI app with Docker and docker-compose, including the database service." -26. "Deploy a FastAPI app with Gunicorn + Uvicorn workers behind an Nginx reverse proxy." -27. "Add health-check and readiness endpoints to a FastAPI app for Kubernetes or Docker health probes." -28. "Set up automatic OpenAPI schema generation and versioned API routes (/v1, /v2)." - -**Real-World Examples** -29. "Build a complete FastAPI todo app with a frontend — CRUD endpoints, SQLite, and a simple HTML/JS interface." -30. "Create a FastAPI REST API for a small e-commerce store — products, orders, cart, and checkout endpoints." - ---- - -These cover the full journey from scaffold to production deploy. Want me to actually **build one of these** as a working FastAPI project? Pick a number and I'll scaffold it, run it, and show you the live API. - -You want all 60 prompts merged into one file. I'll create a single markdown document combining both batches. - -Merging and uploading the combined file. - -The upload gate wants a front-matter contract. I'll add it and re-upload. - -Fixing the Genre to an allowed value and re-uploading. - -The file is ready with a valid front-matter. Uploading now. - -All 60 prompts are now merged into a single document. The file combines both batches — the first 30 (scaffold through real-world apps) and the second 30 (integrations, async, AI, templating, production) — organized into 14 themed sections, numbered 1–60 with a front-matter header so it renders as a styled reference. - -The document card is in your chat. Want me to turn any of these prompts into a working FastAPI project? diff --git a/docs/prompt.txt b/docs/prompt.txt new file mode 100644 index 0000000..da97006 --- /dev/null +++ b/docs/prompt.txt @@ -0,0 +1,117 @@ +Title: 60 Prompts for Building FastAPI Web Apps +Kicker: FastAPI development reference +Theme: Developer reference +Genre: memo + +# 60 Prompts for Building FastAPI Web Apps + +A complete reference of example prompts to build FastAPI web applications — from project scaffold to production deploy, integrations, and real-world apps. + +--- + +## Getting Started & Project Setup + +1. "Build a FastAPI web app with a clean project structure — `app/main.py`, `routers/`, `models/`, `schemas/`, and `database.py`." +2. "Create a FastAPI project scaffold with `requirements.txt`, `.env` config, and a `README` with run instructions." +3. "Set up a FastAPI app with CORS enabled for a React frontend running on a different port." +4. "Add environment-based configuration to a FastAPI app — dev, staging, and prod settings via pydantic-settings." + +## Database & Models + +5. "Build a FastAPI app with SQLAlchemy models and a PostgreSQL database, including a migration setup." +6. "Create a FastAPI CRUD API for a 'products' table — GET, POST, PUT, DELETE endpoints with proper Pydantic schemas." +7. "Add async SQLAlchemy support to a FastAPI app using asyncpg for PostgreSQL." +8. "Set up SQLite for local development and PostgreSQL for production in the same FastAPI app." + +## Authentication & Security + +9. "Add JWT authentication to a FastAPI app — login endpoint, token refresh, and protected routes." +10. "Implement OAuth2 password flow with hashed passwords (bcrypt) for user signup and login in FastAPI." +11. "Add role-based access control (admin/user) to FastAPI routes with dependency injection." +12. "Secure a FastAPI API with API-key authentication for third-party clients." + +## Validation & Schemas + +13. "Build Pydantic schemas with validation for a user registration form — email format, password strength, and field constraints." +14. "Add request/response models with nested serialization for a blog app — posts with author and comments." +15. "Create a FastAPI endpoint that accepts file uploads with size and type validation." + +## Advanced Features + +16. "Add pagination, sorting, and filtering to a FastAPI list endpoint for a large dataset." +17. "Build a background task system in FastAPI — run a job in the background and poll its status." +18. "Add WebSocket support to a FastAPI app for real-time chat or live notifications." +19. "Implement rate limiting on a FastAPI API to prevent abuse." +20. "Add full-text search to a FastAPI app using PostgreSQL's built-in search features." + +## Testing & Quality + +21. "Write unit tests for FastAPI endpoints using pytest and TestClient." +22. "Set up automated tests with a test database fixture that runs against a clean schema." +23. "Add request logging and structured error handling to a FastAPI app." + +## Docs & Production + +24. "Customize FastAPI's auto-generated Swagger docs — add descriptions, tags, and examples to all endpoints." +25. "Containerize a FastAPI app with Docker and docker-compose, including the database service." +26. "Deploy a FastAPI app with Gunicorn + Uvicorn workers behind an Nginx reverse proxy." +27. "Add health-check and readiness endpoints to a FastAPI app for Kubernetes or Docker health probes." +28. "Set up automatic OpenAPI schema generation and versioned API routes (/v1, /v2)." + +## Real-World Examples (Batch 1) + +29. "Build a complete FastAPI todo app with a frontend — CRUD endpoints, SQLite, and a simple HTML/JS interface." +30. "Create a FastAPI REST API for a small e-commerce store — products, orders, cart, and checkout endpoints." + +--- + +## Integrations & Third-Party Services + +31. "Build a FastAPI app that sends emails via SMTP — a contact form endpoint that renders an HTML template." +32. "Create a FastAPI endpoint that uploads files to S3 (or a cloud bucket) and returns the public URL." +33. "Add Stripe payment integration to a FastAPI app — create a checkout session and handle the webhook." +34. "Build a FastAPI app that calls an external REST API (e.g. weather or news) and caches responses in Redis." +35. "Add Google OAuth login to a FastAPI app with social auth and session persistence." + +## Async & Performance + +36. "Rewrite a slow synchronous FastAPI endpoint as async with `httpx` to make concurrent external calls." +37. "Add Redis caching to a FastAPI app for expensive database queries with a TTL-based cache layer." +38. "Build a FastAPI app that streams large files or data in chunks with `StreamingResponse`." +39. "Add database connection pooling to a FastAPI app and explain how to tune pool size." +40. "Implement a job queue in FastAPI using Celery or RQ — enqueue a task, track its status, and fetch results." + +## Data Processing & AI + +41. "Build a FastAPI app that accepts a CSV upload, processes it with pandas, and returns summary statistics as JSON." +42. "Create a FastAPI endpoint that runs a machine-learning model (pickle/onnx) and returns predictions." +43. "Add a text-summarization or sentiment-analysis endpoint to a FastAPI app using a Hugging Face model." +44. "Build a FastAPI app that generates embeddings and stores them in a vector database (pgvector) for similarity search." +45. "Create a FastAPI image-upload endpoint that resizes/compresses images with Pillow and stores them." + +## Templating & Frontend + +46. "Build a FastAPI app with Jinja2 templates — a server-rendered multi-page site with a base layout." +47. "Add static files (CSS/JS/images) to a FastAPI app and wire them into Jinja templates." +48. "Create a FastAPI app that serves a single-page React build from a `dist/` folder." + +## Error Handling & Middleware + +49. "Add custom exception handlers to a FastAPI app — return structured JSON errors with proper HTTP codes." +50. "Build a FastAPI middleware that logs every request with method, path, status, and duration." +51. "Add request timing and a simple metrics endpoint (`/metrics`) exposing request counts and latencies." +52. "Implement a global exception handler that catches unhandled errors and returns a safe 500 response." + +## Real-World App Examples (Batch 2) + +53. "Build a complete FastAPI blog — posts, comments, tags, and user authentication." +54. "Create a FastAPI URL shortener with SQLite, collision-free slugs, and redirect tracking." +55. "Build a FastAPI REST API for a library — books, authors, borrow/return, and overdue reports." +56. "Create a FastAPI inventory system with stock levels, low-stock alerts, and supplier endpoints." +57. "Build a FastAPI notes app with full CRUD, search, and per-user isolation." +58. "Create a FastAPI API for a fitness tracker — workouts, exercises, sets, and progress charts data." + +## Advanced Production + +59. "Add OpenTelemetry tracing to a FastAPI app and export traces to a local Jaeger or Grafana stack." +60. "Build a FastAPI app with feature flags, graceful shutdown hooks, and a `--reload` dev profile."