
- Set up project structure with FastAPI and SQLite - Implement user authentication with JWT - Create database models for users, events, bets, and transactions - Add API endpoints for user management - Add API endpoints for events and betting functionality - Add wallet management for deposits and withdrawals - Configure Alembic for database migrations - Add linting with Ruff - Add documentation in README
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from enum import Enum as PyEnum
|
|
|
|
from sqlalchemy import Column, DateTime, Enum, Float, ForeignKey, Integer
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class BetStatus(str, PyEnum):
|
|
PENDING = "pending"
|
|
WON = "won"
|
|
LOST = "lost"
|
|
CANCELLED = "cancelled"
|
|
VOIDED = "voided"
|
|
|
|
|
|
class Bet(Base):
|
|
__tablename__ = "bets"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
outcome_id = Column(Integer, ForeignKey("outcomes.id"), nullable=False)
|
|
amount = Column(Float, nullable=False)
|
|
odds = Column(Float, nullable=False) # Stored odds at time of bet
|
|
potential_win = Column(Float, nullable=False)
|
|
status = Column(Enum(BetStatus), default=BetStatus.PENDING)
|
|
settled_at = Column(DateTime(timezone=True), nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="bets")
|
|
outcome = relationship("Outcome", back_populates="bets") |