Attendance, leave balances, correction requests, manager approvals, and HR reporting require consistent business rules and carefully separated access. Corp HQ brings those workflows together while enforcing employee, direct-manager, and administrator scope on the server.
Corp HQ
A responsive employee portal for attendance, leave, correction requests, holidays, reporting, role-scoped management, and real-time workforce updates.
About Corp HQ
Corp HQ gives employees one place to check in, review attendance, request corrections, manage leave, and view applicable holidays. Managers receive direct-report attendance and leave workflows, while administrators and HR can manage records, employees, reporting hierarchies, holidays, approvals, analytics, and CSV exports.
Product thinking
Challenge and approach
Attendance calculations use each employee's saved timezone and configured work-start rules. Leave calculations exclude weekends and applicable company or department holidays, reserve balances while requests are pending, and release or consume balances when requests are cancelled, rejected, or approved.
Capabilities
Main features
Timezone-aware employee check-in and checkout with attendance history
Attendance correction requests with administrator review
CL, SL, and PL balances with leave application and approval workflows
Direct-report views and manager-scoped leave review
Employee, reporting hierarchy, holiday, and department administration
Monthly attendance analytics, live workforce status, and CSV exports
Architecture
How the system is structured
- 01
Next.js App Router pages and API route handlers provide the application and authenticated workflow endpoints.
- 02
PostgreSQL and Prisma store employees, sessions, attendance, leave, balances, holidays, departments, and reporting relationships.
- 03
A custom Node.js server prepares Next.js, applies committed migrations, attaches Socket.IO, and runs the automatic checkout timer.
- 04
Service modules centralize attendance, leave, holiday, and regularization rules instead of embedding them in interface components.
Implementation
Technology and data
Technology stack
- Next.js
- React
- PostgreSQL
- Prisma
- Tailwind CSS
- Socket.IO
- JWT
- Zod
- Resend
Engineering details
Technical considerations
SecurityAccess and validation safeguards
- Short-lived JWT access tokens and rotating refresh-token sessions use HTTP-only cookies.
- Protected routes enforce role and direct-manager scope on the server.
- Password-reset responses do not reveal whether an email is registered.
- Single-use reset links expire after 30 minutes and invalidate existing sessions after a successful reset.
- Zod validates requests and bcryptjs hashes passwords.
ReliabilityRecovery and cleanup
- Socket.IO events refresh attendance, leave, and correction views without manual reloads
- Committed Prisma migrations are applied before the custom server accepts traffic
- Startup stops if production migration deployment fails
- An automatic process checks for attendance sessions exceeding the configured checkout duration
OperationsDeployment considerations
- PostgreSQL is required and committed migrations are the production schema source of truth.
- Resend is optional for local operation but must be configured to deliver password-reset emails.
- The production origin must be configured exactly and served through HTTPS.
- The custom server must support Socket.IO connections alongside the Next.js application.
Use cases
What the project supports
- Track employee attendance and working hours
- Apply for and review leave with role-scoped approvals
- Correct missing or inaccurate attendance records
- Manage employees, reporting relationships, holidays, and HR reports