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

43 lines
946 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.cart import router as cart_router
from app.db.session import engine
from app.db.base import Base
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Cart and Checkout System",
description="A simple cart and checkout system API",
version="1.0.0",
openapi_url="/openapi.json",
)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(cart_router, prefix="/api/v1", tags=["Cart"])
@app.get("/")
async def root():
return {
"title": "Cart and Checkout System",
"documentation": "/docs",
"health": "/health",
}
@app.get("/health")
async def health_check():
return {"status": "healthy", "service": "cart-checkout-system"}