
Some checks failed
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Failing after 1m24s
This commit adds new guidelines for FastAPI and Vue.js development, emphasizing best practices for component structure, API performance, and data handling. It also introduces caching mechanisms using Redis for improved performance and updates the API structure to streamline authentication and user management. Additionally, new endpoints for categories and time entries are implemented, enhancing the overall functionality of the application.
32 lines
1.9 KiB
Plaintext
32 lines
1.9 KiB
Plaintext
---
|
||
description:
|
||
globs:
|
||
alwaysApply: true
|
||
---
|
||
# FastAPI-Specific Guidelines:
|
||
- 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.
|
||
|
||
Performance Optimization:
|
||
- 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.
|
||
|
||
Key Conventions
|
||
1. Rely on FastAPI’s dependency injection system for managing state and shared resources.
|
||
2. Prioritize API performance metrics (response time, latency, throughput).
|
||
3. Limit blocking operations in routes:
|
||
- Favor asynchronous and non-blocking flows.
|
||
- Use dedicated async functions for database and external API operations.
|
||
- Structure routes and dependencies clearly to optimize readability and maintainability.
|
||
|
||
|
||
Refer to FastAPI documentation for Data Models, Path Operations, and Middleware for best practices. |