Skip to content

algorithnicmind/Leaveflow-management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

220 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏒 Leaveflow Management System

A Premium, Role-Based Enterprise Employee Leave Management Platform

Next.js FastAPI PostgreSQL Python License


Digitize your leave workflows β€” from instant submissions to manager reviews β€” with secure role-based portals, automated validation constraints, beautiful dark-themed analytics, and structured database safety.

πŸš€ Quick Start Β· πŸ“– Interactive Portals & UI Β· πŸ—οΈ Architecture & Data Model Β· πŸ“Š System Workflows Β· πŸ”Œ API Directory Β· πŸ“‚ Codebase Directory


✨ Enterprise Portals by Role

The platform provides dedicated interfaces, operations, and dashboards tailored dynamically to four roles:

Role Access Level & Capabilities Primary Screens & Features
πŸ‘‘ Super Admin Platform Governance
Configures system-wide leave policy limits, registers administrative accounts, and generates organization-wide analytics reports.
System settings panel, admin registry portal, departmental distribution dashboards.
πŸ›‘οΈ Admin Organizational Directory Management
Creates and manages employee accounts, assigns departments, updates manager-report hierarchies, and deactivates accounts.
Employee CRUD dashboard, global activity stats overview.
πŸ‘” Manager Team Supervision
Audits, approves, or rejects pending leave requests from direct reports with commentary, and tracks team calendar availability.
Pending request manager queue, team availability overview grid.
πŸ‘€ Employee Personal Leave Sandbox
Applies for leaves (Casual, Sick, Earned, Maternity, Miscarriage, Unpaid) with real-time validation checks and cancels pending requests.
Interactive leave balance gauges, personal request history table, leave submission form.

🎨 Interactive Portals & UI Mockups

