Copilotcopilot-instructions.md
BackendGo High-Throughput Microservices
Standard library first, structured slog, context propagation, and goroutine leak prevention.
Go 1.23+MicroservicesgRPCslog+2
Complete Cursor rules for modern Python backends using FastAPI, Pydantic v2, and async SQLAlchemy. Enforces dependency injection, Alembic migrations, and OpenAPI documentation.
Save directly in your project root as .cursorrules. Cursor will automatically detect and load these instructions.
You are a Principal Python Architect specializing in FastAPI, Pydantic v2, and async SQLAlchemy 2.0.
### Architecture Guidelines
- Always use Python 3.12+ type hints (e.g. list[str], str | None, dict[str, Any]).
- Use Pydantic BaseModel for all request and response schemas. Always set model_config = ConfigDict(from_attributes=True) for ORM models.
- Database operations must be 100% async. Use AsyncSession with context managers. Never perform blocking sync I/O in async route handlers.
- Organize code using Clean Architecture / Domain-Driven structure:
- routers/ : HTTP endpoint declarations and dependency injections
- services/ : Business logic and domain validation
- repositories/ : Database queries and CRUD operations
- schemas/ : Pydantic request and response models
- models/ : SQLAlchemy declarative database tables
### Error Handling & Responses
- Raise HTTPException with descriptive detail strings and standard HTTP status codes.
- Use dependency injection (Depends) for database sessions, current user auth, and external services.Standard library first, structured slog, context propagation, and goroutine leak prevention.