# alice62004/visionhr architecture

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

- Interactive diagram: https://gitdiagram.com/alice62004/visionhr
- Repository: https://github.com/alice62004/visionhr

## Overview

VisionHR is a role-based HR management web app: users sign in, enter protected HR workflows, and manage employee, attendance, leave, overtime, payroll, and related records. Face enrollment and kiosk attendance add face detection, matching, and liveness checks; an AI HR agent is also documented. The React client calls an Express API, which mounts domain routes and uses controllers, services, and MySQL-backed models. Edges follow shown route registration, imports, or README statements; some unsampled page and service internals are represented only at their documented subsystem level.

Main entry points: [`client/src/App.tsx`](https://github.com/alice62004/visionhr/blob/main/client/src/App.tsx) (Client router), [`server/routes`](https://github.com/alice62004/visionhr/tree/main/server/routes) (Domain routes), [`server/controllers/employeeController.js`](https://github.com/alice62004/visionhr/blob/main/server/controllers/employeeController.js) (Employee controller), [`server/models`](https://github.com/alice62004/visionhr/tree/main/server/models) (HR data models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Client router<br/>[App.tsx]"]
  node_auth["Login and access<br/>[Login.tsx]"]
  node_aihr["AI HR agent<br/>[AIHR.tsx]"]
end

subgraph group_people["People administration"]
  node_employee["Employee records<br/>[EmployeeForm.tsx]"]
  node_faceenroll["Face enrollment<br/>[FaceEnrollment.tsx]"]
  node_departments["Departments<br/>[Departments.tsx]"]
  node_users["User accounts<br/>[UserList.tsx]"]
end

subgraph group_workforce["Workforce operations"]
  node_attendance["Attendance terminal"]
  node_leave["Leave requests<br/>[Leave.tsx]"]
  node_overtime["Overtime requests<br/>[Overtime.tsx]"]
  node_payroll["Payroll<br/>[Payroll.tsx]"]
  node_workforceextras["Shifts and reports"]
end

subgraph group_server["API and access"]
  node_api["Express API<br/>[server.js]"]
  node_routes["Domain routes"]
  node_access["Auth and role checks<br/>[authMiddleware.js]"]
  node_employeecontroller["Employee controller"]
  node_attendancecore["Attendance service"]
  node_models["HR data models"]
  node_dbconfig["MySQL pool<br/>[db.js]"]
end

subgraph group_intelligence["AI services"]
  node_faceservice["Face recognition"]
  node_aiagent["Python AI service<br/>[service.py]"]
end

node_hr(("HR user"))
node_mysql[("MySQL database")]

node_hr -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_employee
node_app -->|"routes to"| node_faceenroll
node_app -->|"routes to"| node_departments
node_app -->|"routes to"| node_users
node_app -->|"routes to"| node_attendance
node_app -->|"routes to"| node_leave
node_app -->|"routes to"| node_overtime
node_app -->|"routes to"| node_payroll
node_app -->|"routes to"| node_workforceextras
node_app -->|"routes to"| node_aihr
node_api -->|"mounts"| node_routes
node_routes -->|"checks access"| node_access
node_routes -->|"dispatches"| node_employeecontroller
node_employeecontroller -->|"reads and writes"| node_models
node_employeecontroller -->|"checks faces"| node_faceservice
node_attendancecore -->|"reads and writes"| node_models
node_attendancecore -->|"matches faces"| node_faceservice
node_models -->|"queries through"| node_dbconfig
node_dbconfig -->|"connects to"| node_mysql
node_faceservice -.->|"requests AI"| node_aiagent

click node_app "https://github.com/alice62004/visionhr/blob/main/client/src/App.tsx"
click node_auth "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Login/Login.tsx"
click node_employee "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Employees/EmployeeForm.tsx"
click node_faceenroll "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Employees/FaceEnrollment.tsx"
click node_departments "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Departments/Departments.tsx"
click node_users "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Users/UserList.tsx"
click node_attendance "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Attendance/AttendanceTerminal.tsx"
click node_leave "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Leave/Leave.tsx"
click node_overtime "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Overtime/Overtime.tsx"
click node_payroll "https://github.com/alice62004/visionhr/blob/main/client/src/pages/Payroll/Payroll.tsx"
click node_workforceextras "https://github.com/alice62004/visionhr/tree/main/client/src/pages/Shifts"
click node_aihr "https://github.com/alice62004/visionhr/blob/main/client/src/pages/AIHR/AIHR.tsx"
click node_api "https://github.com/alice62004/visionhr/blob/main/server/server.js"
click node_routes "https://github.com/alice62004/visionhr/tree/main/server/routes"
click node_access "https://github.com/alice62004/visionhr/blob/main/server/middleware/authMiddleware.js"
click node_employeecontroller "https://github.com/alice62004/visionhr/blob/main/server/controllers/employeeController.js"
click node_attendancecore "https://github.com/alice62004/visionhr/blob/main/server/services/attendanceService.js"
click node_faceservice "https://github.com/alice62004/visionhr/blob/main/server/services/faceRecognitionService.js"
click node_aiagent "https://github.com/alice62004/visionhr/blob/main/server/ai/service.py"
click node_models "https://github.com/alice62004/visionhr/tree/main/server/models"
click node_dbconfig "https://github.com/alice62004/visionhr/blob/main/server/config/db.js"

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_app,node_auth,node_aihr,node_hr toneBlue
class node_employee,node_faceenroll,node_departments,node_users,node_mysql toneAmber
class node_attendance,node_leave,node_overtime,node_payroll,node_workforceextras toneMint
class node_api,node_routes,node_access,node_employeecontroller,node_attendancecore,node_models,node_dbconfig toneRose
class node_faceservice,node_aiagent toneIndigo
```

## Components

### Web client

- [Client router](https://github.com/alice62004/visionhr/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Login and access](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Login/Login.tsx): `client/src/pages/Login/Login.tsx`
- [AI HR agent](https://github.com/alice62004/visionhr/blob/main/client/src/pages/AIHR/AIHR.tsx): `client/src/pages/AIHR/AIHR.tsx`

### People administration

- [Employee records](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Employees/EmployeeForm.tsx): `client/src/pages/Employees/EmployeeForm.tsx`
- [Face enrollment](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Employees/FaceEnrollment.tsx): `client/src/pages/Employees/FaceEnrollment.tsx`
- [Departments](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Departments/Departments.tsx): `client/src/pages/Departments/Departments.tsx`
- [User accounts](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Users/UserList.tsx): `client/src/pages/Users/UserList.tsx`

### Workforce operations

- [Attendance terminal](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Attendance/AttendanceTerminal.tsx): `client/src/pages/Attendance/AttendanceTerminal.tsx`
- [Leave requests](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Leave/Leave.tsx): `client/src/pages/Leave/Leave.tsx`
- [Overtime requests](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Overtime/Overtime.tsx): `client/src/pages/Overtime/Overtime.tsx`
- [Payroll](https://github.com/alice62004/visionhr/blob/main/client/src/pages/Payroll/Payroll.tsx): `client/src/pages/Payroll/Payroll.tsx`
- [Shifts and reports](https://github.com/alice62004/visionhr/tree/main/client/src/pages/Shifts): `client/src/pages/Shifts`

### API and access

- [Express API](https://github.com/alice62004/visionhr/blob/main/server/server.js): `server/server.js`
- [Domain routes](https://github.com/alice62004/visionhr/tree/main/server/routes): `server/routes`
- [Auth and role checks](https://github.com/alice62004/visionhr/blob/main/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`
- [Employee controller](https://github.com/alice62004/visionhr/blob/main/server/controllers/employeeController.js): `server/controllers/employeeController.js`
- [Attendance service](https://github.com/alice62004/visionhr/blob/main/server/services/attendanceService.js): `server/services/attendanceService.js`
- [HR data models](https://github.com/alice62004/visionhr/tree/main/server/models): `server/models`
- [MySQL pool](https://github.com/alice62004/visionhr/blob/main/server/config/db.js): `server/config/db.js`

### AI services

- [Face recognition](https://github.com/alice62004/visionhr/blob/main/server/services/faceRecognitionService.js): `server/services/faceRecognitionService.js`
- [Python AI service](https://github.com/alice62004/visionhr/blob/main/server/ai/service.py): `server/ai/service.py`

### Other components

- **HR user**
- **MySQL database**

## Connections

- HR user → Client router: uses (evidence: `client/src/App.tsx`)
- Client router → Login and access: routes to (evidence: `client/src/App.tsx`)
- Client router → Employee records: routes to (evidence: `client/src/App.tsx`)
- Client router → Face enrollment: routes to (evidence: `client/src/App.tsx`)
- Client router → Departments: routes to (evidence: `client/src/App.tsx`)
- Client router → User accounts: routes to (evidence: `client/src/App.tsx`)
- Client router → Attendance terminal: routes to (evidence: `client/src/App.tsx`)
- Client router → Leave requests: routes to (evidence: `client/src/App.tsx`)
- Client router → Overtime requests: routes to (evidence: `client/src/App.tsx`)
- Client router → Payroll: routes to (evidence: `client/src/App.tsx`)
- Client router → Shifts and reports: routes to (evidence: `client/src/App.tsx`)
- Client router → AI HR agent: routes to (evidence: `client/src/App.tsx`)
- Express API → Domain routes: mounts (evidence: `server/server.js`)
- Domain routes → Auth and role checks: checks access (evidence: `server/routes/employeeRoutes.js`)
- Domain routes → Employee controller: dispatches (evidence: `server/routes/employeeRoutes.js`)
- Employee controller → HR data models: reads and writes (evidence: `server/controllers/employeeController.js`)
- Employee controller → Face recognition: checks faces (evidence: `server/controllers/employeeController.js`)
- Attendance service → HR data models: reads and writes (evidence: `server/services/attendanceService.js`)
- Attendance service → Face recognition: matches faces (evidence: `server/services/attendanceService.js`)
- HR data models → MySQL pool: queries through (evidence: `server/models/User.js`)
- MySQL pool → MySQL database: connects to (evidence: `server/config/db.js`)
- Face recognition → Python AI service: requests AI (evidence: `README.md`)
