from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.routers import auth, employees, departments, leaves, payroll, attendance from app.db.session import engine from app.db.base import Base # Create database tables Base.metadata.create_all(bind=engine) app = FastAPI( title="HR Management System", description="A comprehensive HR management backend system", version="1.0.0", openapi_url="/openapi.json" ) # CORS configuration app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include routers app.include_router(auth.router, prefix="/auth", tags=["Authentication"]) app.include_router(employees.router, prefix="/employees", tags=["Employees"]) app.include_router(departments.router, prefix="/departments", tags=["Departments"]) app.include_router(leaves.router, prefix="/leaves", tags=["Leave Management"]) app.include_router(payroll.router, prefix="/payroll", tags=["Payroll"]) app.include_router(attendance.router, prefix="/attendance", tags=["Attendance"]) @app.get("/") async def root(): return { "title": "HR Management System", "description": "A comprehensive HR management backend system", "documentation": "/docs", "health_check": "/health" } @app.get("/health") async def health_check(): return {"status": "healthy", "service": "HR Management Backend"}