How ddaza-cell/onduty works
Purpose and entry points
OnDuty is a medical-staff attendance, scheduling, and payroll PWA. The React client starts at frontend/src/main.jsx and composes routes/UI through frontend/src/App.jsx. The Express API starts from backend/src/index.js, configures application middleware/routes in backend/src/app.js, and persists operational data through Prisma.
Client application and access boundary
The frontend is a Vite React PWA with protected, role-aware workflows. Authentication state is centralized in frontend/src/store/authStore.js; API requests use frontend/src/services/api.js; route access is enforced by frontend/src/components/ProtectedRoute.jsx and administrative dashboard access by frontend/src/components/AdminGuardDashboard.jsx. Primary user surfaces cover attendance, schedules, swaps/cessions, payroll, reporting, and administration under frontend/src/pages/.
Identity, authorization, and sessions
The backend auth module provides JWT access/refresh flows and role-based access for employee, supervisor, and admin actors. Route/service boundaries reside in backend/src/modules/auth/auth.routes.js and backend/src/modules/auth/auth.service.js; shared request authentication is in backend/src/middlewares/auth.js. Redis (backend/src/redis.js) supports refresh-token allowlisting/revocation and is an infrastructure dependency alongside the primary database.
Biometric enrollment and attendance
Attendance is a controlled pipeline: the browser captures camera input and performs liveness/descriptor work (frontend/src/components/FaceCapture.jsx, frontend/src/modules/biometric/liveness.js), then calls backend biometric and attendance endpoints (backend/src/modules/biometric/biometric.routes.js, backend/src/modules/attendance/attendance.routes.js). CompreFace is the authoritative external Docker service for facial recognition decisions. The backend also encrypts optional client-generated facial descriptor backups through backend/src/modules/biometric/crypto.service.js; models are packaged under backend/public/models/ and frontend/public/models/.
Shift operations and coverage lifecycle
Scheduling supports rotation templates, assignments, vacancies, substitutions, swaps, and full/partial T24 cessions. The API is separated by workflow in backend/src/modules/shifts/shift.routes.js, backend/src/modules/shifts/swap.routes.js, and backend/src/modules/shifts/cession.routes.js, with cession business logic in backend/src/services/cession.service.js. Corresponding employee-facing interaction points include frontend/src/components/ShiftSwapPanel.jsx and frontend/src/components/ShiftCessionPanel.jsx; supervisors administer schedules from frontend/src/pages/AdminShiftManagementPage.jsx.
Payroll, reporting, and time automation
Attendance and shift records feed payroll calculation, holiday/shift premiums, projections, and closure via backend/src/modules/pay/pay.routes.js and backend/src/services/pay.service.js. Users access individual and administrative payroll through frontend/src/pages/MyPayPage.jsx and frontend/src/pages/PayrollPage.jsx. A background automatic-checkout process in backend/src/jobs/autoCheckout.job.js manages time-bound attendance completion independently of browser sessions.
Realtime delivery, offline behavior, and deployment
Socket.io integration (backend/src/socket.js, frontend/src/hooks/useSocket.js) provides realtime operational events. Web Push is handled by backend/src/modules/push/push.routes.js, backend/src/services/push.service.js, and service worker frontend/public/sw-push.js; email delivery is isolated in backend/src/services/email.service.js. The client queues offline operations in frontend/src/services/offlineQueue.js, critical for attendance continuity. Docker Compose defines the multi-service runtime in docker-compose.yml and production variant docker-compose.prod.yml; Nginx configuration is at nginx/nginx.conf. Prisma schema and migrations define the relational boundary in backend/prisma/schema.prisma.
Main entry points: app.js Express application · App.jsx React application · attendance.routes.js Biometric attendance · schema.prisma Operational database
Components 20
React PWA
- React application · Routes and role-aware user workflows.
frontend/src/App.jsx - Auth state
frontend/src/store/authStore.js - API client
frontend/src/services/api.js - Route guards
frontend/src/components/ProtectedRoute.jsx - Face capture & liveness
frontend/src/components/FaceCapture.jsx - Offline operation queue · Preserves operations during connectivity loss.
frontend/src/services/offlineQueue.js - Socket client
frontend/src/hooks/useSocket.js
Express API
- Express application · Middleware and module route registration.
backend/src/app.js - Authentication · JWT access/refresh flows and role authorization.
backend/src/modules/auth/auth.routes.js - Request authentication
backend/src/middlewares/auth.js - Socket server
backend/src/socket.js
Operational Workflows
- Biometric attendance · Enrollment, recognition, and attendance endpoints.
backend/src/modules/attendance/attendance.routes.js - Shift coverage · Assignments, swaps, and T24 cessions.
backend/src/modules/shifts/shift.routes.js - Payroll calculation · Calculates premiums, projections, and closures.
backend/src/services/pay.service.js - Automatic checkout · Completes time-bound attendance independently of sessions.
backend/src/jobs/autoCheckout.job.js - Push & email delivery
backend/src/services/push.service.js
Data & Delivery
- Operational database · Primary persistence boundary for operational records.
backend/prisma/schema.prisma - Redis · Refresh-token allowlisting and revocation.
backend/src/redis.js - CompreFace · Authoritative facial recognition decision service.
- Docker Compose & Nginx · Multi-service runtime and reverse proxy boundary.
docker-compose.yml
Connections 23
- React application → Auth state: uses
- React application → Route guards: protects routes with
- React application → API client: calls
- React application → Face capture & liveness: hosts
- Offline operation queue → API client: replays operations
- Socket client → Socket server: realtime events
- API client → Express application: HTTPS requests
- Express application → Authentication: routes auth
- Express application → Request authentication: applies
- Express application → Biometric attendance: routes
- Express application → Shift coverage: routes
- Express application → Payroll calculation: routes
- Authentication → Redis: refresh token state
- Authentication → Operational database: identity data
- Biometric attendance → CompreFace: recognition decision
- Biometric attendance → Operational database: attendance records
- Shift coverage → Operational database: shift records
- Payroll calculation → Operational database: reads attendance and shifts
- Automatic checkout → Biometric attendance: completes attendance
- Socket server → Socket client: operational events
- Push & email delivery → React application: web push
- Docker Compose & Nginx → Express application: runs API
- Docker Compose & Nginx → CompreFace: runs service