Skip to content

The Leave Management System uses a classic layered architecture. The frontend is built with HTML templates rendered by Jinja2 through FastAPI, delivering a dynamic UI through the browser.

Notifications You must be signed in to change notification settings

Flinzb/leave_management_app

Repository files navigation

Leave Management System

Project Overview

This is a FastAPI-based Leave Management System designed to help employees apply for leave, view leave balances, and enable managers to approve or reject leave requests.


Setup Instructions

  1. Clone the repository.
  2. Create a Python virtual environment:

python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows 3. Install dependencies: pip install -r requirements.txt

  1. Initialize the database (example with SQLite): alembic upgrade head # if using Alembic migrations, or python backend/database_setup.py # custom setup script if any

  2. Run the FastAPI app: uvicorn backend.app:app --reload

  3. Access the app at http://localhost:8000


Assumptions

  • Each employee is uniquely identified by employee ID.
  • Leave requests must be non-overlapping (checks for pending or approved leaves).
  • Employees have a fixed total leave balance starting at 20 days.
  • Leave balance reduces only after managerial approval.

Edge Cases Handled

  • Invalid employee IDs return 404 errors.
  • Leaves cannot be applied before the employee's joining date.
  • Leaves cannot have end dates before start dates.
  • Leaves cannot be applied for past dates.
  • Overlapping leaves (pending or approved) are disallowed.
  • Rejecting leaves does not reduce leave balance.
  • Leave balance queries filter by employee correctly.

Potential Improvements

  • Implementing asynchronous endpoints for improved scalability.
  • Adding Redis caching for frequently requested data such as leave balances.
  • Adding user authentication and role-based access controls (employee, manager).
  • Pagination on employees and leave request listings for large datasets.
  • Containerize the application with Docker for easier deployment and scaling.
  • Adding unit and integration tests.

API Endpoints and Examples

Endpoint Method Description Sample Input Sample Output
/apply-leave POST Apply for leave { "employee_id": 1, "start_date": "2025-08-25", "end_date": "2025-08-27", "reason": "Vacation" } { "id": 123, "status": "Pending" }
/approve-leave/{leave_id} POST Approve leave request N/A { "message": "Leave approved." }
/reject-leave/{leave_id} POST Reject leave request N/A { "message": "Leave rejected." }
/leave-balance GET Get leave balance by employee query param /leave-balance?employee_id=1 { "employee_id": 1, "leave_balance": 17 }

alt text

alt text

High-Level Design Diagram

alt text The system consists of a browser-based frontend rendering Jinja2 templates served by the FastAPI backend, which manages business logic and communicates with a SQL database via SQLAlchemy ORM. The application supports scalability through load balancing, connection pooling, and caching.)*


Contact

For questions or contributions, contact: your.email@example.com

About

The Leave Management System uses a classic layered architecture. The frontend is built with HTML templates rendered by Jinja2 through FastAPI, delivering a dynamic UI through the browser.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages