Automated Action 16cfcd783e Build Chat Application Backend with FastAPI and SQLite
- 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)
2025-05-12 16:37:35 +00:00

20 lines
930 B
Python

from sqlalchemy import Boolean, Column, String, DateTime, func
from sqlalchemy.orm import relationship
from app.db.session import Base
class User(Base):
__tablename__ = "users"
id = Column(String, primary_key=True, index=True)
username = Column(String, unique=True, index=True)
email = Column(String, unique=True, index=True)
hashed_password = Column(String)
is_active = Column(Boolean, default=True)
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
# Relationships
messages_sent = relationship("Message", back_populates="sender", foreign_keys="Message.sender_id")
messages_received = relationship("Message", back_populates="recipient", foreign_keys="Message.recipient_id")
conversations = relationship("Conversation", secondary="conversation_participants", back_populates="participants")