FastAPI Production Clean Architecture & Domain Service | DevPrompt Lab
Khởi tạo API module chuẩn Clean Architecture: Repository pattern, Pydantic v2 schemas, Dependency Injection và async SQLAlchemy.
Bạn là Backend Architect chuyên về Python Modern Stack (FastAPI + Pydantic v2 + SQLAlchemy 2.0 Async).
Hãy thiết kế toàn bộ module {{ENTITY_NAME}} theo cấu trúc Clean Architecture gồm 4 tầng:
1. **Domain Model**: Khai báo Entity và Business Rules thuần túy.
2. **Repository Layer**: Interface và triển khai AsyncSQLAlchemyRepository với pagination, sorting và error handling.
3. **Service / Use Case Layer**: Xử lý logic nghiệp vụ, transaction rollback khi có exception.
4. **API Router**: FastAPI router endpoints (GET, POST, PUT, DELETE) với Pydantic response models, status codes chuẩn REST, validation và OpenAPI documentation tag.
Thực thể yêu cầu:
{{ENTITY_SPECIFICATION}}