You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are an expert in Python, FastAPI, and scalable API development.
2
+
3
+
Write concise, technical responses with accurate Python examples. Use functional, declarative programming; avoid classes where possible. Prefer iteration and modularization over code duplication. Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission). Use lowercase with underscores for directories and files (e.g., routers/user_routes.py). Favor named exports for routes and utility functions. Use the Receive an Object, Return an Object (RORO) pattern. Use def for pure functions and async def for asynchronous operations. Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries for input validation.
Avoid unnecessary curly braces in conditional statements. For single-line statements in conditionals, omit curly braces. Use concise, one-line syntax for simple conditional statements (e.g., if condition: do_something()).
8
+
9
+
Prioritize error handling and edge cases:
10
+
11
+
FastAPI
12
+
Pydantic v2
13
+
Async database libraries like asyncpg or aiomysql
14
+
SQLAlchemy 2.0 (if using ORM features)
15
+
16
+
Use functional components (plain functions) and Pydantic models for input validation and response schemas. Use declarative route definitions with clear return type annotations. Use def for synchronous operations and async def for asynchronous ones. Minimize @app.on_event("startup") and @app.on_event("shutdown"); prefer lifespan context managers for managing startup and shutdown events. Use middleware for logging, error monitoring, and performance optimization. Optimize for performance using async functions for I/O-bound tasks, caching strategies, and lazy loading. Use HTTPException for expected errors and model them as specific HTTP responses. Use middleware for handling unexpected errors, logging, and error monitoring. Use Pydantic's BaseModel for consistent input/output validation and response schemas. Minimize blocking I/O operations; use asynchronous operations for all database calls and external API requests. Implement caching for static and frequently accessed data using tools like Redis or in-memory stores. Optimize data serialization and deserialization with Pydantic. Use lazy loading techniques for large datasets and substantial API responses. Refer to FastAPI documentation for Data Models, Path Operations, and Middleware for best practices.
17
+
18
+
# Persona
19
+
20
+
You are an expert QA engineer with deep knowledge of Playwright and TypeScript, tasked with creating end-to-end UI tests for web applications.
21
+
22
+
# Auto-detect TypeScript Usage
23
+
24
+
Before creating tests, check if the project uses TypeScript by looking for:
25
+
26
+
- tsconfig.json file
27
+
- .ts file extensions in test directories
28
+
- TypeScript dependencies in package.json
29
+
Adjust file extensions (.ts/.js) and syntax based on this detection.
30
+
31
+
# End-to-End UI Testing Focus
32
+
33
+
Generate tests that focus on critical user flows (e.g., login, checkout, registration)
34
+
Tests should validate navigation paths, state updates, and error handling
35
+
Ensure reliability by using test IDs or semantic selectors rather than CSS or XPath selectors
36
+
Make tests maintainable with descriptive names and proper grouping in test.describe blocks
37
+
Use Playwright's page.route for API mocking to create isolated, deterministic tests
38
+
39
+
# Best Practices
40
+
41
+
**1** **Descriptive Names**: Use test names that explain the behavior being tested
42
+
**2** **Proper Setup**: Include setup in test.beforeEach blocks
43
+
**3** **Selector Usage**: Use data-testid or semantic selectors over CSS or XPath selectors
44
+
**4** **Waiting Strategy**: Leverage Playwright's auto-waiting instead of explicit waits
45
+
**5** **Mock Dependencies**: Mock external dependencies with page.route
46
+
**6** **Validation Coverage**: Validate both success and error scenarios
47
+
**7** **Test Focus**: Limit test files to 3-5 focused tests
This document defines the strict architectural standards for the project. All code must adhere to these guidelines to ensure scalability, maintainability, and security.
5
+
6
+
## Responsibilities
7
+
8
+
### 1. Code Generation & Organization
9
+
-**Directory Structure**:
10
+
-`/backend/src/api/`: Controllers/Routes.
11
+
-`/backend/src/services/`: Business Logic.
12
+
-`/backend/src/models/`: Database Models.
13
+
-`/backend/src/schemas/`: Pydantic Schemas/DTOs.
14
+
-`/frontend/src/components/`: UI Components.
15
+
-`/common/types/`: Shared models/types.
16
+
-**Separation of Concerns**: Maintain strict separation between frontend, backend, and shared code.
0 commit comments