# 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) and `api/models` (Request/Response DTOs). - **Adapters**: `adapters` (External services like S3, Google Gemini). ## Coding Standards & Preferences - **Type Hinting**: Use `Type | None` instead of `Optional[Type]` (Python 3.10+ style). - **Async/Await**: Extensive use of `asyncio` and asynchronous DB drivers. - **Error Handling**: - Repositories should return `None` if an entity is not found (e.g., `toggle_like`). - Services/Routers handle `HTTPException`. ## Key Features & Implementation Details - **Generations**: - Managed by `GenerationService` and `GenerationRepo`. - `toggle_like` returns `bool | None` (True=Liked, False=Unliked, None=Not Found). - `get_generations` requires `current_user_id` to correctly calculate `is_liked`. - **Ideas**: - Managed by `IdeaService` and `IdeaRepo`. - Can have linked generations. - When fetching generations for an idea, ensure `current_user_id` is passed to `GenerationService`. ## Recent Changes - Refactored `toggle_like` to handle non-existent generations and return `bool | None`. - Updated `IdeaRouter` to pass `current_user_id` when fetching generations to ensure `is_liked` flag is correct.