Add Polaris FastAPI backend: models/schemas, pricing+scoring+order router, importer, Celery tasks, API routers, seed script
This commit is contained in:
38
backend/app/main.py
Normal file
38
backend/app/main.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Polaris FastAPI application.
|
||||
|
||||
CORS allow-all (MVP). Routers mounted under /api exactly as the contract lists.
|
||||
"""
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.database import Base, engine
|
||||
from app.routers import admin, analytics, auth, customers, health, orders, products, suppliers
|
||||
from app.version import VERSION
|
||||
|
||||
# Idempotent — schema.sql is canonical and already applied; create_all only
|
||||
# creates anything missing.
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
app = FastAPI(title="Polaris API", version=VERSION)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(health.router, prefix="/api", tags=["health"])
|
||||
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
||||
app.include_router(products.router, prefix="/api/products", tags=["products"])
|
||||
app.include_router(suppliers.router, prefix="/api/suppliers", tags=["suppliers"])
|
||||
app.include_router(orders.router, prefix="/api/orders", tags=["orders"])
|
||||
app.include_router(customers.router, prefix="/api/customers", tags=["customers"])
|
||||
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|
||||
app.include_router(analytics.router, prefix="/api/analytics", tags=["analytics"])
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"app": "polaris", "version": VERSION, "docs": "/docs"}
|
||||
Reference in New Issue
Block a user