How adilmunawar/adicorp works
1. What this repo is
- This is a frontend-first HRMS SPA for Adicorp, built with React + TypeScript + Vite.
- The architecture is centered around client-side routes, reusable UI modules, and a Supabase backend for auth/data/storage. There is no traditional server app in this repo.
2. Top-level application shape
- src/main.tsx bootstraps the app.
- src/App.tsx and the src/pages/* directory define the route-level screens.
- The app is split into two major experience areas:
- Admin/dashboard workspace
- Employee portal under src/pages/portal/*
3. Routing and layout boundary
- Layout composition lives in src/components/layout/*:
- Dashboard.tsx, Sidebar.tsx, Header.tsx, PrivateRoute.tsx
- EmployeePortalLayout.tsx for the portal side
- AnimatedRoute.tsx, PageTransition.tsx for navigation effects
- This is the main boundary between authenticated app shell and individual feature pages.
4. Authentication and access control
- src/context/AuthContext.tsx handles the main user/session auth state.
- src/context/EmployeeAuthContext.tsx isolates the employee portal authentication flow.
- Supporting auth screens include:
- src/components/auth/AuthForm.tsx
- ForgotPasswordForm.tsx
- BiometricLockScreen.tsx
- src/lib/authRedirect.ts and PrivateRoute.tsx suggest route guarding and role-based redirect logic.
5. Core domain subsystems
- The feature folders under src/components/* map directly to business modules:
- Employees: profiles, import/export, document management
- Attendance: attendance table, bulk actions
- Leave: requests, balances, leave-type configuration
- Overtime: entry, records, policy/config panels
- Salary / payroll: salary sheets, payslips, stats, history
- Events: event managers, recurring/advanced scheduling
- Reports / timeline / backup / settings
- This is a modular HRMS, not a single monolithic page.
6. Dashboard and analytics layer
- src/components/dashboard/* powers the main management overview:
- stats cards, analytics widgets, activity feed, recent documents, attendance chart
- These components aggregate data from multiple business domains to present operational status.
- src/pages/Dashboard.tsx is the primary landing page for the admin workspace.
7. Data access and backend integration
- src/integrations/supabase/client.ts is the main backend client entrypoint.
- src/integrations/supabase/types.ts and src/types/supabase.ts indicate typed database access.
- supabase/migrations/* and supabase/config.toml show the database schema is managed as code and lives outside the frontend bundle.
- The backend boundary is therefore:
- React UI → hooks/services → Supabase client → Supabase Auth/Postgres/Storage
8. Service and computation boundary
- Business aggregation and non-UI logic are separated into:
- src/services/dataIntegrationService.ts
- src/services/reportDataService.ts
- Calculation/utilities live in:
- src/utils/salaryCalculations.ts
- src/utils/workingDays.ts
- src/utils/cache.ts
- This is where payroll rules, report shaping, and working-day logic are kept out of components.
9. Stateful hooks and cross-cutting concerns
- Custom hooks in src/hooks/* provide reusable state/data flows:
- useEmployeePortalData, useSalaryData, useSalaryDownloads
- useActivityLogger, useBiometric, useCurrency
- use-toast, use-mobile
- These act as the glue between UI and domain services, especially for derived data, downloads, and device-specific behavior.
10. Shared UI system
- src/components/ui/* is a large design-system layer, likely based on shadcn/ui + Radix + Tailwind.
- It supplies tables, dialogs, dropdowns, forms, toasts, sheets, calendars, charts, etc.
- src/components/common/* adds app-specific shared pieces like loaders, month selector, error boundary, and permission error handling.
11. Employee portal as a separate sub-application
- src/pages/portal/* implements a distinct employee-facing experience:
- login, profile, attendance, overtime, payroll, records, reports, settings, password setup
- src/components/layout/EmployeePortalLayout.tsx and src/context/EmployeeAuthContext.tsx show this is intentionally separated from the admin workspace.
12. Static assets, uploads, and deployment
- public/ contains static assets and uploaded/public files.
- vercel.json indicates deployment is intended for Vercel.
- tailwind.config.ts, postcss.config.js, and components.json indicate a Tailwind/shadcn-based frontend toolchain.
13. What to draw in an architecture diagram
- Draw two user entry paths: Admin dashboard and Employee portal.
- Show both paths going through auth/context + private routing.
- Show feature pages using shared UI components and domain hooks/services.
- Show services/hooks connecting to Supabase for auth, database, and storage.
- Treat supabase/migrations as the schema/infra source of truth, separate from the React app.
Main entry points: pages Admin pages · hooks Hooks · App.tsx App shell · portal Employee portal
Components 22
React app
Frontend entrypoints, route screens, and application shell.
- Main · Vite entry that mounts the React app.
src/main.tsx - App shell · Top-level app composition and route wiring.
src/App.tsx - Admin pages · Dashboard and admin workspace route screens.
src/pages - Employee portal · Employee-facing portal pages and flows.
src/pages/portal
HR modules
Business feature areas for admin and portal workflows.
- Dashboard · Operational overview aggregating activity, attendance, docs, and stats.
src/components/dashboard - Employees · Profiles, import/export, documents, and employee lists/forms.
src/components/employees - Attendance · Attendance table and bulk action workflows.
src/components/attendance - Leave · Leave requests, balances, and leave-type configuration.
src/components/leave - Overtime · Overtime entry, records, and policy configuration.
src/components/overtime - Salary · Salary sheets, payslips, history, and payroll stats.
src/components/salary - Events · Event management with recurring and advanced scheduling.
src/components/events - Settings · Company, working time, currency, security, and password settings.
src/components/settings
Shared layer
Reusable UI, hooks, context, services, and utilities.
- Layouts · Authenticated shells, navigation, transitions, and route guards.
src/components/layout - Auth state · Main session/auth and employee portal auth contexts.
src/context - Auth screens · Login, recovery, and biometric lock UI.
src/components/auth - Services · Data integration and report shaping services.
src/services - Hooks · Reusable data, device, biometric, currency, download, and logging hooks.
src/hooks - UI kit · Reusable shadcn-style UI primitives and app-specific shared components.
src/components/ui - Utilities · Salary, working-day, cache, branding, and permission helpers.
src/utils
Supabase backend
Client integration and schema/migration source of truth.
- Supabase client · Frontend client entrypoint for auth, database, and storage access.
src/integrations/supabase/client.ts - Supabase types · Generated database types used by the frontend.
src/integrations/supabase/types.ts - Migrations · Supabase SQL migrations and config managed as code.
supabase/migrations
Connections 30
- Main → App shell: boots · Application bootstrap mounts the routed SPA.
- App shell → Layouts: uses · Routes compose the authenticated shell and portal layout.
- App shell → Admin pages: routes to · Admin workspace screens are routed from the app shell.
- App shell → Employee portal: routes to · Employee portal screens are routed separately.
- Layouts → Auth state: protects · Private routing and session state gate access.
- Layouts → Auth screens: renders · Layout and auth flows present sign-in and recovery screens.
- Admin pages → Dashboard: landing · Dashboard is the primary admin overview page.
- Admin pages → Employees: includes · Admin workspace exposes employee management.
- Admin pages → Attendance: includes · Admin workspace exposes attendance management.
- Admin pages → Leave: includes · Admin workspace exposes leave management.
- Admin pages → Overtime: includes · Admin workspace exposes overtime management.
- Admin pages → Salary: includes · Admin workspace exposes payroll management.
- Admin pages → Events: includes · Admin workspace exposes event scheduling.
- Admin pages → Settings: includes · Admin workspace exposes configuration screens.
- Employee portal → Auth state: uses · Employee portal has its own auth context and session flow.
- Dashboard → Hooks: reads via · Dashboard widgets aggregate state through hooks.
- Employees → Hooks: uses · Employee workflows use reusable data and logging hooks.
- Attendance → Hooks: uses · Attendance screens use shared state/data hooks.
- Leave → Hooks: uses · Leave flows rely on shared state and data hooks.
- Overtime → Hooks: uses · Overtime flows rely on shared state and data hooks.
- Salary → Services: calculates via · Payroll views rely on aggregation and report services.
- Employee portal → Services: reads via · Portal pages use shared report and data integration services.
- Hooks → Supabase client: calls · Hooks connect UI state to backend data and auth.
- Services → Supabase client: calls · Business services fetch and shape Supabase data.
- Supabase client → Supabase types: typed by · Client operations use generated database types.
- Supabase client → Migrations: backed by · Client data access corresponds to the managed schema.
- UI kit → Admin pages: supports · Feature pages are built from shared UI primitives.
- UI kit → Employee portal: supports · Portal pages also reuse the shared UI system.
- Utilities → Services: supports · Services depend on salary and reporting helpers.
- Utilities → Hooks: supports · Hooks reuse utility logic for device, currency, and cache concerns.