How ahmadmakih/empdesk works
Purpose and Runtime
EmpDesk is a React/TypeScript single-page employee-management system covering HR operations: employees, attendance, leave, payroll, performance, documents, tasks, events, and reporting. It runs as a Vite frontend with Tailwind styling; the README identifies a configurable backend API base URL, but only authentication and employee service modules are present.
Entry and build surfaces: src/main.tsx, src/App.tsx, vite.config.ts, package.json.
Application Bootstrap and Global Composition
main.tsx mounts the React application and global stylesheet. App.tsx is the top-level composition point, expected to install application-wide providers and routing. Global CSS and visual tokens are rooted in src/index.css and tailwind.config.js.
Paths: src/main.tsx, src/App.tsx, src/index.css.
Routing, Access Control, and Layout Boundary
Routing is centralized rather than page-local. AppRouter.tsx maps URL paths to page modules, while ProtectedRoute.tsx blocks unauthenticated access and RoleGuard.tsx restricts role-sensitive views. Authenticated views are organized under a dashboard shell; login uses a separate auth shell. This creates the main navigation and authorization boundary before business pages render.
Paths: src/routes/AppRouter.tsx, src/routes/ProtectedRoute.tsx, src/layouts/DashboardLayout.tsx.
Global Domain State
React contexts hold cross-page session and domain state. Authentication state supplies identity/session behavior; employee and leave contexts provide shared state for their respective workflows; theme context controls dark/light presentation. Hooks are the intended consumer interface for auth, employees, and leave state, separating pages from direct context wiring.
Paths: src/context/AuthContext.tsx, src/context/EmployeeContext.tsx, src/context/LeaveContext.tsx.
Service and Data Boundary
Service modules isolate API-facing operations for authentication and employee records, with VITE_API_BASE_URL documented as the backend endpoint configuration. Shared TypeScript definitions establish the domain contract, while mock data indicates the UI can operate against local/sample data where backend coverage is absent. Other HR modules appear page-driven and do not have dedicated service files in this tree.
Paths: src/services/authService.ts, src/services/employeeService.ts, src/types/index.ts.
Employee Lifecycle and HR Workflows
Employee management is the most explicitly structured domain flow: list/manage employees, then add or edit individual employee records. Supporting pages cover organizational attributes and operational modules—departments, designations, positions, attendance, leave types, and leave requests. Dashboard and reports aggregate or present management information across these workflows.
Paths: src/pages/EmployeesPage.tsx, src/pages/AddEmployeePage.tsx, src/pages/EditEmployeePage.tsx.
Presentation System and Interaction Primitives
Pages compose a reusable component library for tables, forms, navigation controls, dialogs, date inputs, and theme control. Data-heavy management screens likely use shared table state, pagination, and debounce hooks, keeping filtering/paging behavior consistent. Error boundaries contain rendering failures at the UI layer.
Paths: src/components/DataTable.tsx, src/components/ErrorBoundary.tsx, src/hooks/useTableState.ts.
External Libraries and Client Capabilities
Material client dependencies are React 19, React Router DOM v7, React Hook Form, Recharts, Motion, Lucide React, React Hot Toast, Tailwind CSS, and Vite. The repository contains no backend, database, storage provider, or deployment infrastructure; external integration is limited to the configured HTTP API implied by service modules and environment configuration.
Main entry points: App.tsx App composition · EmployeesPage.tsx Employee management · main.tsx React mount · DashboardLayout.tsx Dashboard shell
Components 21
Bootstrap
- Vite runtime · Builds and serves the SPA.
vite.config.ts - React mount
src/main.tsx - App composition · Installs application-wide providers and routing.
src/App.tsx - Global styles · Global CSS and visual tokens.
src/index.css
Navigation & Access
- Application router · Maps URLs to page modules.
src/routes/AppRouter.tsx - Protected route · Blocks unauthenticated routes.
src/routes/ProtectedRoute.tsx - Dashboard shell · Main navigation and authenticated page frame.
src/layouts/DashboardLayout.tsx
Global State
- Auth state · Provides identity and session behavior.
src/context/AuthContext.tsx - Employee state · Shared employee workflow state.
src/context/EmployeeContext.tsx - Leave state · Shared leave workflow state.
src/context/LeaveContext.tsx
HR Interface
- Employee management · Lists and manages employee records.
src/pages/EmployeesPage.tsx - Add employee
src/pages/AddEmployeePage.tsx - Edit employee
src/pages/EditEmployeePage.tsx - Other HR workflows · Attendance, leave, organization, dashboard, and reporting screens.
- Data table · Reusable management table UI.
src/components/DataTable.tsx - Table state · Consistent filtering and pagination behavior.
src/hooks/useTableState.ts - Error boundary · Contains rendering failures.
src/components/ErrorBoundary.tsx
Data Boundary
- Auth service
src/services/authService.ts - Employee service
src/services/employeeService.ts - Domain contracts · Shared domain definitions.
src/types/index.ts - Configured backend API · Endpoint is supplied through VITE_API_BASE_URL.
Connections 22
- Vite runtime → React mount: serves
- React mount → App composition: mounts
- React mount → Global styles: loads
- App composition → Application router: composes
- App composition → Auth state: provides
- App composition → Employee state: provides
- App composition → Leave state: provides
- Application router → Protected route: guards routes
- Protected route → Dashboard shell: admits authenticated views
- Dashboard shell → Employee management: renders
- Dashboard shell → Other HR workflows: renders
- Employee management → Add employee: navigates to
- Employee management → Edit employee: navigates to
- Employee management → Employee state: consumes
- Employee state → Employee service: uses
- Auth state → Auth service: uses
- Auth service → Configured backend API: HTTP
- Employee service → Configured backend API: HTTP
- Employee service → Domain contracts: uses contracts
- Employee management → Data table: composes
- Data table → Table state: uses
- App composition → Error boundary: contains UI failures