
- Complete FastAPI application with JWT authentication
- SQLite database with SQLAlchemy ORM and Alembic migrations
- User registration/login with secure password hashing
- Multi-cryptocurrency wallet system with balance tracking
- Advertisement system for buy/sell listings with fund locking
- Order management with automatic payment integration
- Payment provider API integration with mock fallback
- Automatic crypto release after payment confirmation
- Health monitoring endpoint and CORS configuration
- Comprehensive API documentation with OpenAPI/Swagger
- Database models for users, wallets, ads, orders, and payments
- Complete CRUD operations for all entities
- Security features including fund locking and order expiration
- Detailed README with setup and usage instructions
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, Enum, Text
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.db.base import Base
|
|
import enum
|
|
|
|
class AdType(str, enum.Enum):
|
|
BUY = "buy"
|
|
SELL = "sell"
|
|
|
|
class AdStatus(str, enum.Enum):
|
|
ACTIVE = "active"
|
|
INACTIVE = "inactive"
|
|
COMPLETED = "completed"
|
|
CANCELLED = "cancelled"
|
|
|
|
class Advertisement(Base):
|
|
__tablename__ = "advertisements"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
cryptocurrency_id = Column(Integer, ForeignKey("cryptocurrencies.id"), nullable=False)
|
|
ad_type = Column(Enum(AdType), nullable=False)
|
|
price = Column(Float, nullable=False) # Price per unit in fiat currency
|
|
min_order_amount = Column(Float, nullable=False)
|
|
max_order_amount = Column(Float, nullable=False)
|
|
available_amount = Column(Float, nullable=False) # Crypto amount available
|
|
payment_methods = Column(String, nullable=False) # JSON string of payment methods
|
|
terms_conditions = Column(Text)
|
|
status = Column(Enum(AdStatus), default=AdStatus.ACTIVE)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="advertisements")
|
|
cryptocurrency = relationship("Cryptocurrency", back_populates="advertisements")
|
|
orders = relationship("Order", back_populates="advertisement") |