This document maps frontend API usage to implemented backend contracts.
Primary files:
- endpoint constants:
src/lib/api/endpoints.ts - transport/auth/error handling:
src/lib/api/client.ts - domain modules:
src/lib/api/*.ts
Client behavior:
- injects bearer token from Supabase session
- retries once after coordinated token refresh on 401
- converts network/timeout failures into typed
ApiError - parses standard envelope and paginated contract shapes
GET /auth/meviaauthApi.me()
POST /attendance/check-inPOST /attendance/check-outPOST /attendance/:sessionId/recalculateGET /attendance/my-sessionsGET /admin/sessionsGET /admin/sessions/:id/locations
Session filters sent by frontend:
status=all|active|recent|inactive- optional
employee_idfor admin employee history scopes
GET /locations/my-route?sessionId=<uuid>
POST /expensesPOST /expenses/receipt-upload-urlGET /expenses/myGET /admin/expensesPATCH /admin/expenses/:idGET /admin/expenses/summaryGET /admin/expenses/export
Expense status values used:
allPENDINGAPPROVEDREJECTEDprocessed
GET /admin/employeesPOST /admin/employeesGET /admin/employees/:idPATCH /admin/employees/:id/statusGET /admin/searchGET /admin/audit-logPOST /admin/force-checkout
GET /dashboard/my-summaryGET /admin/dashboardGET /admin/monitoring/mapGET /admin/org-summaryGET /admin/user-summaryGET /admin/top-performersGET /admin/session-trendGET /admin/leaderboardGET /leaderboard
Date filtering follows backend contract (from, to) and optional metric/limit params where applicable.
POST /admin/start-monitoringPOST /admin/stop-monitoringGET /admin/monitoring-historyGET /admin/queuesGET /admin/retry-intentsGET /admin/system-health
- webhooks:
GET /admin/webhooksPOST /admin/webhooksPATCH /admin/webhooks/:idDELETE /admin/webhooks/:idGET /admin/webhooks/logsPOST /admin/webhooks/logs/:id/retryPOST /admin/webhooks/:id/test
- api keys:
GET /admin/api-keysPOST /admin/api-keysPATCH /admin/api-keys/:idDELETE /admin/api-keys/:id
Query keys are domain-based and include dynamic filters to avoid stale collisions.
Examples:
- sessions:
sessionKeys.mine(page, limit, status),sessionKeys.org(...) - expenses:
expenseKeys.mine(page, limit, status), summary and employee-scoped keys - dashboards/maps:
adminDashboard,adminMap
Caching patterns:
- global stale time 60s, with hook-level overrides
- paginated hooks use
keepPreviousData - selected admin views use polling/refetch intervals
Mutation handling patterns:
- optimistic updates for check-in/check-out and expense review in query caches
- rollback on error using pre-mutation snapshots
- invalidate affected domains on settle (for example sessions + dashboard + employees)
SSE integration (useAdminSSE) complements mutations by invalidating or patching cache when server-side events arrive.