Skip to main content

Contexts

The frontend uses 9 React contexts in contexts/ for global state management. They are nested in a specific order in app/providers.tsx (see Architecture for the full hierarchy).

UserAuthProvider

File: contexts/UserAuthProvider.tsx

Central authentication and session management.

StateTypeDescription
isLoggedInbooleanAuthentication status
userUserCurrent user profile
role"company" | "jobseeker"Active role
isCompanybooleanShorthand for company mode
loadingbooleanAuth check in progress
errorErrorAuth errors
MethodPurpose
login()Authenticate and store JWT
logout()Clear token and redirect
setUser()Update user state
setRole()Switch active role
refetchUser()Re-fetch user via WHO_AM_I query

Features: JWT stored in localStorage, 5-hour inactivity auto-logout, activity tracking.

Hook: useUserAuth()

CVBuilderContext

File: contexts/CVBuilderContext.tsx

Manages state during the CV builder wizard.

StateTypeDescription
Personal infoobjectName, email, phone, links
SkillsarraySkills with proficiency levels
ExperiencesarrayWork experience entries
EducationarrayEducation entries
PortfolioarrayPortfolio links
isFromExtractionbooleanWhether CV was AI-extracted or manual

OnboardingContext

File: contexts/OnboardingContext.tsx

Multi-step onboarding flow state.

StateTypeDescription
parsedCvobjectCV data from upload/extraction
profileInfoobjectName, email, phone, links
preferencesobjectjobType, workType, location, salary

Extensible for future sections: experiences, education, skills.

ModalContext

File: contexts/ModalContext.tsx

Global modal state management with 5 named modal types:

ModalPurpose
candidateCandidate detail modal
talentPoolTalent pool detail modal
contactContact detail modal
delete_candidateDelete confirmation
addCandidateAdd candidate form
MethodPurpose
isModalOpen(name)Check if a specific modal is open
openModal(name, data?)Open modal with optional data
closeModal(name)Close a specific modal

NotificationContext

File: contexts/NotificationContext.tsx

Polling-based notification management.

StateTypeDescription
unreadCountnumberTotal unread notifications
isConnectedbooleanPolling active
lastNotificationNotificationMost recent notification

Behavior:

  • Polls UNREAD_NOTIFICATION_COUNT every 30 seconds
  • Updates document title with badge count
  • Shows toast on new messages
  • Monitors user activity (pauses when idle)

PageBlockContext

File: contexts/PageBlockContext.tsx

Slot-based layout system for PageContainer. Allows child components to register content in named slots without prop drilling.

MethodPurpose
setSidebar(node)Register sidebar content
setHeader(node)Register header content
setFooter(node)Register footer content
StatePurpose
paginationCurrent pagination state
viewModeGrid / list / table
layoutLayout configuration

ThemeContext (ColorThemeProvider)

File: contexts/ThemeContext.tsx

Dynamic CSS variable injection based on user-selected theme.

StateTypeDescription
currentThemeThemeActive theme object (6 colors)
themeIdstringTheme identifier
isLoadingbooleanTheme loading state
errorErrorTheme errors
MethodPurpose
setTheme(themeId)Change theme (async, persists via GraphQL mutation)

Injects CSS variables: --primary, --secondary, --tertiary, --light, --background, --text-dark. Supports gradient generation.

WebSocketContext

File: contexts/WebSocketContext.tsx

Plain WebSocket connection management for real-time features.

StateTypeDescription
statusstringconnecting, connected, disconnected, failed
isConnectedbooleanConnection active
clientIdstringClient identifier
errorErrorConnection errors
MethodPurpose
send(event, data)Send a message
on(event, handler)Subscribe to events
off(event, handler)Unsubscribe from events
connect()Establish connection
disconnect()Close connection

Features: Auto-reconnect with exponential backoff, 30-second heartbeat, event-based routing.

info

Initialized with autoConnect={false}. Components must call connect() explicitly.

DevOverlayContext

File: contexts/DevOverlayContext.tsx

Development-only component debugger.

StateTypeDescription
isEnabledbooleanOverlay active
hoveredComponentstringCurrently highlighted component
highlightRectDOMRectHighlight bounding box
isPanelMinimizedbooleanDebug panel minimized

Activation: Ctrl+Shift+D keyboard shortcut. Shows component boundaries, names, and a debug panel with component tree info.