
- Set up FastAPI application structure - Create database models for User, Product, Cart, CartItem, Order, and OrderItem - Set up Alembic for database migrations - Create Pydantic schemas for request/response models - Implement API endpoints for products, cart operations, and checkout process - Add health endpoint - Update README with project details and documentation
19 lines
811 B
Python
19 lines
811 B
Python
from sqlalchemy import Column, String, Numeric, Boolean, Text, Integer
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.models.base import BaseModel, TimestampMixin
|
|
|
|
|
|
class Product(BaseModel, TimestampMixin):
|
|
"""Product model for items that can be purchased."""
|
|
name = Column(String, index=True, nullable=False)
|
|
description = Column(Text)
|
|
price = Column(Numeric(10, 2), nullable=False) # Supports prices up to 99,999,999.99
|
|
sku = Column(String, unique=True, index=True, nullable=False)
|
|
stock_quantity = Column(Integer, nullable=False, default=0)
|
|
is_active = Column(Boolean, default=True)
|
|
image_url = Column(String)
|
|
|
|
# Relationships
|
|
cart_items = relationship("CartItem", back_populates="product")
|
|
order_items = relationship("OrderItem", back_populates="product") |