
- Set up project structure with FastAPI and SQLite - Implement user authentication using JWT - Create database models for users, conversations, and messages - Implement API endpoints for user management and chat functionality - Set up WebSocket for real-time messaging - Add database migrations with Alembic - Create health check endpoint - Update README with comprehensive documentation generated with BackendIM... (backend.im)
32 lines
658 B
Python
32 lines
658 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
class MessageBase(BaseModel):
|
|
content: str
|
|
recipient_id: Optional[str] = None # Optional for group chats
|
|
|
|
class MessageCreate(MessageBase):
|
|
conversation_id: str
|
|
|
|
class MessageUpdate(BaseModel):
|
|
content: Optional[str] = None
|
|
is_read: Optional[bool] = None
|
|
|
|
class MessageInDBBase(MessageBase):
|
|
id: str
|
|
sender_id: str
|
|
conversation_id: str
|
|
is_read: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
class Message(MessageInDBBase):
|
|
pass
|
|
|
|
class MessageInDB(MessageInDBBase):
|
|
pass |