"""GUARDiA Manager 경량 백엔드 API — 포트 8002"""
import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv

load_dotenv()

app = FastAPI(title="GUARDiA Manager API", version="1.0.0")

app.add_middleware(
    CORSMiddleware,
    allow_origins=os.environ.get(
        "MANAGER_ALLOWED_ORIGINS",
        "http://localhost:5175,http://localhost:5173,http://zioinfo.co.kr:8090"
    ).split(","),
    allow_methods=["*"],
    allow_headers=["*"],
    allow_credentials=True,
)

from routers import system, deploy, config, llm
app.include_router(system.router, prefix="/api/system",  tags=["system"])
app.include_router(deploy.router, prefix="/api/deploy",  tags=["deploy"])
app.include_router(config.router, prefix="/api/config",  tags=["config"])
app.include_router(llm.router,    prefix="/api/llm",     tags=["llm"])

@app.get("/health")
async def health():
    return {"status": "ok", "service": "guardia-manager", "port": 8002}
