from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.api import books, inventory, orders from app.db.session import engine app = FastAPI( title="Bookstore Management API", description="A comprehensive REST API for managing a bookstore with inventory and payment processing", version="1.0.0", openapi_url="/openapi.json" ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router(books.router, prefix="/api/v1") app.include_router(inventory.router, prefix="/api/v1") app.include_router(orders.router, prefix="/api/v1") @app.on_event("startup") def create_tables(): from app.db.base import Base Base.metadata.create_all(bind=engine) @app.get("/") def root(): return { "title": "Bookstore Management API", "description": "A comprehensive REST API for managing a bookstore with inventory and payment processing", "documentation": "/docs", "health_check": "/health" } @app.get("/health") def health_check(): return { "status": "healthy", "service": "Bookstore Management API", "version": "1.0.0" }