# ahmadmakih/empdesk architecture

> Architecture diagram of the GitHub repository ahmadmakih/empdesk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmadmakih/empdesk
- Repository: https://github.com/ahmadmakih/empdesk

## Overview

#### 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: [`src/App.tsx`](https://github.com/ahmadmakih/empdesk/blob/main/src/App.tsx) (App composition), [`src/pages/EmployeesPage.tsx`](https://github.com/ahmadmakih/empdesk/blob/main/src/pages/EmployeesPage.tsx) (Employee management), [`src/main.tsx`](https://github.com/ahmadmakih/empdesk/blob/main/src/main.tsx) (React mount), [`src/layouts/DashboardLayout.tsx`](https://github.com/ahmadmakih/empdesk/blob/main/src/layouts/DashboardLayout.tsx) (Dashboard shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap"]
  node_vite{{"Vite runtime<br/>build<br/>[vite.config.ts]"}}
  node_main(("React mount<br/>entrypoint<br/>[main.tsx]"))
  node_app["App composition<br/>root component<br/>[App.tsx]"]
  node_styles["Global styles<br/>Tailwind CSS<br/>[index.css]"]
end

subgraph group_routing["Navigation &amp; Access"]
  node_router["Application router<br/>route map<br/>[AppRouter.tsx]"]
  node_protected["Protected route<br/>access guard<br/>[ProtectedRoute.tsx]"]
  node_dashboard["Dashboard shell<br/>authenticated layout"]
end

subgraph group_state["Global State"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.tsx]"]
  node_employee_context["Employee state<br/>React context"]
  node_leave_context["Leave state<br/>React context<br/>[LeaveContext.tsx]"]
end

subgraph group_ui["HR Interface"]
  node_employee_pages["Employee management<br/>HR pages<br/>[EmployeesPage.tsx]"]
  node_add_employee["Add employee<br/>HR page"]
  node_edit_employee["Edit employee<br/>HR page"]
  node_hr_workflows["Other HR workflows<br/>page modules"]
  node_datatable["Data table<br/>shared component<br/>[DataTable.tsx]"]
  node_table_state["Table state<br/>shared hook<br/>[useTableState.ts]"]
  node_error_boundary["Error boundary<br/>UI resilience<br/>[ErrorBoundary.tsx]"]
end

subgraph group_data["Data Boundary"]
  node_auth_service["Auth service<br/>API service<br/>[authService.ts]"]
  node_employee_service["Employee service<br/>API service<br/>[employeeService.ts]"]
  node_types["Domain contracts<br/>TypeScript types<br/>[index.ts]"]
  node_api{{"Configured backend API<br/>external HTTP API"}}
end

node_vite -->|"serves"| node_main
node_main -->|"mounts"| node_app
node_main -->|"loads"| node_styles
node_app -->|"composes"| node_router
node_app -->|"provides"| node_auth_context
node_app -->|"provides"| node_employee_context
node_app -->|"provides"| node_leave_context
node_router -->|"guards routes"| node_protected
node_protected -->|"admits authenticated views"| node_dashboard
node_dashboard -->|"renders"| node_employee_pages
node_dashboard -->|"renders"| node_hr_workflows
node_employee_pages -->|"navigates to"| node_add_employee
node_employee_pages -->|"navigates to"| node_edit_employee
node_employee_pages -->|"consumes"| node_employee_context
node_employee_context -->|"uses"| node_employee_service
node_auth_context -->|"uses"| node_auth_service
node_auth_service -->|"HTTP"| node_api
node_employee_service -->|"HTTP"| node_api
node_employee_service -.->|"uses contracts"| node_types
node_employee_pages -->|"composes"| node_datatable
node_datatable -->|"uses"| node_table_state
node_app -->|"contains UI failures"| node_error_boundary

