Refactor documentation standards and structure; consolidate clean code principles and service documentation requirements

This commit is contained in:
glenn schrooyen
2025-09-11 23:51:00 +02:00
parent b9206de1a0
commit 83fb444196
6 changed files with 177 additions and 530 deletions

View File

@@ -6,26 +6,30 @@ alwaysApply: false
# API Standards
## API Documentation
When working with service files, follow these standards:
### OpenAPI Requirements
## Service Documentation
Each service MUST have comprehensive documentation:
- **API Gateway**: @services/api-gateway/README.md and @services/api-gateway/CLEAN_CODE.md
- **Service Adapters**: @services/service-adapters/README.md and @services/service-adapters/CLEAN_CODE.md
- **API Docs**: @services/api-docs/README.md and @services/api-docs/CLEAN_CODE.md
## Clean Code Implementation
Apply the principles detailed in each service's CLEAN_CODE.md:
- **Java Spring Boot**: Follow @services/api-gateway/CLEAN_CODE.md
- **Python FastAPI**: Follow @services/service-adapters/CLEAN_CODE.md
- **Node.js Express**: Follow @services/api-docs/CLEAN_CODE.md
## API Documentation
- All endpoints MUST have OpenAPI documentation
- Include request/response schemas
- Provide example requests and responses
- Document error responses
- Include authentication requirements
### Documentation Tags
- Use consistent tags for endpoint grouping
- Provide clear descriptions
- Include parameter documentation
- Document response codes
## Error Handling
### Consistent Error Responses
Use consistent error response format:
```javascript
// Standard error response format
{
"error": "Error type",
"message": "User-friendly message",
@@ -34,63 +38,24 @@ alwaysApply: false
}
```
### HTTP Status Codes
- 200: Success
- 201: Created
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 500: Internal Server Error
- 503: Service Unavailable
## HTTP Status Codes
- 200: Success, 201: Created
- 400: Bad Request, 401: Unauthorized, 403: Forbidden, 404: Not Found
- 500: Internal Server Error, 503: Service Unavailable
## Service-Specific Standards
### Java Spring Boot
- Use constructor injection
- Implement proper validation
- Use appropriate annotations
- Follow REST conventions
- Implement global exception handling
### Python FastAPI
- Use Pydantic models
- Implement async/await
- Use dependency injection
- Follow OpenAPI standards
- Implement proper error handling
### Node.js Express
- Use middleware appropriately
- Implement proper error handling
- Use async/await patterns
- Follow REST conventions
- Implement health checks
- **Java Spring Boot**: Constructor injection, proper validation, REST conventions
- **Python FastAPI**: Pydantic models, async/await, dependency injection
- **Node.js Express**: Middleware usage, error handling, health checks
## Validation
### Input Validation
- Validate all inputs
- Sanitize user data
- Use appropriate data types
- Implement rate limiting
### Response Validation
- Validate response schemas
- Use consistent data formats
- Implement proper error handling
- Document response structures
## Performance
### API Performance
- Use pagination for large datasets
- Implement response compression
- Use appropriate HTTP methods
- Optimize response sizes
### Caching
- Implement appropriate caching
- Use Redis for distributed caching
- Cache frequently accessed data
- Implement cache invalidation
- Optimize response sizes