Automated Action e04059c1e3 Implement FastAPI cart and checkout system
- Created FastAPI application with SQLite database
- Implemented cart management (create, get, add items, remove items, clear)
- Added checkout functionality with payment processing simulation
- Set up database models using SQLAlchemy with Cart and CartItem tables
- Configured Alembic for database migrations
- Added comprehensive API documentation and examples
- Included health endpoint and CORS support
- Formatted code with ruff linting
2025-07-21 09:20:12 +00:00

52 lines
926 B
Python

from typing import List, Optional
from pydantic import BaseModel
from datetime import datetime
class CartItemCreate(BaseModel):
product_id: str
product_name: str
price: float
quantity: int
class CartItemResponse(BaseModel):
id: int
product_id: str
product_name: str
price: float
quantity: int
class Config:
from_attributes = True
class CartCreate(BaseModel):
user_id: str
class CartResponse(BaseModel):
id: int
user_id: Optional[str]
status: str
created_at: datetime
updated_at: datetime
items: List[CartItemResponse] = []
total: Optional[float] = None
class Config:
from_attributes = True
class CheckoutRequest(BaseModel):
cart_id: int
payment_method: str
billing_address: dict
class CheckoutResponse(BaseModel):
success: bool
order_id: Optional[str] = None
total_amount: float
message: str