click node_vite "https://github.com/ahmadmakih/empdesk/blob/main/vite.config.ts"
click node_main "https://github.com/ahmadmakih/empdesk/blob/main/src/main.tsx"
click node_app "https://github.com/ahmadmakih/empdesk/blob/main/src/App.tsx"
click node_styles "https://github.com/ahmadmakih/empdesk/blob/main/src/index.css"
click node_router "https://github.com/ahmadmakih/empdesk/blob/main/src/routes/AppRouter.tsx"
click node_protected "https://github.com/ahmadmakih/empdesk/blob/main/src/routes/ProtectedRoute.tsx"
click node_dashboard "https://github.com/ahmadmakih/empdesk/blob/main/src/layouts/DashboardLayout.tsx"
click node_auth_context "https://github.com/ahmadmakih/empdesk/blob/main/src/context/AuthContext.tsx"
click node_employee_context "https://github.com/ahmadmakih/empdesk/blob/main/src/context/EmployeeContext.tsx"
click node_leave_context "https://github.com/ahmadmakih/empdesk/blob/main/src/context/LeaveContext.tsx"
click node_employee_pages "https://github.com/ahmadmakih/empdesk/blob/main/src/pages/EmployeesPage.tsx"
click node_add_employee "https://github.com/ahmadmakih/empdesk/blob/main/src/pages/AddEmployeePage.tsx"
click node_edit_employee "https://github.com/ahmadmakih/empdesk/blob/main/src/pages/EditEmployeePage.tsx"
click node_datatable "https://github.com/ahmadmakih/empdesk/blob/main/src/components/DataTable.tsx"
click node_table_state "https://github.com/ahmadmakih/empdesk/blob/main/src/hooks/useTableState.ts"
click node_error_boundary "https://github.com/ahmadmakih/empdesk/blob/main/src/components/ErrorBoundary.tsx"
click node_auth_service "https://github.com/ahmadmakih/empdesk/blob/main/src/services/authService.ts"
click node_employee_service "https://github.com/ahmadmakih/empdesk/blob/main/src/services/employeeService.ts"
click node_types "https://github.com/ahmadmakih/empdesk/blob/main/src/types/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vite,node_main,node_app,node_styles toneBlue
class node_router,node_protected,node_dashboard toneAmber
class node_auth_context,node_employee_context,node_leave_context toneMint
class node_employee_pages,node_add_employee,node_edit_employee,node_hr_workflows,node_datatable,node_table_state,node_error_boundary toneRose
class node_auth_service,node_employee_service,node_types,node_api toneIndigo
```

## Components

### Bootstrap

- [Vite runtime](https://github.com/ahmadmakih/empdesk/blob/main/vite.config.ts): build · Builds and serves the SPA. · `vite.config.ts`
- [React mount](https://github.com/ahmadmakih/empdesk/blob/main/src/main.tsx): entrypoint · `src/main.tsx`
- [App composition](https://github.com/ahmadmakih/empdesk/blob/main/src/App.tsx): root component · Installs application-wide providers and routing. · `src/App.tsx`
- [Global styles](https://github.com/ahmadmakih/empdesk/blob/main/src/index.css): Tailwind CSS · Global CSS and visual tokens. · `src/index.css`

### Navigation & Access

- [Application router](https://github.com/ahmadmakih/empdesk/blob/main/src/routes/AppRouter.tsx): route map · Maps URLs to page modules. · `src/routes/AppRouter.tsx`
- [Protected route](https://github.com/ahmadmakih/empdesk/blob/main/src/routes/ProtectedRoute.tsx): access guard · Blocks unauthenticated routes. · `src/routes/ProtectedRoute.tsx`
- [Dashboard shell](https://github.com/ahmadmakih/empdesk/blob/main/src/layouts/DashboardLayout.tsx): authenticated layout · Main navigation and authenticated page frame. · `src/layouts/DashboardLayout.tsx`

### Global State

- [Auth state](https://github.com/ahmadmakih/empdesk/blob/main/src/context/AuthContext.tsx): React context · Provides identity and session behavior. · `src/context/AuthContext.tsx`
- [Employee state](https://github.com/ahmadmakih/empdesk/blob/main/src/context/EmployeeContext.tsx): React context · Shared employee workflow state. · `src/context/EmployeeContext.tsx`
- [Leave state](https://github.com/ahmadmakih/empdesk/blob/main/src/context/LeaveContext.tsx): React context · Shared leave workflow state. · `src/context/LeaveContext.tsx`

### HR Interface

- [Employee management](https://github.com/ahmadmakih/empdesk/blob/main/src/pages/EmployeesPage.tsx): HR pages · Lists and manages employee records. · `src/pages/EmployeesPage.tsx`
- [Add employee](https://github.com/ahmadmakih/empdesk/blob/main/src/pages/AddEmployeePage.tsx): HR page · `src/pages/AddEmployeePage.tsx`
- [Edit employee](https://github.com/ahmadmakih/empdesk/blob/main/src/pages/EditEmployeePage.tsx): HR page · `src/pages/EditEmployeePage.tsx`
- **Other HR workflows**: page modules · Attendance, leave, organization, dashboard, and reporting screens.
- [Data table](https://github.com/ahmadmakih/empdesk/blob/main/src/components/DataTable.tsx): shared component · Reusable management table UI. · `src/components/DataTable.tsx`
- [Table state](https://github.com/ahmadmakih/empdesk/blob/main/src/hooks/useTableState.ts): shared hook · Consistent filtering and pagination behavior. · `src/hooks/useTableState.ts`
- [Error boundary](https://github.com/ahmadmakih/empdesk/blob/main/src/components/ErrorBoundary.tsx): UI resilience · Contains rendering failures. · `src/components/ErrorBoundary.tsx`

### Data Boundary

- [Auth service](https://github.com/ahmadmakih/empdesk/blob/main/src/services/authService.ts): API service · `src/services/authService.ts`
- [Employee service](https://github.com/ahmadmakih/empdesk/blob/main/src/services/employeeService.ts): API service · `src/services/employeeService.ts`
- [Domain contracts](https://github.com/ahmadmakih/empdesk/blob/main/src/types/index.ts): TypeScript types · Shared domain definitions. · `src/types/index.ts`
- **Configured backend API**: external HTTP API · Endpoint is supplied through VITE_API_BASE_URL.

## Connections

- 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
