
- FastAPI application with JWT authentication and role-based access control - Complete employee management with CRUD operations - Department management with manager assignments - Leave management system with approval workflow - Payroll processing with overtime and deductions calculation - Attendance tracking with clock in/out functionality - SQLite database with proper migrations using Alembic - Role-based permissions (Admin, HR Manager, Manager, Employee) - Comprehensive API documentation and health checks - CORS enabled for cross-origin requests Environment Variables Required: - SECRET_KEY: JWT secret key for token signing Features implemented: - User registration and authentication - Employee profile management - Department hierarchy management - Leave request creation and approval - Payroll record processing - Daily attendance tracking - Hours calculation for attendance - Proper error handling and validation
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
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"} |