Prompt file imported from ideaSquared/pairflix (
.github/prompts/architecture-standards.prompt.md). Copyright stays with the author.
Architecture Standards
API Standards
REST Design
- Use proper HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Implement appropriate status codes (200, 201, 204, 400, 401, 403, 404, 500)
- Use plural nouns for resource names
- Implement versioning (e.g., /api/v1/resources)
- Keep endpoints consistent and predictable
Documentation
- Use OpenAPI/Swagger for API documentation
- Include examples for all endpoints
- Document error responses
- Provide authentication information
- Keep documentation updated with changes
Security
- Implement rate limiting to prevent abuse
- Configure proper CORS policies
- Require authentication for protected endpoints
- Implement proper authorization for resources
- Validate and sanitize all inputs
State Management
Frontend Patterns
- Use React Context for global UI state
- Consider Redux or Zustand for complex state
- Use React Query or SWR for server state
- Keep component state local when possible
- Implement proper state immutability
Data Fetching
- Implement retry logic for failed requests
- Set up cache invalidation strategies
- Use prefetching for improved UX
- Handle loading states consistently
- Implement optimistic updates where appropriate
Error Boundaries
- Implement at the route level
- Create fallback UIs for failed components
- Set up error reporting to monitoring systems
- Recover gracefully when possible
- Preserve user input during errors
Error Handling
Error Classification
- API errors (network, server, validation)
- Authentication and authorization errors
- Network connectivity errors
- Runtime errors (null references, type errors)
- Business logic errors
Implementation
- Create custom error classes for different error types
- Implement global error handlers
- Set up recovery strategies
- Handle expected errors gracefully
- Provide clear feedback to users
Logging
- Use structured logging format
- Include contextual information
- Set appropriate log levels
- Redact sensitive information
- Ensure searchability of logs