
- Created FastAPI application structure with SQLAlchemy and Alembic - Implemented full CRUD operations for inventory items - Added search, filtering, and pagination capabilities - Configured CORS, API documentation, and health endpoints - Set up SQLite database with proper migrations - Added comprehensive API documentation and README
40 lines
1009 B
Python
40 lines
1009 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
from app.api.inventory import router as inventory_router
|
|
|
|
app = FastAPI(
|
|
title="Inventory Management API",
|
|
description="A comprehensive inventory management system",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(inventory_router, prefix="/api/v1/inventory", tags=["inventory"])
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"title": "Inventory Management API",
|
|
"description": "A comprehensive inventory management system",
|
|
"version": "1.0.0",
|
|
"documentation": "/docs",
|
|
"health_check": "/health"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {
|
|
"status": "healthy",
|
|
"message": "Inventory Management API is running properly"
|
|
} |