from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.database import engine, Base
from app.api import auth, habits, health, messages, admin, tasks

app = FastAPI(title="Vida180 API")

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

Base.metadata.create_all(bind=engine)

app.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
app.include_router(habits.router, prefix="/api/v1/habits", tags=["habits"])
app.include_router(health.router, prefix="/api/v1/health", tags=["health"])
app.include_router(messages.router, prefix="/api/v1/messages", tags=["messages"])
app.include_router(admin.router, prefix="/api/v1/admin", tags=["admin"])
app.include_router(tasks.router, prefix="/api/v1/tasks", tags=["tasks"])

@app.get("/")
def root():
    return {"message": "Vida180 API"}
