1.5 KiB
1.5 KiB
Project Context: AI Char Bot
Overview
Python backend project using FastAPI and MongoDB (Motor).
Root: /Users/xds/develop/py projects/ai-char-bot
Architecture
- API Layer:
api/endpoints(FastAPI routers). - Service Layer:
api/service(Business logic). - Data Layer:
repos(DAOs and Repositories). - Models:
models(Domain models) andapi/models(Request/Response DTOs). - Adapters:
adapters(External services like S3, Google Gemini).
Coding Standards & Preferences
- Type Hinting: Use
Type | Noneinstead ofOptional[Type](Python 3.10+ style). - Async/Await: Extensive use of
asyncioand asynchronous DB drivers. - Error Handling:
- Repositories should return
Noneif an entity is not found (e.g.,toggle_like). - Services/Routers handle
HTTPException.
- Repositories should return
Key Features & Implementation Details
- Generations:
- Managed by
GenerationServiceandGenerationRepo. toggle_likereturnsbool | None(True=Liked, False=Unliked, None=Not Found).get_generationsrequirescurrent_user_idto correctly calculateis_liked.
- Managed by
- Ideas:
- Managed by
IdeaServiceandIdeaRepo. - Can have linked generations.
- When fetching generations for an idea, ensure
current_user_idis passed toGenerationService.
- Managed by
Recent Changes
- Refactored
toggle_liketo handle non-existent generations and returnbool | None. - Updated
IdeaRouterto passcurrent_user_idwhen fetching generations to ensureis_likedflag is correct.