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
The platform features a completely Dynamic Role Architecture. Organizations can create custom roles mapped to fixed system permissions (e.g., manage_settings, manage_employees, approve_leaves). Typical configurations map to the following core personas:
| 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. |
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.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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] β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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: β β
β βββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Leaveflow Management System is built on a clean three-tier structure to isolate browser operations, business transaction gateways, and secure persistent layers.
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
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"
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 + Permissions]:::success
TokenGen --> RoleSplit{Check User Permissions}
RoleSplit -->|Basic Auth| EmpDash[π€ Employee Dashboard]
RoleSplit -->|approve_leaves| MgrDash[π Manager Dashboard]
RoleSplit -->|manage_settings| AdminDash[π‘οΈ Admin Dashboard]
RoleSplit -->|Tenant Owner| SuperDash[π Super Admin Dashboard]
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]
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
| 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). |
Leaveflow-management/
β
βββ π client/ # Next.js App Router Frontend - Contains all user interface code
β βββ π __tests__/ # Directory
β β βββ π app/ # Next.js App Router folders (Pages & Layouts)
β β β βββ π apply-leave/ # Directory
β β β β βββ page.test.js # Frontend unit/integration tests
β β β βββ π dashboard/ # Directory
β β β β βββ page.test.js # Frontend unit/integration tests
β β β βββ π login/ # Directory
β β β βββ page.test.js # Frontend unit/integration tests
β β βββ π context/ # Directory
β β β βββ AuthContext.test.js # Frontend unit/integration tests
β β β βββ NotificationContex... # Project file
β β βββ π lib/ # Shared utility functions and helpers
β β β βββ utils.test.js # Frontend unit/integration tests
β β βββ π services/ # API client integrators for fetching backend data
β β βββ api.test.js # Frontend unit/integration tests
β βββ π public/ # Static assets like images and favicons
β β βββ assets # Project file
β β βββ favicon.ico # Project file
β β βββ favicon.png # Project file
β β βββ logo.png # Project file
β βββ π src/ # Source code root for the frontend
β β βββ π app/ # Next.js App Router folders (Pages & Layouts)
β β β βββ π (protected)/ # Protected routes requiring authentication
β β β β βββ π apply-leave/ # Directory
β β β β β βββ page.js # Form page for submitting leave requests
β β β β βββ π audit-logs/ # Directory
β β β β β βββ page.js # Next.js page route component
β β β β βββ π dashboard/ # Directory
β β β β β βββ page.js # Main dashboard view with stats
β β β β βββ π employees/ # Directory
β β β β β βββ page.js # Next.js page route component
β β β β βββ π leads/ # Directory
β β β β β βββ π [id]/ # Directory
β β β β β β βββ page.js # Next.js page route component
β β β β β βββ page.js # Next.js page route component
β β β β βββ π leave-history/ # Directory
β β β β β βββ pa... # Project file
β β β β βββ π manage-admins/ # Directory
β β β β β βββ pa... # Project file
β β β β βββ π organizations/ # Directory
β β β β β βββ [i... # Project file
β β β β β βββ [id] # Project file
β β β β β βββ pa... # Project file
β β β β βββ π owner-contacts/ # Directory
β β β β β βββ p... # Project file
β β β β βββ π platform-owners/ # Directory
β β β β β βββ ... # Project file
β β β β βββ π system-settings/ # Directory
β β β β β βββ ... # Project file
β β β β βββ π team-overview/ # Directory
β β β β β βββ pa... # Project file
β β β β βββ π tenants/ # Directory
β β β β β βββ π [id]/ # Directory
β β β β β β βββ das... # Project file
β β β β β β βββ pag... # Project file
β β β β β βββ page.js # Next.js page route component
β β β β βββ account-settings # Project file
β β β β βββ account-settings... # Project file
β β β β βββ layout.js # Next.js layout wrapper for consistent UI
β β β β βββ organization-rep... # Project file
β β β β βββ pending-requests # Project file
β β β β βββ pending-requests... # Project file
β β β βββ π login/ # Directory
β β β β βββ page.js # Login screen for all users
β β β βββ layout.js # Next.js layout wrapper for consistent UI
β β β βββ page.js # Next.js page route component
β β βββ π components/ # Reusable React components
β β β βββ π Chatbot/ # Directory
β β β β βββ ChatInput.js # JavaScript source code
β β β β βββ Chatbot.js # JavaScript source code
β β β β βββ ChatbotHeader.js # JavaScript source code
β β β β βββ FloatingButto... # Project file
β β β β βββ MessageList.js # JavaScript source code
β β β β βββ SuggestionChi... # Project file
β β β βββ π Landing/ # Directory
β β β β βββ ContactSectio... # Project file
β β β β βββ FeatureGrid.js # JavaScript source code
β β β β βββ FloatingNav.js # JavaScript source code
β β β β βββ HeroSection.js # JavaScript source code
β β β β βββ PricingSectio... # Project file
β β β β βββ SolutionsSect... # Project file
β β β βββ π Layout/ # Directory
β β β β βββ π Header/ # Directory
β β β β β βββ Notific... # Project file
β β β β β βββ Organiz... # Project file
β β β β β βββ Profile... # Project file
β β β β β βββ ThemeTo... # Project file
β β β β βββ Header.js # JavaScript source code
β β β β βββ LiveClock.js # JavaScript source code
β β β β βββ Sidebar.js # JavaScript source code
β β β β βββ index.js # JavaScript source code
β β β βββ π shared/ # Directory
β β β β βββ LeaveTypeIcon.js # JavaScript source code
β β β β βββ index.js # JavaScript source code
β β β βββ π ui/ # Atomic UI components (Buttons, Cards, Modals)
β β β β βββ Badge.js # JavaScript source code
β β β β βββ Button.js # Reusable Button component
β β β β βββ Card.js # Reusable Card container component
β β β β βββ Modal.js # Reusable Modal dialog component
β β β β βββ StatCard.js # JavaScript source code
β β β β βββ index.js # JavaScript source code
β β β βββ AppleEmoji.js # JavaScript source code
β β β βββ ErrorBoundary.js # JavaScript source code
β β β βββ LeadModal.js # JavaScript source code
β β β βββ OnboardingModal.js # JavaScript source code
β β β βββ index.js # JavaScript source code
β β βββ π config/ # Directory
β β β βββ constants.js # JavaScript source code
β β β βββ index.js # JavaScript source code
β β β βββ navigation.js # JavaScript source code
β β βββ π context/ # Directory
β β β βββ NotificationContext.js # JavaScript source code
β β β βββ index.js # JavaScript source code
β β βββ π features/ # Domain-specific feature modules (e.g., auth, leaves)
β β β βββ π audit/ # Directory
β β β β βββ AuditLogsPage.js # JavaScript source code
β β β βββ π auth/ # Authentication, login, and authorization logic
β β β β βββ π login/ # Authentication, login, and authorization logic
β β β β β βββ LoginForm.js # JavaScript source code
β β β β βββ AuthContext.js # Global React context for managing user session
β β β β βββ AuthGuard.js # JavaScript source code
β β β β βββ index.js # JavaScript source code
β β β βββ π contact/ # Directory
β β β β βββ OwnerContactsPa... # Project file
β β β βββ π dashboard/ # Dashboard stats and widgets
β β β β βββ DashboardPage.js # JavaScript source code
β β β β βββ components # Project file
β β β βββ π employees/ # Employee directory and management
β β β β βββ EmployeesPage.js # JavaScript source code
β β β β βββ ManageAdminsP... # Project file
β β β β βββ TeamOverviewP... # Project file
β β β βββ π leads/ # Directory
β β β β βββ LeadDetailsPage.js # JavaScript source code
β β β β βββ LeadsPage.js # JavaScript source code
β β β βββ π leaves/ # Leave request creation and management
β β β β βββ π apply/ # Leave request creation and management
β β β β β βββ ApplyLeave... # Project file
β β β β βββ π history/ # Leave request creation and management
β β β β β βββ LeaveHis... # Project file
β β β β βββ π pending/ # Leave request creation and management
β β β β βββ PendingR... # Project file
β β β βββ π organizations/ # Tenant organization management (Platform Owner)
β β β β βββ Organizat... # Project file
β β β βββ π platform-owners/ # Directory
β β β β βββ Platfor... # Project file
β β β βββ π reports/ # Directory
β β β β βββ OrganizationRep... # Project file
β β β βββ π settings/ # System configuration settings
β β β β βββ AccountSetting... # Project file
β β β β βββ SystemSettings... # Project file
β β β βββ π tenants/ # Tenant provisioning and onboarding
β β β βββ TenantDashboard... # Project file
β β β βββ TenantDetailsPa... # Project file
β β β βββ TenantsPage.js # JavaScript source code
β β βββ π hooks/ # Directory
β β β βββ index.js # JavaScript source code
β β β βββ useTheme.js # JavaScript source code
β β βββ π lib/ # Shared utility functions and helpers
β β β βββ constants.js # JavaScript source code
β β β βββ index.js # JavaScript source code
β β β βββ utils.js # JavaScript source code
β β βββ π services/ # API client integrators for fetching backend data
β β β βββ api.js # Centralized frontend API definitions connecting to backend
β β β βββ index.js # JavaScript source code
β β βββ app.css # Global application styling and Tailwind/CSS variables
β βββ .env.local # Project file
β βββ .prettierrc # Project file
β βββ crop_favicon.js # JavaScript source code
β βββ jest.config.js # JavaScript source code
β βββ jest.setup.js # JavaScript source code
β βββ jsconfig.json # JSON configuration data
β βββ next-env.d.ts # Project file
β βββ next.config.js # Next.js compilation and framework settings
β βββ package-lock.json # JSON configuration data
β βββ package.json # Node dependencies and scripts
β βββ postcss.config.mjs # Project file
β βββ remove_bg.js # JavaScript source code
β βββ test-emojis.js # JavaScript source code
β βββ tsconfig.json # JSON configuration data
βββ π docs/ # Detailed Architectural and Planning Documentation
β βββ π task/ # Directory
β β βββ task.md # Markdown documentation file
β βββ 01-PRD.md # Markdown documentation file
β βββ 02-TRD.md # Markdown documentation file
β βββ 03-User-Stories.md # Markdown documentation file
β βββ 04-User-Flows.md # Markdown documentation file
β βββ 05-HLD.md # Markdown documentation file
β βββ 06-LLD.md # Markdown documentation file
β βββ 06a-Database-Design.md # Markdown documentation file
β βββ 07-API-Documentation.md # Markdown documentation file
β βββ 08-Wireframes.md # Markdown documentation file
β βββ 10-Sprint-Tracker.md # Markdown documentation file
βββ π server/ # FastAPI Backend - Contains all business logic and database models
β βββ π app/ # Next.js App Router folders (Pages & Layouts)
β β βββ π core/ # Cross-cutting backend configurations (DB, security)
β β β βββ __init__.py # Python source code
β β β βββ config.py # Environment variable loading and configuration
β β β βββ database.py # SQLAlchemy async database engine setup
β β β βββ dependencies.py # Python source code
β β β βββ security.py # Python source code
β β β βββ tenant.py # Python source code
β β β βββ utils.py # Python source code
β β βββ π modules/ # Backend feature modules (Repository-Service Pattern)
β β β βββ π audit/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π auth/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ repositories.py # Database querying and transaction layer
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π contact/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β βββ π dashboard/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π employees/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ repositories.py # Database querying and transaction layer
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π integrations/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ calendar_se... # Project file
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ services.py # Business logic and service layer
β β β βββ π leaves/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ cron.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ repositories.py # Database querying and transaction layer
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π notifications/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β βββ π onboarding/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ repositories.py # Database querying and transaction layer
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ services.py # Business logic and service layer
β β β βββ π organizations/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ repositori... # Project file
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π reports/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β βββ π settings/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ models.py # SQLAlchemy ORM database table definitions
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β β βββ schemas.py # Pydantic models for request/response validation
β β β β βββ services.py # Business logic and service layer
β β β βββ π uploads/ # Directory
β β β β βββ __init__.py # Python source code
β β β β βββ routes.py # FastAPI HTTP endpoint definitions
β β β βββ __init__.py # Python source code
β β βββ __init__.py # Python source code
β βββ π bot/ # AI Chatbot service for answering employee queries
β β βββ __init__.py # Python source code
β β βββ actions.py # Python source code
β β βββ llm.py # Python source code
β β βββ policies.py # Python source code
β β βββ router.py # Python source code
β β βββ schemas.py # Pydantic models for request/response validation
β β βββ service.py # Python source code
β βββ π migrations/ # Alembic database schema migration scripts
β β βββ π versions/ # Directory
β β β βββ c73b5aa6ffd4_rem... # Project file
β β β βββ f7304259f1a9_ini... # Project file
β β βββ README # Project file
β β βββ env.py # Python source code
β β βββ script.py.mako # Project file
β βββ .env # Project file
β βββ alembic.ini # Project file
β βββ main.py # FastAPI application entry point and server startup
β βββ requirements.txt # Python pip dependencies
βββ π test/ # Comprehensive test suite for the backend
β βββ π .pytest_cache/ # Directory
β β βββ π v/ # Directory
β β β βββ π cache/ # Directory
β β β βββ lastfailed # Project file
β β β βββ nodeids # Project file
β β βββ .gitignore # Files excluded from git version control
β β βββ CACHEDIR.TAG # Project file
β β βββ README.md # Main project documentation and quick start guide
β βββ π e2e/ # Directory
β β βββ __init__.py # Python source code
β β βββ test_admin_employee_flow.py # Automated test cases
β β βββ test_employee_leave_flow.py # Automated test cases
β β βββ test_leave_cancel_flow.py # Automated test cases
β β βββ test_leave_rejection_flow.py # Automated test cases
β β βββ test_notification_flow.py # Automated test cases
β βββ π fixtures/ # Directory
β β βββ __init__.py # Python source code
β β βββ database.py # SQLAlchemy async database engine setup
β β βββ leaves.py # Python source code
β β βββ notifications.py # Python source code
β β βββ settings.py # Python source code
β β βββ users.py # Python source code
β βββ π integration/ # Directory
β β βββ π auth/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_login.py # Automated test cases
β β β βββ test_register.py # Automated test cases
β β βββ π dashboard/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_dashboard_s... # Automated test cases
β β βββ π employees/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_create_empl... # Automated test cases
β β β βββ test_deactivate_... # Automated test cases
β β β βββ test_list_employ... # Automated test cases
β β β βββ test_update_empl... # Automated test cases
β β βββ π leaves/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_apply_leave.py # Automated test cases
β β β βββ test_approve_leave.py # Automated test cases
β β β βββ test_cancel_leave.py # Automated test cases
β β β βββ test_leave_balance.py # Automated test cases
β β β βββ test_leave_history.py # Automated test cases
β β β βββ test_pending_reques... # Automated test cases
β β β βββ test_reject_leave.py # Automated test cases
β β βββ π notifications/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_list_no... # Automated test cases
β β β βββ test_mark_al... # Automated test cases
β β β βββ test_mark_re... # Automated test cases
β β βββ π reports/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_org_report.py # Automated test cases
β β βββ π settings/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_get_settings.py # Automated test cases
β β β βββ test_update_setti... # Automated test cases
β β βββ __init__.py # Python source code
β βββ π performance/ # Directory
β β βββ __init__.py # Python source code
β β βββ test_dashboard_load.py # Automated test cases
β β βββ test_employee_list_load.py # Automated test cases
β β βββ test_leave_apply_load.py # Automated test cases
β β βββ test_login_load.py # Automated test cases
β βββ π unit/ # Directory
β β βββ π auth/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_auth_service.py # Automated test cases
β β β βββ test_security.py # Automated test cases
β β βββ π dashboard/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_dashboard_service.py # Automated test cases
β β βββ π employees/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_employee_repositor... # Automated test cases
β β β βββ test_employee_service.py # Automated test cases
β β βββ π leaves/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_leave_repository.py # Automated test cases
β β β βββ test_leave_service.py # Automated test cases
β β β βββ test_leave_validators.py # Automated test cases
β β βββ π notifications/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_notification_h... # Automated test cases
β β βββ π settings/ # Directory
β β β βββ __init__.py # Python source code
β β β βββ test_settings_service.py # Automated test cases
β β βββ __init__.py # Python source code
β βββ conftest.py # Python source code
β βββ pytest.ini # Project file
βββ .env.example # Example environment variables template
βββ .gitignore # Files excluded from git version control
βββ LICENSE # Project file
βββ README.md # Main project documentation and quick start guide
βββ filtered_tree.txt # Project file
βββ scripts # Project file
βββ tree_output.txt # Project file
- Node.js v18+
- Python v3.10+
- PostgreSQL v15+
Create a new Postgres instance:
createdb leave_management# 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# 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- Next.js Frontend: http://localhost:3000
- FastAPI Backend (Swagger UI): http://localhost:8000/docs
- FastAPI Base API: http://localhost:8000/api
All passwords default to password123. You can reset the database and seed these accounts by running python db/seed.py.
| Role | 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. |
- 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.
Note: There are no duplicate files in the repository. If you saw files like account-settings... in the directory tree above, it was just a visual truncation (the command output was cut off). The project is fully clean and organized.
Below is a detailed breakdown of the largest and most critical files in the system, explaining exactly what each one does:
1. features/dashboard/DashboardPage.js
- What it does: The main landing page after a user logs in. It calculates and displays key metrics (like pending approvals, leave balances) using dynamic charts (Recharts). It shows different data depending on whether you are an Employee, Manager, or Admin.
2. features/leaves/apply/ApplyLeavePage.js (and related leave files)
- What it does: Contains the logic and forms for employees to request time off. It handles date picking, validates if the user has enough balance, checks for overlapping leaves, and submits the request to the backend.
3. features/organizations/OrganizationDetailsPage.js & TenantDetailsPage.js
- What it does: Used by the Platform Owners (Super Admins) to manage different client organizations (tenants). It allows creating new companies in the system, managing their admin users, and viewing cross-organization reports.
4. features/employees/EmployeesPage.js
- What it does: The employee directory. Managers and Admins use this to view all staff, add new employees, assign roles (like making someone a Manager), and organize departments.
5. features/reports/OrganizationReportsPage.js
- What it does: Generates heavy data tables and charts for HR/Admins. It includes logic to dynamically export this data into CSV (
papaparse) and PDF (jsPDF) formats without slowing down the initial page load.
6. services/api.js
- What it does: The central nervous system of the frontend. Every time the frontend needs to talk to the backend (to login, fetch leaves, or submit data), it uses the functions defined in this file. It automatically attaches JWT security tokens to every request.
1. server/main.py
- What it does: The primary entry point for the backend server. It starts the FastAPI application, configures security middlewares (CORS, CSRF, Rate Limiting), sets up database connections, and registers all the API routes.
2. modules/auth/services.py & routes.py
- What it does: Handles everything related to security. When a user types their email and password, this file verifies the hash (Bcrypt), creates a secure JWT session token, and tracks failed login attempts to prevent brute-force attacks.
3. modules/leaves/services.py & cron.py
- What it does: The core business logic of the app.
services.pyensures that when someone applies for leave, they aren't breaking any company policies (like going into a negative balance).cron.pyis a background job that automatically adds new leave days to every employee's account at the end of the month.
4. modules/dashboard/services.py
- What it does: Runs heavy database queries to aggregate data for the frontend dashboard. It counts how many people are on leave today, how many requests are pending, and caches the results in Redis so the dashboard loads instantly.
5. migrations/versions/ (Alembic Files)
- What it does: These are database history files. Whenever we change a database table (like adding a new column), Alembic creates a migration file here so we can safely update the production database without losing data.