Below are structural representations of the user interface screens, exhibiting the custom-designed Dark Glassmorphism UI (#0a0b14 β†’ #0f1123) using electric indigo, emerald, amber, and rose accents.

πŸ‘€ Employee Dashboard Mockup

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LEAVEFLOW SYSTEM  β€’  EMPLOYEE PORTAL                                        [πŸ‘€ John]  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                        β”‚
β”‚  πŸ“Š Leave Balances (2026 Year Calendar)                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚ πŸ– CASUAL LEAVE       β”‚ β”‚ πŸ₯ SICK LEAVE         β”‚ β”‚ πŸ“… EARNED LEAVE       β”‚         β”‚
β”‚  β”‚  12 Days Allocated    β”‚ β”‚  12 Days Allocated    β”‚ β”‚  18 Days Allocated    β”‚         β”‚
β”‚  β”‚  [β– β– β– β– β– β– β–‘β–‘β–‘β–‘β–‘β–‘] 50%   β”‚ β”‚  [β– β– β– β– β– β– β– β– β– β– β–‘β–‘] 83%   β”‚ β”‚  [β– β– β– β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 16%  β”‚         β”‚
β”‚  β”‚  Remaining: 6 Days    β”‚ β”‚  Remaining: 2 Days    β”‚ β”‚  Remaining: 15 Days   β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚                                                                                        β”‚
β”‚  πŸ“‹ Recent Leave History                                           [+ Apply New Leave]  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Leave Type    Duration                     Days    Status        Actions         β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚ πŸ– Casual     Jun 15 - Jun 18, 2026        3 Days  ● Pending     [Cancel] [View] β”‚  β”‚
β”‚  β”‚ πŸ₯ Sick       May 10 - May 12, 2026        2 Days  ● Approved             [View] β”‚  β”‚
β”‚  β”‚ πŸ“… Earned     Apr 01 - Apr 05, 2026        4 Days  ● Rejected             [View] β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ‘” Manager Console Mockup

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LEAVEFLOW SYSTEM  β€’  MANAGER PORTAL                                        [πŸ‘” Alice] β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                        β”‚
β”‚  ⏳ Pending Approvals Queue                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Employee      Leave Type   Dates                   Duration   Reason      Status β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚ Jane Doe      πŸ– Casual    Jun 18 - Jun 20, 2026   2 Days     Family Trip ⏳Pendingβ”‚  β”‚
β”‚  β”‚ John Smith    πŸ“… Earned    Jul 01 - Jul 10, 2026   9 Days     Vacation    ⏳Pendingβ”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  Selected: Jane Doe  ───  Leave Type: Casual  ───  Duration: 2 Days                    β”‚  β”‚
β”‚  [πŸ’¬ Enter optional comments or rejection reason here...                           ]  β”‚
β”‚  [ βœ… Approve Request ]                             [ ❌ Reject Request ]              β”‚
β”‚                                                                                        β”‚
β”‚  πŸ“… Team Availability Grid (Current Week)                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Team Member   Mon 15     Tue 16     Wed 17     Thu 18     Fri 19                 β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚ Jane Doe      Active     Active     Active     [πŸ– LEAVE]  [πŸ– LEAVE]              β”‚  β”‚
β”‚  β”‚ John Smith    Active     Active     Active     Active     Active                 β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›‘οΈ Administrative Directory Mockup

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  LEAVEFLOW SYSTEM  β€’  ADMINISTRATIVE CONTROL                                [πŸ›‘οΈ Admin]  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                        β”‚
β”‚  πŸ‘₯ Employee Directory                                                [+ Add Employee]  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Name           Email                 Role        Department      Status   Actions    β”‚  β”‚
β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
β”‚  β”‚ John Doe       john@company.com      Employee    Engineering     ● Active [✏️] [πŸ—‘οΈ]   β”‚  β”‚
β”‚  β”‚ Alice Manager  alice@company.com     Manager     Engineering     ● Active [✏️] [πŸ—‘οΈ]   β”‚  β”‚
β”‚  β”‚ Jane Doe       jane@company.com      Employee    Design          ● Active [✏️] [πŸ—‘οΈ]   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                                        β”‚
β”‚  πŸ“Š System Stats Overview                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚  β”‚ Total Active Employees:  45 β”‚ β”‚ Active Out-of-Office Today: β”‚                       β”‚
β”‚  β”‚ Org Approved Leaves YTD: 214β”‚ β”‚ Pending Approvals in Queue: β”‚                       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—οΈ Architecture & Data Model

Leaveflow Management System is built on a clean three-tier structure to isolate browser operations, business transaction gateways, and secure persistent layers.

System Architecture Flowchart

graph TD
    %% Custom Styling
    classDef client fill:#1e1b4b,stroke:#4f46e5,stroke-width:2px,color:#fff;
    classDef proxy fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#fff;
    classDef backend fill:#1e293b,stroke:#64748b,stroke-width:2px,color:#fff;
    classDef db fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#fff;
    classDef security fill:#7f1d1d,stroke:#f43f5e,stroke-width:2px,color:#fff;

    Client["🌐 Next.js App Router Client<br/>(Tailored Dynamic Views)"]:::client
    Proxy["πŸ›‘οΈ Nginx Gateway / Reverse Proxy<br/>(SSL/TLS + Local Rate Limits)"]:::proxy
    API["βš™οΈ FastAPI REST Server<br/>(Business Logic Engine)"]:::backend
    DB["πŸ—„οΈ PostgreSQL Database<br/>(ACID Transactions)"]:::db
    JWT["πŸ” JWT Authentication & Guard<br/>(Role Middleware Check)"]:::security

    Client -->|HTTPS / JSON Requests| Proxy
    Proxy -->|Filtered Ports Clean Traffic| API
    API -->|Validates Token & Scope| JWT
    API -->|Async SQLAlchemy Query| DB

Loading

Entity Relationship (ER) Schema

The relational database layer enforces schema-level constraints to prevent duplicate entries, overlapping intervals, and incorrect roles.

erDiagram
    EMPLOYEES {
        int id PK
        string name
        string email UK
        string password_hash
        string role "super_admin, admin, manager, employee"
        int manager_id FK
        string department
        boolean is_active
        datetime created_at
    }
    LEAVE_REQUESTS {
        int id PK
        int employee_id FK
        string leave_type "casual, sick, earned, maternity, miscarriage, unpaid"
        date start_date
        date end_date
        text reason
        string status "pending, approved, rejected, cancelled"
        datetime created_at
        datetime updated_at
    }
    LEAVE_APPROVALS {
        int id PK
        int leave_request_id FK
        int manager_id FK
        string action "approved, rejected"
        text comments
        datetime acted_at
    }
    LEAVE_BALANCES {
        int id PK
        int employee_id FK
        string leave_type "casual, sick, earned, maternity, miscarriage"
        int total_days
        int used_days
        int year
    }

    EMPLOYEES ||--o{ LEAVE_REQUESTS : "applies_for"
    EMPLOYEES ||--o{ LEAVE_BALANCES : "allocated"
    EMPLOYEES ||--o| EMPLOYEES : "reports_to"
    LEAVE_REQUESTS ||--o| LEAVE_APPROVALS : "receives_action"
    EMPLOYEES ||--o{ LEAVE_APPROVALS : "audits_and_decides"
Loading

πŸ“Š System Workflows

1. Login & Role-Based Navigation

When a user logs in, their credential details are checked, a stateless JWT is produced, and the client routes them to the appropriate portal interface:

flowchart TD
    classDef default fill:#111326,stroke:#4f46e5,stroke-width:1px,color:#e8ecf4;
    classDef primary fill:#4f46e5,stroke:#7c3aed,stroke-width:1px,color:#fff;
    classDef success fill:#065f46,stroke:#10b981,stroke-width:1px,color:#fff;
    classDef warning fill:#78350f,stroke:#f59e0b,stroke-width:1px,color:#fff;
    classDef danger fill:#7f1d1d,stroke:#f43f5e,stroke-width:1px,color:#fff;

    Start[🌐 Open Web App] --> Login[πŸ” Login Page]:::primary
    Login --> Credentials[✍️ Enter Email & Password]
    Credentials --> AuthCheck{Verify API Authenticate}
    
    AuthCheck -->|Failed| FailMsg[❌ Show Bad Credentials]:::danger
    FailMsg --> Credentials
    
    AuthCheck -->|Success| TokenGen[πŸ” Return JWT Token + Role]:::success
    TokenGen --> RoleSplit{Read User Role}
    
    RoleSplit -->|employee| EmpDash[πŸ‘€ Employee Dashboard]
    RoleSplit -->|manager| MgrDash[πŸ‘” Manager Dashboard]
    RoleSplit -->|admin| AdminDash[πŸ›‘οΈ Admin Dashboard]
    RoleSplit -->|super_admin| SuperDash[πŸ‘‘ Super Admin Dashboard]
Loading

2. Leave Submission & Validation Cycle

When an employee applies for leave, the backend applies multiple strict validations before debiting balances and writing to database history:

flowchart TD
    classDef default fill:#111326,stroke:#4f46e5,stroke-width:1px,color:#e8ecf4;
    classDef primary fill:#4f46e5,stroke:#7c3aed,stroke-width:1px,color:#fff;
    classDef success fill:#065f46,stroke:#10b981,stroke-width:1px,color:#fff;
    classDef warning fill:#78350f,stroke:#f59e0b,stroke-width:1px,color:#fff;
    classDef danger fill:#7f1d1d,stroke:#f43f5e,stroke-width:1px,color:#fff;

    Init[πŸ“Š Employee Dashboard] --> Action[πŸ–±οΈ Click Apply Leave]
    Action --> Form[πŸ“‹ Fill Request Details]:::primary
    Form --> ValidRange{Is End Date >= Start Date?}
    
    ValidRange -->|No| ErrRange[❌ Invalid Date Range]:::danger
    ErrRange --> Form
    
    ValidRange -->|Yes| ValidToday{Is Start Date >= Today?}
    
    ValidToday -->|No| ErrPast[❌ Start Date cannot be in Past]:::danger
    ErrPast --> Form
    
    ValidToday -->|Yes| OverlapCheck{Is Calendar Free?<br/>No Overlapping Leaves}
    
    OverlapCheck -->|No| ErrOverlap[❌ Overlapping request exists]:::danger
    ErrOverlap --> Form
    
    OverlapCheck -->|Yes| BalanceCheck{Leave Unpaid OR<br/>Has Balance >= Requested?}
    
    BalanceCheck -->|No| ErrBalance[❌ Insufficient Leave Balance]:::danger
    ErrBalance --> Form
    
    BalanceCheck -->|Yes| Deduct[βš–οΈ Deduct Balance - Increment Used Days]:::warning
    Deduct --> Submit[πŸ“ Write Leave Request - Status: PENDING]:::success
    Submit --> Notify[πŸ‘” Notify Supervising Manager]
Loading

3. Manager Approval & Balance Restoration

A supervisor audits the leaves from direct reports. If approved, the status is finalized. If rejected, the balance is restored to the employee automatically:

flowchart TD
    classDef default fill:#111326,stroke:#4f46e5,stroke-width:1px,color:#e8ecf4;
    classDef primary fill:#4f46e5,stroke:#7c3aed,stroke-width:1px,color:#fff;
    classDef success fill:#065f46,stroke:#10b981,stroke-width:1px,color:#fff;
    classDef warning fill:#78350f,stroke:#f59e0b,stroke-width:1px,color:#fff;
    classDef danger fill:#7f1d1d,stroke:#f43f5e,stroke-width:1px,color:#fff;

    Start[πŸ“Š Manager Dashboard] --> Queue[πŸ“‹ View Pending Requests]:::primary
    Queue --> Detail[πŸ“„ Open Request Details]
    Detail --> Decision{Approve or Reject?}
    
    Decision -->|Approve| AppComment[πŸ’¬ Add Optional Comments]
    AppComment --> SaveApp[βœ… Status -> APPROVED]:::success
    SaveApp --> LogApp[πŸ“ Create LeaveApproval Row]
    
    Decision -->|Reject| RejComment[πŸ’¬ Add Mandatory Reason]:::danger
    RejComment --> SaveRej[❌ Status -> REJECTED]:::danger
    SaveRej --> Restore[πŸ”„ Restore Balance - Decrement Used Days]:::warning
    Restore --> LogRej[πŸ“ Create LeaveApproval Row]
    
    LogApp --> ClientUpdate[πŸ‘€ Employee Views Updated History]
    LogRej --> ClientUpdate
Loading

πŸ”Œ API Directory

Endpoint Method Security Level / Role Scope Description
/api/auth/login POST Public Authenticates credentials and returns dynamic role JSON + Bearer JWT.
/api/auth/register POST super_admin, admin Registers new administrator and managers in the database directory.
/api/employees GET super_admin, admin Retrieves organizational directory, filters by search query.
/api/employees POST super_admin, admin Inserts a new employee profile and generates default leave balances.
/api/employees/{id} PUT super_admin, admin Updates employee demographics, manager ID, and roles.
/api/employees/{id} DELETE super_admin, admin Sets is_active = False to prevent user login and clear hierarchies.
/api/leaves POST Authenticated (All) Submits a leave request, checks rules, and debits balances.
/api/leaves GET Authenticated (All) Fetches the employee's personal leave requests history.
/api/leaves/balance GET Authenticated (All) Retrieves active leave type balances (Total, Used, Remaining).
/api/leaves/{id}/cancel PUT Authenticated (All) Cancels pending request and refunds allocated days.
/api/leaves/pending GET super_admin, admin, manager Returns outstanding requests (scoped by manager ID or org-wide).
/api/leaves/{id}/approve PUT super_admin, admin, manager Approves request, adds comment, logs approval details.
/api/leaves/{id}/reject PUT super_admin, admin, manager Rejects request, requires rejection reason, refunds balance.
/api/dashboard/stats GET Authenticated (All) Computes role-specific counters, charts, and metadata.
/api/reports/organization GET super_admin Generates breakdown statistics by department and leave type.
/api/settings GET super_admin Gets system-wide baseline leaves allocation configuration.
/api/settings PUT super_admin Modifies global limits (Casual, Sick, Earned limits).

πŸ“‚ Codebase Directory

Leaveflow-management/
β”‚
β”œβ”€β”€ πŸ“ client/                        # 🌐 Next.js App Router Frontend
β”‚   β”œβ”€β”€ package.json                 #    Node packages configure
β”‚   β”œβ”€β”€ next.config.js               #    Next.js configuration parameters
β”‚   └── πŸ“ src/
β”‚       β”œβ”€β”€ πŸ“ app/                  #    App Router folders (Pages & Layouts)
β”‚       β”‚   β”œβ”€β”€ page.js              #    Landing Page
β”‚       β”‚   β”œβ”€β”€ layout.js            #    Global HTML Layout
β”‚       β”‚   β”œβ”€β”€ πŸ“ apply-leave/      #    Employee apply leave screen
β”‚       β”‚   β”œβ”€β”€ πŸ“ dashboard/        #    Custom dynamic Home Dashboard
β”‚       β”‚   β”œβ”€β”€ πŸ“ employees/        #    Admin Employee CRUD controller
β”‚       β”‚   β”œβ”€β”€ πŸ“ leave-history/    #    Employee list of requests
β”‚       β”‚   β”œβ”€β”€ πŸ“ login/            #    Login Form
β”‚       β”‚   β”œβ”€β”€ πŸ“ manage-admins/    #    Super admin portal settings
β”‚       β”‚   β”œβ”€β”€ πŸ“ organization-reports/  # Organization performance stats
β”‚       β”‚   β”œβ”€β”€ πŸ“ pending-requests/ #    Manager approval portal
β”‚       β”‚   β”œβ”€β”€ πŸ“ system-settings/  #    Super admin setup variables
β”‚       β”‚   └── πŸ“ team-overview/    #    Manager direct report calendar
β”‚       β”œβ”€β”€ πŸ“ components/           #    Reusable Glassmorphic elements
β”‚       β”œβ”€β”€ πŸ“ context/              #    Global Contexts (AuthContext provider)
β”‚       β”œβ”€β”€ πŸ“ lib/                  #    Shared helpers and constants
β”‚       β”œβ”€β”€ πŸ“ services/             #    Frontend API client integrations
β”‚       └── app.css                  #    Unified Design System styling
β”‚
β”œβ”€β”€ πŸ“ server/                        # 🐍 Python REST API (FastAPI Backend)
β”‚   β”œβ”€β”€ main.py                      #    Coordinator entrypoint & Demo Auto-seeding
β”‚   β”œβ”€β”€ requirements.txt             #    Pip dependencies
β”‚   β”œβ”€β”€ πŸ“ app/
β”‚   β”‚   β”œβ”€β”€ πŸ“ core/                 #    Cross-cutting configurations
β”‚   β”‚   β”‚   β”œβ”€β”€ config.py            #    Environment Variable settings
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py          #    Async Session and engine configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ dependencies.py      #    JWT validation and role checker filters
β”‚   β”‚   β”‚   └── security.py          #    Bcrypt utilities
β”‚   β”‚   └── πŸ“ modules/              #    Feature modules (Repository-Service Pattern)
β”‚   β”‚       β”œβ”€β”€ πŸ“ auth/             #    User authorization services
β”‚   β”‚       β”œβ”€β”€ πŸ“ dashboard/        #    Consolidated dashboard API
β”‚   β”‚       β”œβ”€β”€ πŸ“ employees/        #    Staff directory services
β”‚   β”‚       β”œβ”€β”€ πŸ“ leaves/           #    Core leave engines
β”‚   β”‚       β”œβ”€β”€ πŸ“ reports/          #    Super admin org statistics
β”‚   β”‚       └── πŸ“ settings/         #    Global limit settings
β”‚   └── πŸ“ db/
β”‚       └── seed.py                  #    Database seeder script (Drop & Rebuilds schema)
β”‚
β”œβ”€β”€ πŸ“ docs/                          # πŸ“– Detailed Architectural Docs
└── README.md                         # ← You are here!

πŸš€ Quick Start

Prerequisites

Installation & Launch

1. Setup the Database

Create a new Postgres instance:

createdb leave_management

2. Startup Backend API (FastAPI)

# Enter server directory
cd server

# Setup virtual environment
python -m venv venv

# Activate Virtual Environment:
# On Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# On macOS / Linux:
source venv/bin/activate

# Install package dependencies
pip install -r requirements.txt

# Configure environment settings:
# Create a .env file and set DATABASE_URL (Async pg driver) + JWT_SECRET
# e.g., DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/leave_management
# e.g., JWT_SECRET=supersecretkeyshouldbechangedinproduction

# Run database seeder (seeds all default test credentials below)
python db/seed.py

# Launch FastAPI ASGI dev server
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

3. Startup Frontend (Next.js)

# Open a new terminal in the project root directory
cd client

# Install packages
npm install

# Configure environment settings:
# Create a .env.local file and set NEXT_PUBLIC_API_URL
# e.g., NEXT_PUBLIC_API_URL=http://localhost:8000

# Launch Next.js dev server
npm run dev

🌐 Ports & Documentation


πŸ”‘ Demo Credentials

All passwords default to password123. You can reset the database and seed these accounts by running python db/seed.py.

Role Email Password Scope & Responsibilities
πŸ‘‘ Super Admin superadmin@company.com password123 Configures system-wide settings, reviews organization charts.
πŸ›‘οΈ Admin admin@company.com password123 Adds/modifies employee directory entries and manager links.
πŸ‘” Manager alice@company.com password123 Engineering manager (direct reports: John Doe).
πŸ‘” Manager bob@company.com password123 Design manager (direct reports: Jane Doe).
πŸ‘€ Employee john@company.com password123 Applies for leaves, reports to Alice.
πŸ‘€ Employee jane@company.com password123 Applies for leaves, reports to Bob.

πŸ›‘οΈ Security Implementations

  • Gateway Shields: Built-in CORS configuration to restrict backend resource consumption to authorized client Origins.
  • Stateless Auth: Enforces JWT token authorization filters with Bcrypt cryptography hashing for login keys.
  • Parameter Validation: Restricts SQL injection vulnerability using async SQLAlchemy parameterized queries.
  • Business Safe Rails: Employs backend check boundaries and schema Constraints to lock leave applications against invalid dates, overlaps, and negative balances.

About

A Modern, Role-Based Employee Leave Management Platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors