
- Set up FastAPI application with CORS and health check endpoint - Create SQLite database models for inventory items, categories, and suppliers - Implement complete CRUD API endpoints for all entities - Add low-stock monitoring functionality - Configure Alembic for database migrations - Set up Ruff for code linting and formatting - Include comprehensive API documentation and README
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.routers import categories, inventory, suppliers
|
|
|
|
app = FastAPI(
|
|
title="Small Business Inventory System",
|
|
description="A comprehensive inventory management system for small businesses",
|
|
version="1.0.0"
|
|
)
|
|
|
|
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.include_router(suppliers.router, prefix="/api/v1/suppliers", tags=["suppliers"])
|
|
app.include_router(categories.router, prefix="/api/v1/categories", tags=["categories"])
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"title": "Small Business Inventory System",
|
|
"documentation": "/docs",
|
|
"health": "/health"
|
|
}
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy", "service": "inventory-system"}
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|